0

I am working on tracking moving object using OpenCV, python. The code that I have right now works well for a hardcoded set of lower and upper bounds of HSV values.

blueLower = (100, 50, 50)
blueUpper = (150, 255, 255)

Now, I want to feed the lower and upper HSV values dynamically for the cropped section of an image (the image will be the first frame of a video). I am able to get the cropped section of image and its dominant RGB value.

Is it possible to get lower and upper range of HSV with a dynamic RGB value?

If not, how can I get the range of HSV with the help of the cropped image?

Note:- The cropped image will have the object to track, hence I will have majority of color that belongs to that object.

  • a little of topic: color detection is not reliable at all for object tracking – Moia Jun 01 '18 at 10:23
  • Thanks @Moia, I am completely aware of your concern. For the time being, it will be sufficient for the objective of this small program. – ɐʂʂɐ ʂʂɪȠo Jun 01 '18 at 10:31
  • I am not sure I get it. You want to find the HSV values of a cropped image from RGB of that image? Or is it something else? – Eypros Jun 01 '18 at 10:48
  • https://stackoverflow.com/questions/10948589/choosing-the-correct-upper-and-lower-hsv-boundaries-for-color-detection-withcv/48367205#48367205 – Kinght 金 Jun 01 '18 at 11:02
  • @Eypros, I already have RGB values, eg. (221,160,221) for the cropped image, now my question is, is it possible to get range of HSV for that particular RGB value? Or, if that is not possible, since I already have the cropped image, can I determine range of HSV for that image? Because the cropped image has majority of color that I want to track; and I can remove other noise if present. – ɐʂʂɐ ʂʂɪȠo Jun 01 '18 at 11:22
  • @ausk, partially, may be. What I wanted is, the cropped image I have, will have different color for different objects. I need to find the HSV boundaries for those different RGB values. – ɐʂʂɐ ʂʂɪȠo Jun 01 '18 at 11:28
  • @ɐʂʂɐʂʂɪȠo Make it clear in your title please, or it may be judged as duplicated. – Kinght 金 Jun 01 '18 at 11:30
  • So, what's stopping you from converting RGB to HSV and check the ranges for the various objects? – Eypros Jun 01 '18 at 12:17
  • @Eypros, the actual reason is, I don't know how. And I'm new to the python as well. I am just following the references available on the internet, and I'm stuck in this part. – ɐʂʂɐ ʂʂɪȠo Jun 01 '18 at 13:38
  • Something like https://docs.python.org/3/library/colorsys.html is not good enough? – Eypros Jun 01 '18 at 13:40
  • @Eypros, interesting, in this way I can get an HSV value for specific RGB. Additionally, how may I compute somehow accurate lower and upper range for that HSV? Is there any reliable method as such? – ɐʂʂɐ ʂʂɪȠo Jun 01 '18 at 15:39
  • What do you mean accurate? You just collect all images from object1 and get the max and min in each channel and continue with the next object etc – Eypros Jun 01 '18 at 20:29

0 Answers0