📄 _ocr_example_image_view_8cpp-source.html
字号:
<a name="l00365"></a>00365 <span class="comment">// this is a blocking call</span><a name="l00366"></a>00366 <span class="keywordflow">if</span> (! <a class="code" href="class_c_ocr_example_image_view.html#41df03d3f25580af9a93f5af442ce677">ExecuteWaitNoteL</a>())<a name="l00367"></a>00367 {<a name="l00368"></a>00368 <span class="comment">// cancelled</span><a name="l00369"></a>00369 <a class="code" href="class_c_ocr_example_image_view.html#56132cb68e64726ad0658571e44e9644">iHandler</a>->Cancel();<a name="l00370"></a>00370 }<a name="l00371"></a>00371 }<a name="l00372"></a>00372 }<a name="l00373"></a>00373 }<a name="l00374"></a>00374 <a name="l00375"></a>00375 <span class="comment">// -----------------------------------------------------------------------------</span><a name="l00376"></a>00376 <span class="comment">// COcrExampleImageView::CloseImage()</span><a name="l00377"></a>00377 <span class="comment">// -----------------------------------------------------------------------------</span><a name="l00378"></a>00378 <span class="comment">//</span><a name="l00379"></a><a class="code" href="class_c_ocr_example_image_view.html#7561e6dda22ddb24f4b8c58d0229ebc5">00379</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#7561e6dda22ddb24f4b8c58d0229ebc5">COcrExampleImageView::CloseImage</a>()<a name="l00380"></a>00380 {<a name="l00381"></a>00381 <a class="code" href="class_c_ocr_example_image_view.html#9eb6fa3188758350a81b83400892e787">iBitMap</a>->Reset();<a name="l00382"></a>00382 <a class="code" href="class_c_ocr_example_image_view.html#e72899bf23845a10c6b7559c2e896baa">iData</a>.<a class="code" href="class_t_screen_update_data.html#ea6eefa2a3b0315b12fbb5ab0532a849">iScaledBitMap</a>->Reset();<a name="l00383"></a>00383 <a class="code" href="class_c_ocr_example_image_view.html#63052a309baec315239b427aa7647b76">iState</a> = <a class="code" href="class_c_ocr_example_image_view.html#8e0e9e3030ee220d737a3e9e733390ec553253ec36b6a826ce4923c5dcf95a12">EInit</a>;<a name="l00384"></a>00384 <a class="code" href="class_c_ocr_example_image_view.html#b815b1b6d046be197859ca009a28a50a">ReleaseOCREngine</a>();<a name="l00385"></a>00385 }<a name="l00386"></a>00386 <a name="l00387"></a>00387 <span class="comment">// -----------------------------------------------------------------------------</span><a name="l00388"></a>00388 <span class="comment">// COcrExampleImageView::ReleaseOCREngine()</span><a name="l00389"></a>00389 <span class="comment">// -----------------------------------------------------------------------------</span><a name="l00390"></a>00390 <span class="comment">//</span><a name="l00391"></a><a class="code" href="class_c_ocr_example_image_view.html#b815b1b6d046be197859ca009a28a50a">00391</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#b815b1b6d046be197859ca009a28a50a">COcrExampleImageView::ReleaseOCREngine</a>()<a name="l00392"></a>00392 {<a name="l00393"></a>00393 <span class="keywordflow">if</span> (<a class="code" href="class_c_ocr_example_image_view.html#c22846eecaea51cfb97699603e4227b3">iEngine</a>)<a name="l00394"></a>00394 {<a name="l00395"></a>00395 OCREngineFactory::ReleaseOCREngine(<a class="code" href="class_c_ocr_example_image_view.html#c22846eecaea51cfb97699603e4227b3">iEngine</a>);<a name="l00396"></a>00396 iEngine = NULL;<a name="l00397"></a>00397 <a name="l00398"></a>00398 <span class="keywordflow">if</span> (<a class="code" href="class_c_ocr_example_image_view.html#e72899bf23845a10c6b7559c2e896baa">iData</a>.<a class="code" href="class_t_screen_update_data.html#95ab72856a165c79d387b1fe1060f649">iBlockInfo</a> != NULL)<a name="l00399"></a>00399 {<a name="l00400"></a>00400 <a class="code" href="class_c_ocr_example_image_view.html#e72899bf23845a10c6b7559c2e896baa">iData</a>.<a class="code" href="class_t_screen_update_data.html#95ab72856a165c79d387b1fe1060f649">iBlockInfo</a> = NULL;<a name="l00401"></a>00401 <a class="code" href="class_c_ocr_example_image_view.html#e72899bf23845a10c6b7559c2e896baa">iData</a>.<a class="code" href="class_t_screen_update_data.html#4d5bc772261d36c752b058c133d81978">iBlockCount</a> = 0;<a name="l00402"></a>00402 <span class="comment">// content changed in UI</span><a name="l00403"></a>00403 <a class="code" href="class_c_ocr_example_image_view.html#6dc94c8cd7c107bc61701348814020e6">iContainer</a>->DrawDeferred();<a name="l00404"></a>00404 }<a name="l00405"></a>00405 }<a name="l00406"></a>00406 }<a name="l00407"></a>00407 <a name="l00408"></a>00408 <span class="comment">// -----------------------------------------------------------------------------</span><a name="l00409"></a>00409 <span class="comment">// COcrExampleImageView::InitializeOCREngineL()</span><a name="l00410"></a>00410 <span class="comment">// -----------------------------------------------------------------------------</span><a name="l00411"></a>00411 <span class="comment">//</span><a name="l00412"></a><a class="code" href="class_c_ocr_example_image_view.html#b32756a8fbffada316fc03085c4d0d52">00412</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#b32756a8fbffada316fc03085c4d0d52">COcrExampleImageView::InitializeOCREngineL</a>(<a name="l00413"></a>00413 OCREngineFactory::TEngineType aEngineType )<a name="l00414"></a>00414 {<a name="l00415"></a>00415 TOcrEngineEnv env;<a name="l00416"></a>00416 env.iPriority = EPriorityLess; <span class="comment">// thread's priority</span><a name="l00417"></a>00417 env.iMaxHeapSize = 1200*KMinHeapGrowBy; <span class="comment">// thread's heap maximum size</span><a name="l00418"></a>00418 <a name="l00419"></a>00419 <span class="comment">// release create the OCR engine instance.</span><a name="l00420"></a>00420 <a class="code" href="class_c_ocr_example_image_view.html#b815b1b6d046be197859ca009a28a50a">ReleaseOCREngine</a>();<a name="l00421"></a>00421 <a name="l00422"></a>00422 <a class="code" href="class_c_ocr_example_image_view.html#c22846eecaea51cfb97699603e4227b3">iEngine</a> = OCREngineFactory::CreateOCREngineL(*<span class="keyword">this</span>, env, aEngineType);<a name="l00423"></a>00423 <a name="l00424"></a>00424 <span class="comment">// set active languages</span><a name="l00425"></a>00425 RArray<TLanguage> languages;<a name="l00426"></a>00426 CleanupClosePushL(languages);<a name="l00427"></a>00427 <a name="l00428"></a>00428 <span class="preprocessor"> #ifdef _DEBUG</span><a name="l00429"></a>00429 <span class="preprocessor"></span> _LIT(KInstalledLangs,<span class="stringliteral">"OCR: Installed languages:"</span>);<a name="l00430"></a>00430 _LIT(KLangId,<span class="stringliteral">"OCR: language id: %d"</span>);<a name="l00431"></a>00431 RDebug::Print(KInstalledLangs);<a name="l00432"></a>00432 <a class="code" href="class_c_ocr_example_image_view.html#c22846eecaea51cfb97699603e4227b3">iEngine</a>->Base()->GetInstalledLanguage(languages);<a name="l00433"></a>00433 <span class="keywordflow">for</span> (TInt i = 0; i < languages.Count(); ++i)<a name="l00434"></a>00434 {<a name="l00435"></a>00435 RDebug::Print(KLangId, languages[i]);<a name="l00436"></a>00436 }<a name="l00437"></a>00437 languages.Reset();<a name="l00438"></a>00438 <span class="preprocessor"> #endif</span><a name="l00439"></a>00439 <span class="preprocessor"></span><a name="l00440"></a>00440 iSettings.GetLanguages(languages);<a name="l00441"></a>00441 <a name="l00442"></a>00442 <span class="preprocessor"> #ifdef _DEBUG</span><a name="l00443"></a>00443 <span class="preprocessor"></span> _LIT(KLangs,<span class="stringliteral">"OCR: languages to be set:"</span>);<a name="l00444"></a>00444 RDebug::Print(KLangs);<a name="l00445"></a>00445 <span class="keywordflow">for</span> (TInt i = 0; i < languages.Count(); ++i)<a name="l00446"></a>00446 {<a name="l00447"></a>00447 RDebug::Print(KLangId, languages[i]);<a name="l00448"></a>00448 }<a name="l00449"></a>00449 <span class="preprocessor"> #endif</span><a name="l00450"></a>00450 <span class="preprocessor"></span><a name="l00451"></a>00451 iEngine->Base()->SetActiveLanguageL(languages);<a name="l00452"></a>00452 <a name="l00453"></a>00453 CleanupStack::PopAndDestroy(&languages);<a name="l00454"></a>00454 }<a name="l00455"></a>00455 <a name="l00456"></a>00456 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00457"></a>00457 <span class="comment">// COcrExampleImageView::AnalyzeImageLayoutL()</span><a name="l00458"></a>00458 <span class="comment">//</span><a name="l00459"></a>00459 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00460"></a>00460 <span class="comment">//</span><a name="l00461"></a><a class="code" href="class_c_ocr_example_image_view.html#deb0a73c2e8490684e18cea6caa9af23">00461</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#deb0a73c2e8490684e18cea6caa9af23">COcrExampleImageView::AnalyzeImageLayoutL</a>()<a name="l00462"></a>00462 {<a name="l00463"></a>00463 ASSERT(<a class="code" href="class_c_ocr_example_image_view.html#9eb6fa3188758350a81b83400892e787">iBitMap</a>->Handle());<a name="l00464"></a>00464 <a name="l00465"></a>00465 TRAPD(err, <a class="code" href="class_c_ocr_example_image_view.html#b32756a8fbffada316fc03085c4d0d52">InitializeOCREngineL</a>( OCREngineFactory::EEngineLayoutRecognize ));<a name="l00466"></a>00466 <span class="keywordflow">if</span> (err)<a name="l00467"></a>00467 {<a name="l00468"></a>00468 _LIT(KInitFailed,<span class="stringliteral">"Initializing OCR Engine failed"</span>);<a name="l00469"></a>00469 <a class="code" href="class_c_ocr_example_image_view.html#5d97b3005d7025da3ce0f8f008328e43">DisplayWarningL</a>(KInitFailed, err);<a name="l00470"></a>00470 }<a name="l00471"></a>00471 <span class="keywordflow">else</span><a name="l00472"></a>00472 {<a name="l00473"></a>00473 <span class="comment">// convert the instance from MOCREngineInterface point to</span><a name="l00474"></a>00474 <span class="comment">// MOCREngineLayoutRecognize</span><a name="l00475"></a>00475 MOCREngineLayoutRecognize* engine =<a name="l00476"></a>00476 static_cast<MOCREngineLayoutRecognize*>(<a class="code" href="class_c_ocr_example_image_view.html#c22846eecaea51cfb97699603e4227b3">iEngine</a>);<a name="l00477"></a>00477 <a name="l00478"></a>00478 <span class="comment">// layout analysis</span><a name="l00479"></a>00479 TOCRLayoutSetting layoutSettings;<a name="l00480"></a>00480 layoutSettings.iBrightness = TOCRLayoutSetting::ENormal;<a name="l00481"></a>00481 layoutSettings.iSkew = ETrue;<a name="l00482"></a>00482 <a name="l00483"></a>00483 <span class="comment">// create and execute form. Don't care about return value</span><a name="l00484"></a>00484 <a class="code" href="class_n_o_c_r_utils_1_1_c_layout_form.html#570327852c83286fdc8be676cebfdcf6">NOCRUtils::CLayoutForm::ExecuteFormLD</a>( layoutSettings,<a name="l00485"></a>00485 R_ANALYZE_LAYOUT_FORM_DIALOG);<a name="l00486"></a>00486 <a name="l00487"></a>00487 <span class="preprocessor"> #ifdef _DEBUG</span><a name="l00488"></a>00488 <span class="preprocessor"></span> _LIT(KSettings,<span class="stringliteral">"OCR: settings skew: %d, brightness: %d"</span>);<a name="l00489"></a>00489 RDebug::Print(KSettings, layoutSettings.iSkew, layoutSettings.iBrightness);<a name="l00490"></a>00490 <span class="preprocessor"> #endif</span><a name="l00491"></a>00491 <span class="preprocessor"></span><a name="l00492"></a>00492 <span class="comment">// async operation. LayoutComplete() will be called, when ready</span>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -