ManualPerspectiveCorrectionCommand Class
Summary
Corrects the view perspective of the RasterImage.
Syntax
C#
VB
Objective-C
C++
Java
public class ManualPerspectiveCorrectionCommand : RasterCommand, IDestDataCommand
Public Class ManualPerspectiveCorrectionCommand
Inherits RasterCommand
@interface LTKernelManualPerspectiveCorrectionCommand : LTRasterCommand
public class ManualPerspectiveCorrectionCommand extends RasterCommand
public ref class ManualPerspectiveCorrectionCommand : public RasterCommand
Example
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Kernel;
public void ManualPerspectiveCorrectionCommandExample()
{
using (RasterCodecs codecs = new RasterCodecs())
{
// Load an image
using (RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "PerspectiveDeskew.jpg")))
{
//Prepare the command
ManualPerspectiveCorrectionCommand command = new ManualPerspectiveCorrectionCommand();
//The four corners of the polygon (Can be retrieved using DetectDocumentCommand)
command.InputPoints[0] = new LeadPoint(131, 193);
command.InputPoints[1] = new LeadPoint(456, 151);
command.InputPoints[2] = new LeadPoint(535, 282);
command.InputPoints[3] = new LeadPoint(124, 354);
// Set mapping points
command.MappingPoints[0] = new LeadPoint(0, 0);
command.MappingPoints[1] = new LeadPoint(610, 0);
command.MappingPoints[2] = new LeadPoint(610, 421);
command.MappingPoints[3] = new LeadPoint(0, 421);
// Run the command and save the result
command.Run(image);
codecs.Save(command.DestinationImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.bmp"), RasterImageFormat.Bmp, 24);
command.DestinationImage.Dispose();
}
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing.Kernel
Public Sub ManualPerspectiveCorrectionCommandExample()
Using codecs As RasterCodecs = New RasterCodecs()
Using image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "PerspectiveDeskew.jpg"))
' Prepare the command
Dim command As ManualPerspectiveCorrectionCommand = New ManualPerspectiveCorrectionCommand()
' The four corners of the polygon (Can be retrieved using DetectDocumentCommand)
command.InputPoints(0) = New LeadPoint(131, 193)
command.InputPoints(1) = New LeadPoint(456, 151)
command.InputPoints(2) = New LeadPoint(535, 282)
command.InputPoints(3) = New LeadPoint(124, 354)
' Set mapping points
command.MappingPoints(0) = New LeadPoint(0, 0)
command.MappingPoints(1) = New LeadPoint(610, 0)
command.MappingPoints(2) = New LeadPoint(610, 421)
command.MappingPoints(3) = New LeadPoint(0, 421)
' Run the command And save the result
command.Run(image)
codecs.Save(command.DestinationImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.bmp"), RasterImageFormat.Bmp, 24)
command.DestinationImage.Dispose()
End Using
End Using
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class