Search code examples
opencvhsvcolor-spaceandroid

In an app using OpenCV4Android, how to find out if the camera is taking 8-bit image or 32-bit image?


In OpenCV HSV images, the scale of Hue depends on the type of image. From this answer,

For HSV images it depends on the image type (see OpenCV doc):

8 bit images: H in [0, 180], S,V in [0, 255]

32bit images: H in [0, 360] ,S,V in [0,1]

I have two questions:

  1. How do I know which type of image or frame (whether 8-bit or 32-bit) is the camera detecting, e.g. how would I know in this class in the Color Blob Detection sample application?

  2. Is there a way to force the camera to take 32 bit image (because I really want the second scale, and if there is no way, I will have to find a way to convert the first scale to the second one, because Android's Color.HSVToColor method follows the second scale)?


Solution

  • 1) It uses CvType.CV_8U so that means 8 bit unsigned.

    2) Probably not, you have to dive in the part of code that actually controls the camera and grabs a frame to find this out. However, you can simply convert a 8 bit image to 32 bit by using convertTo functions.