OpenCV: convert Scalar to different color space

前端 未结 4 1573
刺人心
刺人心 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 21:55

    Although not optimal, You can use the following:

    Scalar ScalarHSV2BGR(uchar H, uchar S, uchar V) {
        Mat rgb;
        Mat hsv(1,1, CV_8UC3, Scalar(H,S,V));
        cvtColor(hsv, rgb, CV_HSV2BGR);
        return Scalar(rgb.data[0], rgb.data[1], rgb.data[2]);
    }
    

提交回复
热议问题