问题
I have images that I need to crop and have multiple X,Y co-ordinates to cut out the business card or paper. What would be the best way to do it.
My Co Ordinates is the following. X: 490, y: 0 X: 1442, y: 0 X: 1442, y: 4031 X: 490, y: 4031
回答1:
You could check out the KeyStoneCommand from the Leadtools Image Processing Nuget
This Nuget package also includes a detect document ip command that you can use if you don't know the bounding box of the business card that will detect and give you back the 4 points of the card.
Here is a code snippet:
private RasterImage DetectAndDeskew(RasterImage image)
{
DetectDocumentCommand detectDocumentCommand = new DetectDocumentCommand();
detectDocumentCommand.Run(image);
if (detectDocumentCommand.DocumentArea == null)
{
Console.WriteLine("No document detected");
return null;
}
KeyStoneCommand command = new KeyStoneCommand(detectDocumentCommand.DocumentArea);
command.Run(image);
image = command.TransformedImage;
return image;
}
Here is the output image from this process:
Disclaimer: I am an employed by the maker of this nuget
来源:https://stackoverflow.com/questions/60828712/crop-image-with-multiple-x-and-y-points-c-sharp