hi all,
I have a form including a button and a picture box to display the webcam. When i press the button, the picture box will start to display the image.
This is the code of the button:
private: System::Void btnCapture_Click(System::Object^ sender,
System::EventArgs^ e) {
CvCapture * pCapture = cvCaptureFromCAM(0);
IplImage *image = 0;
cvNamedWindow ("Demo",CV_WINDOW_AUTOSIZE);
while (1)
{
image = cvQueryFrame (pCapture);
showImage (image, pictureBox1);
if (cvWaitKey (1) == 27) break;
}
cvReleaseCapture (&pCapture);
cvDestroyWindow ("Demo");
}
And this is showImage function:
private: System::Void showImage(IplImage *img,
System::Windows::Forms::PictureBox^ picturebox){
IntPtr ip(new unsigned
char[img->widthStep*img->height]);
memcpy(ip.ToPointer(),img->imageData,img->widthStep*img->height);
picturebox->Image = gcnew Bitmap(img->width,
img->height, img->widthStep,
System::Drawing::Imaging::PixelFormat::Format24bppRgb, ip);
}
but there is an error when compile
Inline native assembly not supported in managed code
c:\opencv\build\include\opencv2/core/types_c.h(289): error C3862: 'cvRound': cannot compile an unmanaged function with /clr:pure or /clr:safe
1> Inline native assembly not supported in managed code
1>c:\opencv\build\include\opencv2/core/types_c.h(289): error C3645: 'cvRound' : __clrcall cannot be used on functions compiled to native code
1>c:\opencv\build\include\opencv2/core/mat.hpp(115): error C3861: '_InterlockedExchangeAdd': identifier not found
1>c:\opencv\build\include\opencv2/core/mat.hpp(305): error C3861: '_InterlockedExchangeAdd': identifier not found
1>c:\opencv\build\include\opencv2/core/mat.hpp(377): error C3861: '_InterlockedExchangeAdd': identifier not found
1>c:\opencv\build\include\opencv2/core/mat.hpp(381): error C3861: '_InterlockedExchangeAdd': identifier not found
1>c:\opencv\build\include\opencv2/core/mat.hpp(2064): error C3861: '_InterlockedExchangeAdd': identifier not found
1>c:\opencv\build\include\opencv2/core/mat.hpp(2092): error C3861: '_InterlockedExchangeAdd': identifier not found
1>c:\opencv\build\include\opencv2/core/mat.hpp(2096): error C3861: '_InterlockedExchangeAdd': identifier not found
1>c:\opencv\build\include\opencv2/flann/flann.hpp(233): warning C4996: 'cv::flann::Index_<t>': was declared deprecated
1> c:\opencv\build\include\opencv2/flann/flann.hpp(278) : see reference to class template instantiation 'cv::flann::Index_<t>' being compiled
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\emmintrin.h(27): fatal error C1189: #error : ERROR: EMM intrinsics not supported in the pure mode!