I have to convert a component color from HSV
to RGB
and viceversa in OpenCV.
For example if I have the vector hsvcomponent = { 30, 80, 100 }
I want the same color in RGB
How can I do this in OpenCV? I know that opencv has the cvtColor
with CV_BGR2HSV
but this function works with images. I want something simpler.
What can I do?
I found a simple solution to my problem:
cv::Vec3b ConvertColor( cv::Vec3b src, int code, int dstCn )
{
cv::Mat srcMat(1, 1, CV_8UC3 );
*srcMat.ptr< cv::Vec3b >( 0 ) = src;
cv::Mat resMat;
cv::cvtColor( srcMat, resMat, code, dstCn );
return *resMat.ptr< cv::Vec3b >( 0 );
}