⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _ocr_example_image_view_8cpp-source.html

📁 基于symbian 平台 ocr 示例程序
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00493"></a>00493         TRAP(err, engine-&gt;LayoutAnalysisL(<a class="code" href="class_c_ocr_example_image_view.html#9eb6fa3188758350a81b83400892e787">iBitMap</a>-&gt;Handle(), layoutSettings));<a name="l00494"></a>00494         <span class="keywordflow">if</span> (err)<a name="l00495"></a>00495             {<a name="l00496"></a>00496             _LIT(KLayoutFailed,<span class="stringliteral">"Starting analysis failed"</span>);<a name="l00497"></a>00497             <a class="code" href="class_c_ocr_example_image_view.html#5d97b3005d7025da3ce0f8f008328e43">DisplayWarningL</a>(KLayoutFailed, err);<a name="l00498"></a>00498             }<a name="l00499"></a>00499         <span class="keywordflow">else</span><a name="l00500"></a>00500             {<a name="l00501"></a>00501              <span class="comment">// this is a blocking call</span><a name="l00502"></a>00502             <span class="keywordflow">if</span> (! <a class="code" href="class_c_ocr_example_image_view.html#41df03d3f25580af9a93f5af442ce677">ExecuteWaitNoteL</a>())<a name="l00503"></a>00503                 {<a name="l00504"></a>00504                 <span class="comment">// cancelled by user</span><a name="l00505"></a>00505                 engine-&gt;Base()-&gt;CancelOperation();<a name="l00506"></a>00506                 }<a name="l00507"></a>00507             }<a name="l00508"></a>00508         }<a name="l00509"></a>00509     }<a name="l00510"></a>00510 <a name="l00511"></a>00511 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00512"></a>00512 <span class="comment">// COcrExampleImageView::RecognizeImageL()</span><a name="l00513"></a>00513 <span class="comment">//</span><a name="l00514"></a>00514 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00515"></a>00515 <span class="comment">//</span><a name="l00516"></a><a class="code" href="class_c_ocr_example_image_view.html#72da075f30fbcf471e8af996ae74f499">00516</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#72da075f30fbcf471e8af996ae74f499">COcrExampleImageView::RecognizeImageL</a>()<a name="l00517"></a>00517     {<a name="l00518"></a>00518     ASSERT(<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> &gt; 0);<a name="l00519"></a>00519     ASSERT(<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="l00520"></a>00520     ASSERT(<a class="code" href="class_c_ocr_example_image_view.html#c22846eecaea51cfb97699603e4227b3">iEngine</a> != NULL);<a name="l00521"></a>00521 <a name="l00522"></a>00522     RArray&lt;TInt&gt; blockIndex;<a name="l00523"></a>00523     CleanupClosePushL(blockIndex);<a name="l00524"></a>00524 <a name="l00525"></a>00525     <span class="keywordflow">for</span> (TInt i = 0; i &lt; <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>; ++i)<a name="l00526"></a>00526         {<a name="l00527"></a>00527         blockIndex.Append(i);<a name="l00528"></a>00528         }<a name="l00529"></a>00529 <a name="l00530"></a>00530     TOCRRecognizeSetting dummy;<a name="l00531"></a>00531     dummy.iAny = NULL;<a name="l00532"></a>00532 <a name="l00533"></a>00533     <span class="comment">// convert the instance from MOCREngineInterface point to</span><a name="l00534"></a>00534     <span class="comment">// MOCREngineLayoutRecognize</span><a name="l00535"></a>00535     MOCREngineLayoutRecognize* engine = static_cast&lt;MOCREngineLayoutRecognize*&gt;(<a class="code" href="class_c_ocr_example_image_view.html#c22846eecaea51cfb97699603e4227b3">iEngine</a>);<a name="l00536"></a>00536 <a name="l00537"></a>00537     <span class="comment">// async operation. RecognizeComplete() will be called, when ready</span><a name="l00538"></a>00538     TRAPD(err, engine-&gt;RecognizeL(dummy, blockIndex));<a name="l00539"></a>00539     <span class="keywordflow">if</span> (err)<a name="l00540"></a>00540         {<a name="l00541"></a>00541         _LIT(KFailed,<span class="stringliteral">"Starting recognition failed"</span>);<a name="l00542"></a>00542         <a class="code" href="class_c_ocr_example_image_view.html#5d97b3005d7025da3ce0f8f008328e43">DisplayWarningL</a>(KFailed, err);<a name="l00543"></a>00543         }<a name="l00544"></a>00544 <a name="l00545"></a>00545     CleanupStack::PopAndDestroy(&amp;blockIndex);<a name="l00546"></a>00546     }<a name="l00547"></a>00547 <a name="l00548"></a>00548 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00549"></a>00549 <span class="comment">// COcrExampleImageView::RecognizeBlockL()</span><a name="l00550"></a>00550 <span class="comment">//</span><a name="l00551"></a>00551 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00552"></a>00552 <span class="comment">//</span><a name="l00553"></a><a class="code" href="class_c_ocr_example_image_view.html#a31d77d219f1dc7b797c06d4356fefd9">00553</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#a31d77d219f1dc7b797c06d4356fefd9">COcrExampleImageView::RecognizeBlockL</a>()<a name="l00554"></a>00554     {<a name="l00555"></a>00555     ASSERT( <a class="code" href="class_c_ocr_example_image_view.html#9eb6fa3188758350a81b83400892e787">iBitMap</a>-&gt;Handle() );<a name="l00556"></a>00556     ASSERT( <a class="code" href="class_c_ocr_example_image_view.html#e72899bf23845a10c6b7559c2e896baa">iData</a>.<a class="code" href="class_t_screen_update_data.html#3beeffcd97169ea8291ae2fffec377e8">iCrosshair</a> != NULL );<a name="l00557"></a>00557 <a name="l00558"></a>00558     TRAPD(err, <a class="code" href="class_c_ocr_example_image_view.html#b32756a8fbffada316fc03085c4d0d52">InitializeOCREngineL</a>( OCREngineFactory::EEngineRecognizeBlock ));<a name="l00559"></a>00559     <span class="keywordflow">if</span> (err)<a name="l00560"></a>00560         {<a name="l00561"></a>00561         _LIT(KInitFailed,<span class="stringliteral">"Initializing OCR Engine failed"</span>);<a name="l00562"></a>00562         <a class="code" href="class_c_ocr_example_image_view.html#5d97b3005d7025da3ce0f8f008328e43">DisplayWarningL</a>(KInitFailed, err);<a name="l00563"></a>00563         }<a name="l00564"></a>00564     <span class="keywordflow">else</span><a name="l00565"></a>00565         {<a name="l00566"></a>00566         <span class="comment">// convert the instance from MOCREngineInterface point to</span><a name="l00567"></a>00567         <span class="comment">// MOCREngineLayoutRecognize</span><a name="l00568"></a>00568         MOCREngineRecognizeBlock* engine =<a name="l00569"></a>00569             static_cast&lt;MOCREngineRecognizeBlock*&gt;(<a class="code" href="class_c_ocr_example_image_view.html#c22846eecaea51cfb97699603e4227b3">iEngine</a>);<a name="l00570"></a>00570 <a name="l00571"></a>00571         <span class="comment">// fill struct with default values</span><a name="l00572"></a>00572         TOCRLayoutBlockInfo layoutInfo;<a name="l00573"></a>00573         layoutInfo.iLayout = EOcrLayoutTypeH;<a name="l00574"></a>00574         layoutInfo.iText = EOcrTextMultiLine;<a name="l00575"></a>00575         layoutInfo.iBackgroundColor = EOcrBackgroundLight;<a name="l00576"></a>00576 <a name="l00577"></a>00577         <span class="comment">// calculate rect based on scaled crosshair</span><a name="l00578"></a>00578         layoutInfo.iRect = <a class="code" href="class_c_ocr_example_image_view.html#e72899bf23845a10c6b7559c2e896baa">iData</a>.<a class="code" href="class_t_screen_update_data.html#d8df217ecaec20976c2b240f971a5034">iRectScaler</a>.<a class="code" href="class_n_o_c_r_utils_1_1_t_rect_scaler.html#ca08d2a24ef3ed2929d7054436b3e366">ScaleUp</a>( *(<a class="code" href="class_c_ocr_example_image_view.html#e72899bf23845a10c6b7559c2e896baa">iData</a>.<a class="code" href="class_t_screen_update_data.html#3beeffcd97169ea8291ae2fffec377e8">iCrosshair</a>) );<a name="l00579"></a>00579 <a name="l00580"></a>00580         <span class="comment">// create and execute form. Don't care about return value</span><a name="l00581"></a>00581         <a class="code" href="class_n_o_c_r_utils_1_1_c_layout_form.html#570327852c83286fdc8be676cebfdcf6">NOCRUtils::CLayoutForm::ExecuteFormLD</a>( layoutInfo,<a name="l00582"></a>00582                                                R_RECOGNIZE_BLOCK_FORM_DIALOG);<a name="l00583"></a>00583 <a name="l00584"></a>00584 <span class="preprocessor">        #ifdef _DEBUG</span><a name="l00585"></a>00585 <span class="preprocessor"></span>        _LIT(KSettings,<span class="stringliteral">"OCR: settings layout: %d, text: %d, brightness: %d"</span>);<a name="l00586"></a>00586         RDebug::Print(KSettings, layoutInfo.iLayout, layoutInfo.iText, layoutInfo.iBackgroundColor);<a name="l00587"></a>00587 <span class="preprocessor">        #endif</span><a name="l00588"></a>00588 <span class="preprocessor"></span><a name="l00589"></a>00589         <span class="comment">// async operation. LayoutComplete() will be called, when ready</span><a name="l00590"></a>00590         TRAP(err, engine-&gt;RecognizeBlockL(<a class="code" href="class_c_ocr_example_image_view.html#9eb6fa3188758350a81b83400892e787">iBitMap</a>-&gt;Handle(), layoutInfo));<a name="l00591"></a>00591         <span class="keywordflow">if</span> (err)<a name="l00592"></a>00592             {<a name="l00593"></a>00593             _LIT(KFailed,<span class="stringliteral">"Starting recognize block failed"</span>);<a name="l00594"></a>00594             <a class="code" href="class_c_ocr_example_image_view.html#5d97b3005d7025da3ce0f8f008328e43">DisplayWarningL</a>(KFailed, err);<a name="l00595"></a>00595             }<a name="l00596"></a>00596         <span class="keywordflow">else</span><a name="l00597"></a>00597             {<a name="l00598"></a>00598              <span class="comment">// this is a blocking call</span><a name="l00599"></a>00599             <span class="keywordflow">if</span> (! <a class="code" href="class_c_ocr_example_image_view.html#41df03d3f25580af9a93f5af442ce677">ExecuteWaitNoteL</a>())<a name="l00600"></a>00600                 {<a name="l00601"></a>00601                 <span class="comment">// cancelled by user</span><a name="l00602"></a>00602                 engine-&gt;Base()-&gt;CancelOperation();<a name="l00603"></a>00603                 }<a name="l00604"></a>00604             }<a name="l00605"></a>00605         }<a name="l00606"></a>00606     }<a name="l00607"></a>00607 <a name="l00608"></a>00608 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00609"></a>00609 <span class="comment">// COcrExampleImageView::RecognizeSpecialRegionL()</span><a name="l00610"></a>00610 <span class="comment">//</span><a name="l00611"></a>00611 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00612"></a>00612 <span class="comment">//</span><a name="l00613"></a><a class="code" href="class_c_ocr_example_image_view.html#fac0e83d0111d471ebf4deffd9f87bc2">00613</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#fac0e83d0111d471ebf4deffd9f87bc2">COcrExampleImageView::RecognizeSpecialRegionL</a>()<a name="l00614"></a>00614     {<a name="l00615"></a>00615     ASSERT( <a class="code" href="class_c_ocr_example_image_view.html#9eb6fa3188758350a81b83400892e787">iBitMap</a>-&gt;Handle() );<a name="l00616"></a>00616     ASSERT( <a class="code" href="class_c_ocr_example_image_view.html#e72899bf23845a10c6b7559c2e896baa">iData</a>.<a class="code" href="class_t_screen_update_data.html#3beeffcd97169ea8291ae2fffec377e8">iCrosshair</a> != NULL );<a name="l00617"></a>00617 <a name="l00618"></a>00618     TRAPD(err, <a class="code" href="class_c_ocr_example_image_view.html#b3

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -