Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find a rectangle in a photo using iphone?

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?

like image 617
TiansHUo Avatar asked May 26 '11 05:05

TiansHUo


People also ask

How do I identify objects in photos on iPhone?

If you see the Visual Look Up icon, tap it or swipe up. An icon will appear on the photo. Note that the icon varies depending on the image it detects. For example, a pin icon will appear for landmarks and a paw print icon for animals.

Does iPhone have object eraser?

Erase a mistake Tap the eraser tool in the Markup toolbar in a supported app, then do one of the following: Erase with the pixel eraser: Scrub over the mistake with your finger. Erase with the object eraser: Touch the object with your finger.

What is that square thing on iPhone photo?

Square. Square mode limits the frame of your camera screen to a square — the optimal photo size for many social media apps. So when you take a photo, you can quickly share it on your favorite social platforms.


1 Answers

From iOS 8, you can now use the new detector CIDetectorTypeRectangle that returns CIRectangleFeature. You can add options :

  • Accuracy : low/hight
  • 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.

An example from shinobicontrols.com

like image 82
Ded77 Avatar answered Sep 30 '22 09:09

Ded77