Opencv cvLine method not working

I want to print a line on a frame captured by the camera, but when I tried this snippet code it throws

cv::Mat cameraFrame
main method Mat
Error: no suitable conversion function for "cv::Mat" to "CvArr" exists

      

cvLine( cameraFrame, 
cvPoint(30, 30),
cvPoint(90, 90),
Scalar(255,255,255), 1, 8, CV_AA); 

      

but at the same time I used a method putText

that works flawlessly.

+3


source to share


1 answer


cvLine()

is a function from the OpenCV API API (now deprecated), but it is designed to work only with the data type IplImage

.

cv::Mat

, on the other hand, from the OpenCV C ++ API as well cv::line()

, which is a suitable C ++ alternative for line drawing:



cv::line(cameraFrame,
         cv::Point2i(30, 30), 
         cv::Point2i(90, 90), 
         cv::Scalar(255, 255, 255), 1, 8, CV_AA);

      

+2


source







All Articles