Trying to detect blue color from image using opencv, and getting unexpected result

后端 未结 2 645
星月不相逢
星月不相逢 2020-12-10 22:31

I am new to OpenCV4Android. Here is some code I wrote to detect blue colored blob in an image. Among the following images, image 1 was in my laptop. I run the application an

2条回答
  •  执笔经年
    2020-12-10 23:06

    Probably the range you are using is wrong for blue, In OpenCV the hue range is from 0-180 and you have given it's 170-270. Find the correct hue value for blue and use in inRange.

    1. http://answers.opencv.org/question/30547/need-to-know-the-hsv-value/#30564
    2. http://answers.opencv.org/question/28899/correct-hsv-inrange-values-for-red-objects/#28901

    You can refer the answer here for choosing correct hsv value.

    Below is the code for segmenting red color, check it with your code, and make sure it segmenting red object.

        Imgproc.cvtColor(rgbaFrame, hsv, Imgproc.COLOR_RGB2HSV,4); // Convert to hsv for color segmentation.      
        Core.inRange(hsv,new Scalar(0,50,40,0), new Scalar(10,255,255,0),thr);//upper red range of hue cylinder 
    

提交回复
热议问题