Problem is Multiple Color Points Tracking [closed]

asked 2019-01-21 00:25:11 -0600

Hello, I'm running into a weird exception when I try to use the below method to track multiple color points of the same color:

Pseudo Code:

  1. Capture a Video Frame
  2. Convert frame from BGR to HSV colorspace
  3. Run Inrange to filter out all other colors and only get the one color I want (so far so good)

Now here is where things get dicey. I'm trying to use the Hough circles detector to figure out the center of these filters color dots. However, there is no Convert color from HSV to GRAY. So I do the following:

  1. Convert Inrange filtered Mat object from HSV back to BGR
  2. Convert the now BGR Mat object to Gray

At step 5 is where an exception gets thrown. How come I can straight convert a directly captured BGR Mat object but not one that has been filtered by InRange?

Any suggestions for better code to track the position of same colored dots?

Thanks,

Han

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-13 14:03:59.214123

Comments

At step 5 is where an exception gets thrown.

how can we know,without seing your code ? (also, an image would be helpful)

no Convert color from HSV to GRAY.

you could split() the V channel from HSV, it's a "good enough" grayscale image already.

use the Hough circles detector to figure out the center

maybe it's easier to use connectedComponentsWithStats() on the mask you get from inRange(). this will already give you boundingBoxes for the blobs

berak gravatar imageberak ( 2019-01-21 01:06:41 -0600 )edit