0

I am using the opencv library on an android app. From an image taken from the camera, I want to read a check box (I already have the location of the checkbox), and see if the check box has been filled. i.e. i want to know if the area within the check box has been filled in partially or completely with dark pixels.

I am using the jni interface so i am using the c++ language. I want to know how i can find the values of those pixels in the check box such that i will know that most the check box is filled with dark (black) pixels.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
  • When you say "I already have the location of the checkbox", does that mean you know the pixel coordinates of the centre/corner/etc and its (pixel) size? – mathematical.coffee Jan 23 '12 at 00:58
  • If you are trying to access pixel values, try [this SO](http://stackoverflow.com/questions/8963617/opencv-fastest-way-to-extract-individual-pixel-data). – Abid Rahman K Jan 23 '12 at 06:39
  • what if the checkbox a different color/representation for its states? like red dot for unchecked and green dot for checked? – STT LCU Jan 23 '12 at 08:29

1 Answers1

1

If you know what the complete form looks like, lets assume you have an image of it stored somewhere. We can then use feature points to detect another instance of that form as a planar object inside the camera image, as shown in the find_obj.cpp sample. The locatePlanarObject() function actually gives us a homography matrix, which we can use directly with cvWarpPerspective() to warp back the captured image to match with your stored image. Assuming you know where the check boxes are in the stored image, we can simply and directly compare the pixels values. Some sort of threshold on the amount of "dark" pixels should work IMO.

Oh, I think you want to know more about how to access pixel values. This has been covered in many places, e.g.: Pixel access in OpenCV 2.2

Community
  • 1
  • 1
Samuel Audet
  • 4,964
  • 1
  • 26
  • 33