📄 index.html
字号:
Both text and settings views are such that the view-class does not require any customization. And what suits for one, suits also to another one. Thus the view-functionality is implemented by template, and all differentiating functionality is specified either with template parameters or with parameters passed to <a class="el" href="class_n_o_c_r_utils_1_1_c_simple_view.html#f82712d9bbd47a3fbb8579fff98069d8">NewL </a>. <br> The container is created, when the view is activated, and destroyed when deactivated. And when Back- or Ok-button is given, the previous view is activated. <br> Containers of these two simple views are<ul><li><a class="el" href="class_c_ocr_example_text_container.html">COcrExampleTextContainer</a>, and</li><li><a class="el" href="class_c_ocr_example_settings_container.html">COcrExampleSettingsContainer</a>.</li></ul><h3><a class="anchor" name="Sub33">3.3 Opening File</a></h3>Initially image-view Options offer just Open File- and Settings-commands. <a class="el" href="class_c_ocr_example_image_view.html#3ae77c2aed5e1270a13c14bd5aa415fe">COcrExampleImageView::DynInitMenuPaneL</a> implements menu's dynamic handling.<p>Open File -functionality is implemented in <a class="el" href="class_c_ocr_example_image_view.html#2003512dd8696219849f58d8ae1e3c37">COcrExampleImageView::OpenImageL()</a>:<ul><li>First file selection dialog is executed. In the OcrExample.rss MEMORYSELECTIONDIALOG is defined, so that the user can choose between phone memory and memory card from where to seek the file. <br> The whole dialog functionality and directory browsing is implemented by AknCommonDialogs.</li><li>If image file was chosen, the previously loaded image - if such exists - is closed and freed.</li><li>Then image-view request loading - and scaling of image - by calling <a class="el" href="class_n_o_c_r_utils_1_1_c_image_handler.html#0135e243bf1c2ba8db5d62edc631e3d4">NOCRUtils::CImageHandler::LoadFileAndScaleL()</a>. The filename and the size of the screen are passed as parameters. <br> The file loading and scaling operations are asynchronous, executed by CImageHandler active object: the handler will first load the original image to <a class="el" href="class_c_ocr_example_image_view.html#9eb6fa3188758350a81b83400892e787">COcrExampleImageView::iBitMap</a>, and then scale the image to fit the screen and store it to <a class="el" href="class_t_screen_update_data.html#ea6eefa2a3b0315b12fbb5ab0532a849">TScreenUpdateData::iScaledBitMap</a>.</li><li>Then image-view will execute wait-note for the duration of loading and scaling. See <a class="el" href="class_c_ocr_example_image_view.html#41df03d3f25580af9a93f5af442ce677">COcrExampleImageView::ExecuteWaitNoteL()</a>.</li><li>The image-view acts as an observer to the image handler i.e. the view-class inherits <a class="el" href="class_n_o_c_r_utils_1_1_m_image_handler_callback.html">NOCRUtils::MImageHandlerCallback</a>. The handler will call <a class="el" href="class_c_ocr_example_image_view.html#09a548f36fef23b5490ecdf57e2bdd1a">ImageOperationCompleteL </a>, when loading and scaling have been completed.</li><li>When <a class="el" href="class_c_ocr_example_image_view.html#09a548f36fef23b5490ecdf57e2bdd1a">ImageOperationCompleteL </a> is called, the image-view checks, whether operation was successful - and if so, the sizes of the original and scaled image are passed to a small help-utility <a class="el" href="class_t_screen_update_data.html#d8df217ecaec20976c2b240f971a5034">TScreenUpdateData::iRectScaler</a>, which is used to resize rectangles between original and scaled images. Next drawing is requested. See also <a class="el" href="index.html#SubDrawing">3.6 Drawing the screen</a></li></ul><h3><a class="anchor" name="Sub34">3.4 OCR operations</a></h3>When the image has been loaded, OCR operations become available. Similarly as in the actual OCR API, the operations are divided to two groups:<ul><li>layout analysis of the whole image and recognition (of analysed areas), and</li><li>block or special region recognition of the user-specified rectangle.</li></ul><p>The state of the cross-hair rectangle defines, which group of commands are available:<ul><li>if the cross-hair is disabled, layout analysis and recognition can be done;</li><li>if the cross-hair is enabled, then it defines the area of the image to be recognized (block or special region). The user can use arrow-keys to move the cross-hair and change its size via Settings.</li></ul><p>When an OCR operation is started, the application executes a simple form dialog (<a class="el" href="class_n_o_c_r_utils_1_1_c_layout_form.html">NOCRUtils::CLayoutForm</a>) to specify the settings used in the OCR operation. The asked options match one-to-one to the parameters of the particular OCR interface to be triggered. (Recognition of regions produced by layout analysis is the exception - as the interface does not currently have any operational parameters.) <br> For details of those options, refer to OCR API documentation.<p>OCR operations are asynchronous and completion - for better or worse - is informed via callbacks.<h4><a class="anchor" name="Sub341">3.4.1 Initializing OCR Engine</a></h4>Whenever a new layout analysis, block or special region recognition is to be done, OCR Engine initialization takes place. (Note, that recognition of regions acquired from layout analysis does not do OCR Engine initialization as analysis and recognition is two-step process and thus uses the same initialized engine.)<p><a class="el" href="class_c_ocr_example_image_view.html#b32756a8fbffada316fc03085c4d0d52">COcrExampleImageView::InitializeOCREngineL</a> contains the initialization steps:<ul><li>possible previously initialized OCR Engine is first released,</li><li>then a new one is created (the caller informs which type of engine should be initialized), and</li><li>used languages are informed to OCR Engine. The language set is taken from the settings, which in this example allows English, Chinese or Japanese to be used.</li></ul><h4><a class="anchor" name="Sub342">3.4.2 Operations</a></h4><a class="el" href="class_c_ocr_example_image_view.html#deb0a73c2e8490684e18cea6caa9af23">COcrExampleImageView::AnalyzeImageLayoutL()</a> triggers analyze layout operation. OCR Engine informs the completion by calling <a class="el" href="class_c_ocr_example_image_view.html#41758248db42aec6d42d6a54b13d36b8">COcrExampleImageView::LayoutComplete()</a>. <br> If layout analysis was successful, the block info is written to the log file and the text-view is activated to show the results. See <a class="el" href="index.html#SubTextView">3.5 Text view</a>.<p><a class="el" href="class_c_ocr_example_image_view.html#72da075f30fbcf471e8af996ae74f499">COcrExampleImageView::RecognizeImageL()</a> triggers the recognition of regions identified by analysis operation. (This operation is not available until analysis has been done.) All regions are asked to be recognized. The completion callback is <a class="el" href="class_c_ocr_example_image_view.html#c8b0731eeda182f92be8229b23165d4b">COcrExampleImageView::RecognizeComplete()</a>, which directly calls <a class="el" href="class_c_ocr_example_image_view.html#4149f35a8fe71a3b10562faddd824986">COcrExampleImageView::RecognizeDoneL()</a>.<p><a class="el" href="class_c_ocr_example_image_view.html#a31d77d219f1dc7b797c06d4356fefd9">COcrExampleImageView::RecognizeBlockL()</a> triggers the block recognition operation. (The cross-hair defines the region; scaled up with <a class="el" href="class_t_screen_update_data.html#d8df217ecaec20976c2b240f971a5034">iRectScaler </a> to match the size and position of the original image.) The completion callback is <a class="el" href="class_c_ocr_example_image_view.html#5cf1fbd18ad3ec441cedf31760963484">COcrExampleImageView::RecognizeBlockComplete()</a>, which also directly calls <a class="el" href="class_c_ocr_example_image_view.html#4149f35a8fe71a3b10562faddd824986">COcrExampleImageView::RecognizeDoneL()</a>.<p><a class="el" href="class_c_ocr_example_image_view.html#fac0e83d0111d471ebf4deffd9f87bc2">COcrExampleImageView::RecognizeSpecialRegionL()</a> triggers the special region recognition operation. (The cross-hair again defines the region.) The completion callback is <a class="el" href="class_c_ocr_example_image_view.html#a05e98e6d1efee3a5bcfb61c292a8e01">COcrExampleImageView::RecognizeSpecialRegionComplete()</a>, which also directly calls <a class="el" href="class_c_ocr_example_image_view.html#4149f35a8fe71a3b10562faddd824986">COcrExampleImageView::RecognizeDoneL()</a>.<p>So, <a class="el" href="class_c_ocr_example_image_view.html#4149f35a8fe71a3b10562faddd824986">RecognizeDoneL </a> handles the recognition results in case of all three variant recognition operations. In very similar fashion as in case of analysis results, if recognition was successful, the block info and recognized texts are written to the log file and the text-view is again activated to show the results.<h3><a class="anchor" name="SubTextView">3.5 Text view</a></h3>The text view is very simple: when activated, the log file is read from the disk and the contents is shown in a read-only editor. (The whole file is always read, but the previous position is stored in the data-object of the container, so that the cursor can be set to the beginning of the new data.) The user can scroll the text up and down - and when she exits the view, the control returns back to the image view.<p>The implementation of text view is in class <a class="el" href="class_c_ocr_example_text_container.html">COcrExampleTextContainer</a> and the view-layer is taken care of by <a class="el" href="class_n_o_c_r_utils_1_1_c_simple_view.html">NOCRUtils::CSimpleView</a>.<h3><a class="anchor" name="SubDrawing">3.6 Drawing the screen</a></h3>When the framework calls <a class="el" href="class_c_ocr_example_image_container.html#67f946ca7848ec78de4961c5bcefdb72">Draw() </a> OCR Example draws the scaled version of the image (assuming one is loaded) to the screen.<p>Then if cross-hair rectangle is activated, it is also drawn on top of the image.<p>If cross-hair is not activated, but layout analysis have been successfully done, the rectangles informed by OCR Engine are drawn on top of the image. However, as the OCR operations are done to the original image, also the areas (i.e. rectangles) containing texts refer to the original image. Hence container has to adjust sizes and positions of those rectangles to fit the scaled image drawn to the screen. <a class="el" href="class_t_screen_update_data.html#d8df217ecaec20976c2b240f971a5034">TScreenUpdateData::iRectScaler</a> is then asked to scale down the rectangles, before drawing. <hr><table x-use-null-cells style="x-cell-content-align: top; width: 100%; border-spacing: 0px; border-spacing: 0px;" cellspacing=0 width=100%> <col style="width: 50%;"> <col style="width: 50%;"> <tr style="x-cell-content-align: top;" valign=top> <td style="width: 50%; padding-right: 10px; padding-left: 10px; border-right-style: None; border-left-style: None; border-top-style: None; border-bottom-style: None;" width=50%> <p style="font-family: Arial;"><small style="font-size: smaller;">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -