OpenCV's Canny Edge Detection in C++

后端 未结 1 969
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 04:10

I want to extract the edges of hand but I get the following result. I\'ve tried adjusting the low and high threshold but I still can\'t get the desired output. I have includ

相关标签:
1条回答
  • 2020-12-03 04:28

    Change this line

    cvtColor( image, gray_image, CV_RGB2GRAY );
    

    to

    std::vector<cv::Mat> channels;
    cv::Mat hsv;
    cv::cvtColor( image, hsv, CV_RGB2HSV );
    cv::split(hsv, channels);
    gray_image = channels[0];
    

    The problem seems to be that your hand in gray scale is very close to the gray background. I have applied Canny on the hue (color) because the skin color should be sufficiently different.

    Also, the Canny thresholds look a bit crazy. The accepted norm is that the higher one should be 2x to 3x the lower. 350 is a bit too much and it doesn't help solve the main problem.

    Edit

    with these thresholds I was able to extract quite a good contour

    cv::Canny(image,contours,35,90);

    Reading a bit of theory about the algorithm will help you understand what happens and what you should do to improve. wiki canny on google

    However, the improvement above will give you much better results (provided you use better thresholds than 10, 350. Try (40, 120) )

    0 讨论(0)
提交回复
热议问题