質問

I want to make a program that tracks the position of a pen with a led, moves the mouse and clicks. To do it, I'm using a rgb led and opencv with c++. However, for any of the 3 colors I just get hsv 87,9,255. How do I distinguish them?

役に立ちましたか?

解決

It is better to convert hsv colour space if you are doing colour based segmentation, as it doesn’t affect the brightness and light variation,

You could use the color range like

    cvtColor(src, hsv, CV_BGR2HSV);
    inRange(hsv,Scalar(0,50,40), Scalar(10,255,255),thr1); //upper red range of hue cylinder
    inRange(hsv,Scalar(165,50,40), Scalar(179,255,255),thr2);// lower red range of hue cylinder
    thr1+=thr2; // Red pixels.

Also see the colour hsv-wheel here which will help you to get exact colour range in hsv for a particular colour

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top