OpenCV: convert Scalar to different color space

前端 未结 4 1562
刺人心
刺人心 2021-01-17 21:28

I am using a Scalar to define the color of a rectangle I am drawing with OpenCV:

rectangle(imgOriginal, Point(0, 0), Point(25, 50),         


        
4条回答
  •  有刺的猬
    2021-01-17 22:15

    Use this to convert a single value:

    cv::Vec3f rgb;
    cv::Vec3f hsv;
    hsv[0] = H;
    hsv[1] = S;
    hsv[2] = V;
    cvtColor(hsv, rgb, CV_HSV2BGR);
    

    Then you can use it:

    rectangle(imgOriginal, Point(0, 0), Point(25, 50), 
        Scalar(rgb[0], rgb[1], rgb[2]), CV_FILLED);
    

提交回复
热议问题