Nicomsoft OCR: Developer's Guide


Blk_GetTextRect


Syntax

C++:int Blk_GetTextRect(HBLK BlkObj, int LineIndex, int WordIndex, int* Xpos, int* Ypos, int* Width, int* Height)
C#:int Blk_GetTextRect(int BlkObj, int LineIndex, int WordIndex, out int Xpos, out int Ypos, out int Width, out int Height)
Visual Basic:Function Blk_GetTextRect(ByVal BlkObj As Integer, ByVal LineIndex As Integer, ByVal WordIndex As Integer, ByRef Xpos As Integer, ByRef Ypos As Integer, ByRef Width As Integer, ByRef Height As Integer) As Integer
Java:int Blk_GetTextRect(HBLK BlkObj, int LineIndex, int WordIndex, NSInt Xpos, NSInt Ypos, NSInt Width, NSInt Height)
Delphi:function Blk_GetTextRect(BlkObj:HBLK; LineIndex:integer; WordIndex:integer; out Xpos:integer; out Ypos:integer; out Width:integer; out Height:integer):integer


Description

Retrieves the bounding rectangle for the specified word or text line, or for the entire text block. Use the Blk_GetLineCnt function to get the total number of text lines in the block. Use the Blk_GetWordCnt function to get the total number of words in the specified line.


Parameters

BlkObj [IN] – the Block object. You can also specify the Image object if you want to work with the global list of text lines for the entire image.
LineIndex [IN] – the index of the text line; 0 – the first line. Specify -1 to get the rectangle for the entire block; you cannot use -1 if ImgObj is used instead of BlkObj.
WordIndex [IN] – the index of the word in the specified text line; 0 – the first word. Specify -1 to get the rectangle for the entire text line.
Xpos [OUT] – the address of the variable that will get the X coordinate of the top-left corner of the rectangle, in pixels.
Ypos [OUT] – the address of the variable that will get the Y coordinate of the top-left corner of the rectangle, in pixels.
Width [OUT] – the address of the variable that will get the width of the rectangle, in pixels.
Height [OUT] – the address of the variable that will get the height of the rectangle, in pixels.


Return value

Zero if success, otherwise an error code.


Remarks

For the best recognition quality, the rescaling and deskewing algorithms are applied to the original image at the OCRSTEP_PREFILTERS step. This function returns the position and size for the final image. To get the position/size for the original image, use the Img_CalcPointPosition function to convert coordinates.


Example

See the sample code for the Img_GetBlockCnt function.