How to convert CLEyeCameraGetFrame to Image<Bgr, Byte> in opencv (C#)
Posted: 02 April 2017 11:10 PM   [ Ignore ]
New Member
Rank
Total Posts:  2
Joined  2017-03-02

Hi All,

I am facing problems to convert the image query from CLEyeCameraGetFrame API to the Image<Bgr, Byte> format used in emgucv which is a c# wrapper for opencv.

This is the line in the opencv:
Image<Bgr, Byte> currentFrame = camera_object.queryFrame();

where the queryframe is by the capture class from opencv.

For now i want to use the CLEyeCameraGetFrame API to substitute the opencv query frame….

Basically what I want to do is to get the image from my ps3eye and used the image in emgucv…..

I tried with the original capture class from opencv which it only able to capture from one ps3 eye. I need to make it work for 2 ps3eye and it looks ike the only way to do so is to use the CLEye sdk api.

Can anyone please help ? Thanks….

Profile
 
 
Posted: 03 April 2017 10:05 PM   [ Ignore ]   [ # 1 ]
New Member
Rank
Total Posts:  2
Joined  2017-03-02

Manage to get this done !

First initialize the camera:
  Guid CLEye1UUID = CLEyeCameraDevice.CLEyeGetCameraUUID(0);

  framePtr = CLEyeCameraDevice.CLEyeCreateCamera(CLEye1UUID, CLEyeCameraColorMode.CLEYE_COLOR_RAW, CLEyeCameraResolution.CLEYE_VGA, 60);

  CLEyeCameraDevice.CLEyeCameraGetFrameDimensions(framePtr, ref texW, ref texH);
  CLEyeCameraDevice.CLEyeCameraStart(framePtr);
  _ptrBmpPixels = Marshal.AllocHGlobal(1280 * 960);


Next:
CLEyeCameraDevice.CLEyeCameraGetFrame(framePtr, _ptrBmpPixels, 500); // get the frame
int bitsPerPixel = ((int)System.Drawing.Imaging.PixelFormat.Format32bppRgb & 0xff00) >> 8;
int bytesPerPixel = (bitsPerPixel + 7) / 8;
int stride = 4 * ((640 * bytesPerPixel + 3) / 4);
Bitmap frame1 = new Bitmap(640, 480, stride, System.Drawing.Imaging.PixelFormat.Format32bppRgb, _ptrBmpPixels);

Image<Bgr, Byte> currentFrame = new Image<Bgr, Byte>(frame1);


So the Intptr is converted to bitmap then convert to Image.

Profile
 
 
 
 


RSS 2.0     Atom Feed