Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Bu uygulama, basit bir el yazısı tanıma uygulaması oluşturmayı gösterir.
Bu program, mürekkep için bir InkCollector nesnesi oluşturur- pencereyi ve varsayılan tanıyıcı bağlamını nesnesi etkinleştirin. Uygulamanın menüsünden tetiklenen "Recognize!" komutunu aldıktan sonra, toplanan mürekkep vuruşları tanıyıcı bağlamına aktarılır. En iyi sonuç dizesi bir ileti kutusunda gösterilir.
RecognizerContext Nesnesi Oluşturma
Uygulamanın WndProc yordamında, başlangıçta WM_CREATE iletisi alındığında, varsayılan tanıyıcıyı kullanan yeni bir tanıyıcı bağlamı oluşturulur. Bu bağlam, uygulamadaki tüm tanıma için kullanılır.
case WM_CREATE:
{
HRESULT hr;
hr = CoCreateInstance(CLSID_InkRecognizerContext,
NULL, CLSCTX_INPROC_SERVER, IID_IInkRecognizerContext,
(void **) &g_pIInkRecoContext);
if (FAILED(hr))
{
::MessageBox(NULL, TEXT("There are no handwriting recognizers installed.\n"
"You need to have at least one in order to run this sample.\nExiting."),
gc_szAppName, MB_ICONERROR);
return -1;
}
//...
Vuruşları Tanıma
Tanıma komutu, kullanıcı "Tanıma!" düğmesine tıkladığında alınır. menü öğesi. Kod, InkDisp nesnesinin mürekkep InkStrokes (pIInkStrokes) işaretçisini alır ve putref_Strokes çağrısı kullanarak InkStrokes tanıyıcı bağlamını geçirir.
case WM_COMMAND:
//...
else if (wParam == ID_RECOGNIZE)
{
// change cursor to the system's Hourglass
HCURSOR hCursor = ::SetCursor(::LoadCursor(NULL, IDC_WAIT));
// Get a pointer to the ink stroke collection
// This collection is a snapshot of the entire ink object
IInkStrokes* pIInkStrokes = NULL;
HRESULT hr = g_pIInkDisp->get_Strokes(&pIInkStrokes);
if (SUCCEEDED(hr))
{
// Pass the stroke collection to the recognizer context
hr = g_pIInkRecoContext->putref_Strokes(pIInkStrokes);
if (SUCCEEDED(hr))
{
Kod daha sonra InkRecognizerContext nesnesinin Recognize yöntemini çağırır ve sonuçları tutmak için bir IInkRecognitionResult nesnesine bir işaretçi geçirir.
// Recognize
IInkRecognitionResult* pIInkRecoResult = NULL;
hr = g_pIInkRecoContext->Recognize(&pIInkRecoResult);
if (SUCCEEDED(hr))
{
Son olarak kod, IInkRecognitionResult nesnesinin TopString özelliğini kullanarak en iyi tanıma sonucunu dize değişkenine alır, IInkRecognitionResult nesnesini serbest bırakır ve dizeyi bir ileti kutusunda görüntüler.
// Get the best result of the recognition
BSTR bstrBestResult = NULL;
hr = pIInkRecoResult->get_TopString(&bstrBestResult);
pIInkRecoResult->Release();
pIInkRecoResult = NULL;
// Show the result string
if (SUCCEEDED(hr) && bstrBestResult)
{
MessageBoxW(hwnd, bstrBestResult,
L"Recognition Results", MB_OK);
SysFreeString(bstrBestResult);
} }
Kullanımlar arasındaki tanıyıcı bağlamını sıfırlamayı unutmayın.
// Reset the recognizer context
g_pIInkRecoContext->putref_Strokes(NULL);
}
pIInkStrokes->Release();
}
// restore the cursor
::SetCursor(hCursor);
}