Search code examples
iosswiftrectangles

Automatically take a picture to proceed on back thread when rectangle detected? iOS, Swift


I am working on a project at the moment and wanted to find out what I need to be looking at to automatically take a picture when a rectangle is detected. I have seen this in action on an app called car spotter but wanted to know how it could be done. On car spotter it detects the rectangle and blurs the number plate automatically.


Solution

  • You can use AVCaptureSession to capture pictures from camera, and use CIDetector to detect rectangle. They are all system APIs, doesn't need OpenCV which costs extra storage space.

    And there is an implementation example on Github: https://github.com/charlymr/IRLDocumentScanner

    And the key procedures are in this class: https://github.com/charlymr/IRLDocumentScanner/blob/master/Source/Private/IRLCameraView.m