cvcvtcolor,如何将cvCvtColor转换为cvtColor调用在opencv(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);

where frame and imgHSV are IplImage* objects

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?

解决方案

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();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值