I will need to identify, rotate and crop a rectangle(business card) from a photo took from an iphone. I believe this can be done by using OpenCV, but I have not used it before. Could anyone give some tips on this?
From iOS 8, you can now use the new detector CIDetectorTypeRectangle that returns CIRectangleFeature. You can add options :
Aspect ratio : 1.0 if you want to find only squares for example
CIImage *image = // your image
NSDictionary *options = @{CIDetectorAccuracy: CIDetectorAccuracyHigh, CIDetectorAspectRatio: @(1.0)};
CIDetector *rectangleDetector = [CIDetector detectorOfType:CIDetectorTypeRectangle context:nil options:options];
NSArray *rectangleFeatures = [rectangleDetector featuresInImage:image];
for (CIRectangleFeature *rectangleFeature in rectangleFeatures) {
CGPoint topLeft = rectangleFeature.topLeft;
CGPoint topRight = rectangleFeature.topRight;
CGPoint bottomLeft = rectangleFeature.bottomLeft;
CGPoint bottomRight = rectangleFeature.bottomRight;
}
More information in WWDC 2014 Advances in Core Image, Session 514.