#include "ltimgkrn.h"
L_LTIMGKRN_API L_INT L_ImgKrnManualPerspectiveCorrection(srcBitmap, data, destBitmap, structSize)
Corrects the view perspective of the image.
Pointer to the source bitmap handle referencing the bitmap to be transformed.
Pointer to L_ImgKrnPerspectiveCorrectionData structure that contains a list of points that will be transformed to match the location of the mapped points list.
Pointer to the handle of the transformed destination bitmap.
Size, in bytes, of the structure pointed to by destBitmap.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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.
Call L_ImgKrnDetectDocument to detect the points at the document corners.
Use the results from L_ImgKrnDetectDocument as the input points for the L_ImgKrnPerspectiveCorrectionData structure, which is used by the L_ImgKrnManualPerspectiveCorrection function to correct the perspective of a captured image.
Note: All functions with the L_ImgKrn prefix modify the underlying properties of the input BITMAPHANDLE, including but not limited to:
To avoid BITMAPHANDLE property fidelity loss, pass a copy of your BITMAPHANDLE to all L_ImgKrn* functions.
Required DLLs and Libraries
Win32, x64, Linux.
This example loads a bitmap and applies the 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 Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document