L_ImgKrnManualPerspectiveCorrection

#include "ltimgkrn.h"

L_LTIMGKRN_API L_INT L_ImgKrnManualPerspectiveCorrection(srcBitmap, data, destBitmap, structSize)

BITMAPHANDLE *srcBitmap; source bitmap handle
const L_ImgKrnPerspectiveCorrectionData *data; list of points to be transformed
BITMAPHANDLE *destBitmap; destination bitmap handle
L_UINT structSize; size of destination bitmap

Corrects the image view perspective.

Parameter Description
srcBitmap Pointer to the source bitmap handle referencing the bitmap to be transformed.
data Pointer to L_ImgKrnPerspectiveCorrectionData structure that contains a list of points that will be transformed to match the location of the mapped points list.
destBitmap Pointer to the destination transformed bitmap handle.
structSize Size in bytes, of the structure pointed to by dstBitmap.

Returns

SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

Typically, this function is used as a preprocessing step when taking images from digital cameras. It changes the image based on a view perspective equation.

It is best to choose input points that are far away from each other.

Use the L_ImgKrnDetectDocument to detect the document corners points as an Input for L_ImgKrnManualPerspectiveCorrection.

Required DLLs and Libraries

LTIMGKRN
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64, Linux.

See Also
Functions: L_ImgKrnCopyImage, L_ImgKrnCreateImage, L_ImgKrnCropImage, L_ImgKrnDetectDocument, L_ImgKrnDetectGlare, L_ImgKrnFromYUV, L_ImgKrnInvertImage, L_ImgKrnRotateFlipImage, L_ImgKrnSignalToNoiseRatio
Topics: Raster Image Functions: Doing Geometric Transformations

Example

This example loads a bitmap and applies manual perspective deskew filter.

L_INT KrnManualPerspectiveCorrectionExample(L_VOID) 
{ 
   L_INT ret; 
   BITMAPHANDLE bitmap;         /* Bitmap handle to hold the loaded image. */ 
   BITMAPHANDLE resultBitmap;   /* Bitmap handle to hold the result image. */ 
 
   /* Load the bitmap */ 
   ret = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("cannon.jpg")), &bitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if (ret != SUCCESS) 
      return ret; 
 
   L_INT Width = bitmap.Width; 
   L_INT Height = bitmap.Height; 
 
   /* Apply manual perspective deskew filter to move down the top right corner by half of the image height*/ 
   L_ImgKrnPerspectiveCorrectionData data; 
   data.InputPoints[0].x = 0; 
   data.InputPoints[0].y = 0; 
   data.InputPoints[1].x = Width - 1; 
   data.InputPoints[1].y = 0; 
   data.InputPoints[2].x = 0; 
   data.InputPoints[2].y = Height - 1; 
   data.InputPoints[3].x = Width - 1; 
   data.InputPoints[3].y = Height - 1; 
 
   data.MappingPoints[0].x = 0; 
   data.MappingPoints[0].y = 0; 
   data.MappingPoints[1].x = Width - 1; 
   data.MappingPoints[1].y = Height / 2; 
   data.MappingPoints[2].x = 0; 
   data.MappingPoints[2].y = Height - 1; 
   data.MappingPoints[3].x = Width - 1; 
   data.MappingPoints[3].y = Height - 1; 
 
   ret = L_ImgKrnManualPerspectiveCorrection(&bitmap, &data, &resultBitmap, sizeof(BITMAPHANDLE)); 
   if (ret != SUCCESS) 
   { 
      ret = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &resultBitmap, FILE_BMP, 24, 0, NULL); 
 
      L_FreeBitmap(&resultBitmap); 
   } 
 
   //free bitmap 
   L_FreeBitmap(&bitmap); 
 
   return ret; 
} 

Help Version 20.0.2018.1.19
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help