I'm working with OPENCVSHARP (OpenCV) to access a Ps3Eye camera in C #.
But I'm having a serious protected memory problem! I use visual studio 2010 in Windows7.
Code:
IntPtr_ptr;publicIntPtr_ptrBmpPixels;staticIntPtr_camera;staticintw=0,h=0;publicvoidbutton2_Click(objectsender,EventArgse){_camera=CLEyeCreateCamera(CameraUUID(0),CLEyeCameraColorMode.CLEYE_COLOR_RAW,CLEyeCameraResolution.CLEYE_VGA,75);CLEyeCameraGetFrameDimensions(_camera,refw,refh);CLEyeCameraStart(_camera);_ptrBmpPixels=Marshal.AllocHGlobal(w*h*4);RtlZeroMemory(_ptrBmpPixels,w*h*4);BitmapbmpGraph=newBitmap(w,h,w*4,PixelFormat.Format32bppRgb,_ptrBmpPixels);pictureBox2.Image=bmpGraph;myTimer2.Enabled=true;}publicvoidtimer2(objectsender,EventArgse){CvInvoke.cvQueryFrame(_camera);//AQUIESTÁOERROaoACESSARO"_camera"
CLEyeCameraGetFrame( _camera,_ptrBmpPixels,500);
pictureBox2.Invalidate();
//IntPtr img = CvInvoke.cvQueryFrame(_ptrBmpPixels);
//IplImage iplImage = (IplImage)Marshal.PtrToStructure(img, typeof(IplImage));
Bitmap bmpGraph = new Bitmap (160, 480, 640, PixelFormat.Format32bppRgb, _ptrBmpPixels);
IplImage mp = Cv.CreateImage(Cv.Size(bmpGraph.Width, bmpGraph.Height), BitDepth.U8, 3);
//learn(mp, bmpGraph);
}