Ask Your Question
1

cvCvtColor - cannot convert 'cv::Mat' to 'const CvArr*'

asked 2013-03-04 10:48:00 -0500

breich90 gravatar image

Hi,

I am encountering problems when I try to use cvCvtColor. I am using OpenCV functions in ROS after using the ROS opencv_bridge package to translate from ROS published images to an OpenCV Mat. I get the following compilation error:

'cannot convert 'cv::Mat' to 'const CvArr* {aka const void}' for argument '1' to 'void cvCvtColor(const CvArr, CvArr*, int)'

I need to use cvCvtColor to translate to HSV colorspace in order to threshold white from the converted image. My understanding of CvArr* is that it is a catch-all for multiple types of inputs, including a cv::Mat.

// cv_ptr is the image converted from ROS; ->image points to the associated cv::Mat

cv::Mat* rosImg = &cv_ptr->image;

cv::Mat A = *rosImg;

// Create an empty CVImage that we can designate as the HSV copy.

IplImage* imgHSV = cvCreateImage(cvSize(1024,768), 8, 3);

// Convert the color of the ROS image from RGB into HSV.

cvCvtColor(A, imgHSV, CV_BGR2HSV);

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-03-04 11:01:19 -0500

berak gravatar image

use cv::cvtColor for cv::Mats, cvCvtColor for CvMat* .

the old(1.0) api was using IplImage*, CvMat* and functions starting with cv,

the new(2.+) api is using cv::Mat, and functions from the cv:: namespace.

(better stick to the new api, i'd say!)

also, try to avoid pointers to cv::Mat, you'll wreck havoc on the internal refcounts there !

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-03-04 10:48:00 -0500

Seen: 12,688 times

Last updated: Mar 04 '13