I want to implement a business card detection feature such as this application ( https://scanbot.io ). The camera should detect a business card and automatically take a picture (business card only).

My idea was to use the BradLarson GPUImage library, determine the angles (using the Harris angle detection algorithm), calculate the largest rectangle with the obtained angles, and crop the image contained inside the rectangle.
Here is my code:
- (void)setupFilter { videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack]; filter = [[GPUImageHarrisCornerDetectionFilter alloc] init]; [(GPUImageHarrisCornerDetectionFilter *)filter setThreshold:0.01f]; [(GPUImageHarrisCornerDetectionFilter *)filter setSensitivity:0.5f]; [(GPUImageHarrisCornerDetectionFilter *)filter setBlurRadiusInPixels:2.0f]; [videoCamera addTarget:filter]; videoCamera.runBenchmark = YES; GPUImageView *filterview = [[GPUImageView alloc] init]; self.view=filterview; GPUImageCrosshairGenerator *crosshairGenerator = [[GPUImageCrosshairGenerator alloc] init]; crosshairGenerator.crosshairWidth = 22.0; [crosshairGenerator forceProcessingAtSize:CGSizeMake(480.0, 640.0)]; [(GPUImageHarrisCornerDetectionFilter *)filter setCornersDetectedBlock:^(GLfloat* cornerArray, NSUInteger cornersDetected, CMTime frameTime) { [crosshairGenerator renderCrosshairsFromArray:cornerArray count:cornersDetected frameTime:frameTime]; }]; GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init]; [blendFilter forceProcessingAtSize:CGSizeMake(480.0, 640.0)]; GPUImageGammaFilter *gammaFilter = [[GPUImageGammaFilter alloc] init]; [videoCamera addTarget:gammaFilter]; [gammaFilter addTarget:blendFilter]; [crosshairGenerator addTarget:blendFilter]; [blendFilter addTarget:filterview]; [videoCamera startCameraCapture]; }
The problem is that I donβt know how to set the threshold and sensibility attribute property to get angles (now I get angles for all objects in the image).
I also don't know how to work with this GLfloat* cornerArray .
I donβt know if I am right ... any other ideas on how to implement this functionality or is there an existing library?
Thanks!
source share