[ros-users] OpenCV cv::Mat to CvMat

Phil Osteen prosteen at ufl.edu
Wed Jul 21 22:22:14 UTC 2010


Hi I have written a ROS node that implements a camera calibration 
given intrinsic parameters and a chessboard pattern.

I want to use FindExtrinsicCameraParams2, and it would be nice to 
have a templated cv:: function for it, but I cannot find one 
anywhere in my environment. Is the ROS version of OpenCV missing 
any C++ functionality versus OpenCV2.1?

So, I resorted to trying to convert the cv::Mat objects I have to 
CvMat objects using the simple operator. I assume, since there is 
no data copying, that the matrix header is the only change made. I 
also assume that I can use the cvFindExtrinsicCameraParams2 
function with my newly-created CvMat objects.

I run into an error, however, since I cannot directly copy-paste 
my code so here's a quick rundown.

// I have a populated STL vector of Mats
vector<Mat> distortion_coeffs;
//I create cv::Mats
Mat distortion(rows,cols,CV_64FC3);
//Then, populate all of them except tvec,rvec
distortion_coeffs[0].copyTo(distortion);
//Then copy to the old CvMat struct
CvMat distortion_old = distortion;

// Then call cvFindExtrinsicCameraParams2

OpenCV Error: Incorrect size of input array (Either the number of 
channels or columns or rows must be =1) in 
cvConvertPointsHomogeneous, file 
/opt/ros/boxturtle/stacks/vision_opencv/opencv2/build/opencv-svn/src/cv/cvfundam.cpp


I am running boxturtle on Ubuntu Karmic 2.6.31-14. Thanks for any 
help.

--
Phil Osteen
BS Aerospace Engineering, University of Florida
MS Mechanical Engineering, University of Florida
Research Assistant, Center for Intelligent Machines and Robotics 
(UF)
Researcher, Grupo de Sistemas y Automatica, Universidad de 
Sevilla
Robotics Research Engineer, Motile Robotics Inc




More information about the ros-users mailing list