Android Question how to detect color use OpenCV by camera ? and color always change

hears

Active Member
Licensed User
Longtime User

JordiCP

Expert
Licensed User
Longtime User
It depends on what you want to do...

OpenCV can help you if, for instance, you need to detect several points, or detect objects with a given or similar color, etc... and build some real-time logic on top of it. One of the attached examples (BlobDetector4) does it. Code built with OpenCV can be quite simple or really complex, depending on the problem to solve.


On the other hand, if you just need to detect the camera preview color of just one point (for instance, the center of the screen), the fastest approach is to get the value directly from the preview data event, and then do some calculations:
  • First, calculate which bytes of the preview data array correspond to the exact point that you want to measure.
  • Second conversion is related to the data format: camera preview comes in YUV format, should be converted to RGB.
Besides, as detected color can change a bit over time, a good approach is to calculate a mean of the values received during N consecutive frames.
 
Upvote 0

hears

Active Member
Licensed User
Longtime User
It depends on what you want to do...

OpenCV can help you if, for instance, you need to detect several points, or detect objects with a given or similar color, etc... and build some real-time logic on top of it. One of the attached examples (BlobDetector4) does it. Code built with OpenCV can be quite simple or really complex, depending on the problem to solve.


On the other hand, if you just need to detect the camera preview color of just one point (for instance, the center of the screen), the fastest approach is to get the value directly from the preview data event, and then do some calculations:
  • First, calculate which bytes of the preview data array correspond to the exact point that you want to measure.
  • Second conversion is related to the data format: camera preview comes in YUV format, should be converted to RGB.
Besides, as detected color can change a bit over time, a good approach is to calculate a mean of the values received during N consecutive frames.
very thank you for reply,this is a big help for my project
 
Upvote 0
Top