gamal
gamal

Reputation: 1665

opencv cvLine method does not working

I want to print a line on camera captured frame, 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 putText method it works flawlessly.

Upvotes: 4

Views: 2194

Answers (1)

karlphillip
karlphillip

Reputation: 93410

cvLine() is a function from OpenCV's C API (now deprecated), but it's meant to work only with the IplImage data type.

cv::Mat on the other hand is from OpenCV's C++ API, as well as cv::line(), which is the appropriate C++ alternative to draw a line:

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

Upvotes: 4

Related Questions