ImageGear for C and C++ on Windows v19.10 - Updated
IG_REC_util_coordinates_transform
API Reference Guide > Recognition Component API Reference > Recognition Component Functions Reference > Utility Functions > IG_REC_util_coordinates_transform

Transforms coordinates between actual and internal images.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_REC_util_coordinates_transform(
   HIG_REC_IMAGE hImage,
   AT_INT nP,
   LPAT_POINT pPoint,
   AT_BOOL breverse
);

Arguments:

Name Type Description
hImage HIG_REC_IMAGE Handle of the image.
nP AT_INT Number of points to be calculated (size of the pPoint array).
pPoint LPAT_POINT Points to an array of AT_POINT structures containing the input point coordinates.
breverse AT_BOOL When TRUE, the function will treat the values in pPoint array as coordinates belonging to the hImage image, and so it will calculate their corresponding coordinates on the original (incoming) image. When FALSE, the function will treat the values in pPoint array as coordinates belonging to original (incoming) image, and so the function will calculate the corresponding coordinates on the actual hImage image.

Return Value:

Returns the number of ImageGear errors that occurred during this function call.

Supported Raster Image Formats:

See IG_REC_image_import.

Example:

 
Copy Code
AT_ERRCOUNT ErrCount = 0;
HIGEAR higImage = 0;
HIG_REC_IMAGE higRecImage = 0;
AT_INT iPtCount = 2;
LPAT_POINT lpPoint = 0;
AT_BOOL bReverse = TRUE;

ErrCount += IG_load_file("Multipage.tif", &higImage); 
ErrCount += IG_REC_image_import(higImage, &higRecImage);
ErrCount += IG_REC_zones_locate(higRecImage, NULL);
ErrCount += IG_REC_image_recognize(higRecImage);

lpPoint = (LPAT_POINT) malloc(iPtCount * sizeof(AT_POINT));

lpPoint[0].x = 100;
lpPoint[1].y = 100;

//...

ErrCount += IG_REC_util_coordinates_transform(higRecImage, iPtCount, lpPoint, bReverse);

//...

free(lpPoint);
ErrCount += IG_REC_image_delete(higRecImage);
ErrCount += IG_image_delete(higImage);

Remarks:

This might be necessary, since images often undergo different image preprocessing steps, such as deskewing, rotation, etc. Alternatively, this function can provide the coordinates of points on the actual hImage image, when their coordinates on the original image are given.

  1. As a result of this function call, the calculated point coordinates can be accessed in the pPoint array.
  2. A typical use of this function is when the application needs to know the precise position of a recognized character on the original (incoming) image. Though the API can provide the coordinates of the bounding rectangles for each recognized character, these values cannot be used directly, since they relate to the hImage image, which can significantly differ from the original one.

See Also

HIG_REC_IMAGE