4

How to create custom RectangleDetector like FaceDetector and BarcodeDetector in Mobile vision API? I need to detect rectangle shapes from camera frame. How can i achieve that?

karthi
  • 125
  • 2
  • 8
  • did you manage to implement? Care to share any details on how it was done? I've been looking at opencv to achieve it, but it's a big library and would rather keep things lean. IOS has rectangle detection built in - would be great if android did the same. – Avner Mar 17 '17 at 04:12

2 Answers2

3

You'd extend the Detector class:

https://developers.google.com/android/reference/com/google/android/gms/vision/Detector

Defining your RectangleDetector class. The code to detect rectangles would be implemented by overriding the detect() method. You'd need to implement this yourself, since there isn't already code for detecting rectangles in mobile vision.

When you have this, you'd be able to use it with CameraSource and other parts of the mobile vision API.

pm0733464
  • 2,862
  • 14
  • 16
0

As pm0733464 mentioned you can extend the Detector and use an Image processing library such as Catalano Framework GITHUB or CODEPROJECT. for each frame,

  • convert frame to Bitmap
  • using the framework convert the Bitmap to FastBitmap
  • Gray-scale, then threshold it
  • start a blob search
  • check the blobs for Rectangular shapes with certain sizes

It can find Rectangles even when they are scaled or skewed, extract the blob with four angles and stretch it for farther processing. You can make any type of detector and am working on a custom object detector ATM.