I have a color that I want to convert to a different color space. Is it possible to use cvtColor on a cv::Vec3f directly without creating a 1x1
Your second approach is correct, but you have source and destination of different types in cvtColor, and that causes the error.
Be sure to have both hsv and bgr of the same type, CV_32F here:
#include
#include
int main()
{
cv::Mat3f hsv(cv::Vec3f(0.7, 0.7, 0.8));
std::cout << "HSV: " << hsv << std::endl;
cv::Mat3f bgr;
cvtColor(hsv, bgr, CV_HSV2BGR);
std::cout << "BGR: " << bgr << std::endl;
return 0;
}
You can use Mat3f for brevity. It's just a typedef:
typedef Mat_ Mat3f;