TIEVisionFeaturesDetector
TIEVisionFeaturesDetector
Declaration
TIEVisionFeaturesDetector = interface(TIEVisionBase)
Description
An interface for keypoint detection and matching between two images, using ORB, SIFT, AKAZE, KAZE or BRISK (see
TIEVisionFeatureAlgorithm).
The matching points can be used to align one image to another, e.g. with
findHomography and
warpPerspective.
Create it with
createFeaturesDetector.
Which algorithm works best depends on the images, so try another if alignment fails or is inaccurate. In tests aligning the three image pairs of the ImageAlignment demo with
maxFeatures = 2000:
◼All five algorithms aligned all three pairs accurately
◼ORB took about 60 ms, SIFT 300 ms, BRISK 400 ms, AKAZE 550 ms and KAZE 1400 ms
With
maxFeatures = 500, ORB was less accurate on one pair and BRISK failed on one pair.
Note: Large images are reduced before detection to limit memory use (except with ORB). See
setMaxImageSize.
Note:
◼A shortcut method for this is available:
DetectAndDeskew
◼The legacy class TIEVisionLibrary.createORBFeaturesDetector returns the same interface using ORB (TIEVisionORBFeaturesDetector is an alias of TIEVisionFeaturesDetector)
Demos
| Demos\IEVision\ImageAlignment\ImageAlignment.dpr |
| Demos\ImageEditing\EveryMethod\EveryMethod.dpr |
Examples
var
bmp1, bmp2: TIEBitmap;
detector: TIEVisionFeaturesDetector;
hmat: TIEVisionMatrix;
imgres: TIEVisionImage;
begin
bmp1 := TIEBitmap.Create('scanned-form.jpg');
bmp2 := TIEBitmap.Create('form.jpg');
// detect matching points of the two images
detector := IEVisionLib().createFeaturesDetector( ievFeatureSIFT );
detector.detect( bmp1.GetIEVisionImage(), bmp2.GetIEVisionImage(), 2000 );
// optionally show matching graph (matching points links)
//ImageEnView2.IEBitmap.AssignIEVisionImage( detector.getMatchingGraph() );
// find homography matrix (hmat) from matching points
hmat := IEVisionLib().createMath().findHomography( detector.getPoints1(), detector.getPoints2(), ievRANSAC );
// adjust "scanned-form" to the same skew of "form" image
imgres := bmp1.GetIEVisionImage().warpPerspective( hmat, IEVisionSize( bmp2.Width, bmp2.Height ));
// show final result
ImageEnView1.IEBitmap.AssignIEVisionImage( imgres );
bmp2.Free();
bmp1.Free();
end;
// Find matching keypoints between the image and a rotated (15 deg.) and scaled (80%) copy
detector := IEVisionLib().createFeaturesDetector( ievFeatureSIFT );
detector.detect( ImageEnView1.IEBitmap.GetIEVisionImage(), ImageEnView2.IEBitmap.GetIEVisionImage(), 2000 );
ImageEnView1.IEBitmap.AssignIEVisionImage( detector.getMatchingGraph() );
ImageEnView1.Update(); // Show changes in our viewer
Methods and Properties
See Also
◼createFeaturesDetector
◼findHomography
◼isValidHomography
◼warpPerspective