如何将cvCvtColor转换为cvtColor调用在opencv(BGR到HSV)? [英] How to convert a cvCvtColor to cvtColor call in opencv (BGR to HSV)?
问题描述
我使用的是旧版本的opencv的C ++代码,用于将BGR转换为HSV -
I am using a C++ code with old version of opencv that uses this to convert BGR to HSV -
cvCvtColor(frame, imgHSV, CV_BGR2HSV);
cvReleaseImage(&imgHSV);
其中frame和imgHSV是IplImage * objects
where frame and imgHSV are IplImage* objects
较新版本的opencv没有这个方法,我发现在imgproc中的cvtColor()也是一样。但是这个方法对参数使用cv :: InputArray和cv :: OutputAray格式,而不是IplImage *。如何转换并将IplImage *格式转换回这些新格式?
The newer versions of opencv don't have this method and I found cvtColor() in imgproc that does the same. But this method uses cv::InputArray and cv::OutputAray formats for parameters instead of IplImage* . How do I convert and convert back the IplImage* formats to these new formats? Any other way to convert from BGR to HSV for IplImage* that I don't know of?
推荐答案
使用cv :: Mat而不是IplImage这里,一般来说,喜欢c ++ api到已过时的c-api:
use cv::Mat instead of IplImage here, in general, prefer the c++ api to the deprecated c-api:
cv::Mat img = cv::imread("my.png");
cv::Mat hsv;
cv::cvtColor(frame, hsv, CV_BGR2HSV);
cv::imshow("hsv",hsv);
cv::waitKey();
这篇关于如何将cvCvtColor转换为cvtColor调用在opencv(BGR到HSV)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!