Reputation: 13
I'm just trying to learn about OpenCV and i running on a x64 machine.
I am using OpenCV 3.2.0 with VS2015 before and I try to following step by step tutorial from Kyle Hounslow on youtube, but i get error.
then i reinstall using VS2013, but i still got error like below :
Error 1 error C2664: 'void cvShowImage(const char *,const CvArr *)' : cannot convert argument 2 from 'cv::Mat' to 'const CvArr *' Error 2 IntelliSense: no suitable conversion function from "cv::Mat" to "const CvArr *" exists
i already see in link below but still doesn't work for me
i check on link below too, but i got confused
my code is like below :
#include<iostream> #include<opencv\cv.h> #include<opencv2\highgui\highgui.hpp> #include<opencv2\videoio.hpp> #include<opencv2\core.hpp> #include<opencv2\imgproc\imgproc.hpp> using namespace cv; int main() { Mat image; VideoCapture cap; cap.open(0); cvNamedWindow("window", 1); while (true) { cap >> image; cvShowImage("window", image); cvWaitKey(33); } }
please help me in that, many thanks.
sorry, i delete the update because the original issue is already solved
many thanks
Upvotes: 1
Views: 2712
Reputation: 6310
You are mixing old, obsolete C api (cvNamedWindow
, cvShowImage
, cvWaitKey
) with new C++ api (Mat
, VideoCapture
). Don't do that. Drop the C api altogether. Everything named like cvFunctionName is obsolete. Use newer api that uses cv
as a namespace, so names like cv::functionName are what you're supposed to be calling.
In your case it's cv::namedWindow
, cv::imshow
and cv::waitKey
:
using namespace cv;
int main()
{
Mat image;
VideoCapture cap;
cap.open(0);
namedWindow("window", 1);
while (true)
{
cap >> image;
imshow("window", image);
waitKey(33);
}
}
Upvotes: 1
Reputation: 167
You should use imshow("window", image);
if you need to use c++ Mat.
according to opencv docs
Displays an image in the specified window.
C++: void imshow(const string& winname, InputArray mat)
C: void cvShowImage(const char* name, const CvArr* image)
Upvotes: 1