ImageGear for C and C++ on Windows v19.10 - Updated
IG_REC_image_skew_detect
API Reference Guide > Recognition Component API Reference > Recognition Component Functions Reference > Image Processing Functions > IG_REC_image_skew_detect

Detects the orientation and the skew of the image specified.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_REC_image_skew_detect(
   HIG_REC_IMAGE hImage,
   LPAT_INT pSlope,
   enumIGRecImgRotate* pImgRotate
);

Arguments:

Name Type Description
hImage HIG_REC_IMAGE Handle of the image.
pSlope LPAT_INT Detects the skew of the image specified.
pImgRotate enumIGRecImgRotate* Detects the orientation and the image specified.

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 nSlope = 0; 
enumIGRecImgRotate eImgRotate = IG_REC_IMG_ROTATE_AUTO;

ErrCount += IG_load_file("Image.tif", &higImage); 
ErrCount += IG_REC_image_import(higImage, &higRecImage);
ErrCount += IG_REC_image_skew_detect(higRecImage, &nSlope, &eImgRotate);

//...

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

Remarks:

Depending on the current setting of the Image deskewing and Image rotation modes, this function returns either with the detected image skew / orientation or with the current values of these settings.

  1. This function's behavior depends on the deskewing mode set in IG_REC_deskew_mode_set:
    • IG_REC_IMG_DESKEW_AUTO: it detects the skew of the hImage image.
    • IG_REC_IMG_DESKEW_SET: it reports the current slope value setting.
    • IG_REC_IMG_DESKEW_NO: it returns zero (0).
    • IG_REC_IMG_DESKEW_3D: the function provides zero (0).
    • The current slope value is the one set by the last call to IG_REC_slope_set()
  2. Detecting the skew of the image specified is effective with images in the range of one half to 15 degrees skew.
  3. The detected skew value can be placed in IG_REC_image_deskew to immediately perform the specified amount of deskewing on a single image.
  4. The slope value can also be placed in IG_REC_slope_set, which makes it available to IG_REC_deskew_mode_set when IG_REC_IMG_DESKEW_SET is specified. Then all images will be deskewed by the given value whenever IG_REC_image_preprocess is called.
  5. If the current Image rotation mode (set by a previous IG_REC_orientation_mode_set call) is IG_REC_IMG_ROTATE_AUTO, this function provides the detected orientation of the hImage image, otherwise the current Image rotation mode setting is provided.
  6. When detecting the image rotation with Image rotation mode setting IG_REC_IMG_ROTATE_AUTO, one of the following values is returned: IG_REC_IMG_ROTATE_NO, IG_REC_IMG_ROTATE_RIGHT, IG_REC_IMG_ROTATE_DOWN, IG_REC_IMG_ROTATE_LEFT. This is the value by which the image should be rotated to reach the orientation that the program considers correct. This value can be placed in the RecRotateImg function to explicitly perform the image rotation.

See Also

HIG_REC_IMAGE