0

I have an IDS UEye webcam and want to make a snapshot via the uEyeDotNet.dll (version 1.6.4.2).

At the moment I'm using this piece of code.

var camera = new Camera();
camera.Init(_deskCamInfo.UEyeId);
camera.Memory.Allocate();
camera.Acquisition.Capture();

Thread.Sleep(500);

int s32MemID;
camera.Memory.GetActive(out s32MemID);

Bitmap image;
camera.Memory.ToBitmap(s32MemID, out image);
var converter = new ImageConverter();
var imageData = (byte[])converter.ConvertTo(image, typeof(byte[]));

When I use my code with the Thread.Sleep(500) I get the snapshot as expected and everything works fine. But if I remove the Thread.Sleep(500) I get a black image and I really don't know why.

But I don't want to wait 500ms for each snapshot and would like to solve this problem without it.

In my original code I check each result value from the uEye methods and I get always an success. Just removed this checks because it's hard to read with all the if statements.

Mighty Badaboom
  • 6,067
  • 5
  • 34
  • 51

2 Answers2

1

I solved the problem. Maybe someone else is having the same issue and it can help.

Second guessed the solution was really simple. I had to change

status = camera.Acquisition.Capture();

to

status = camera.Acquisition.Capture(DeviceParameter.Wait);

and then the camera is waiting till you can capture an image.

Mighty Badaboom
  • 6,067
  • 5
  • 34
  • 51
0

You could also subscribe to EventFrame from the camera before starting the camera with Capture. A than read the camera memory in the Subscribed function like this:

                Int32 s32MemID;
                uEye.Defines.Status statusRet = Camera.Memory.GetLast(out s32MemID);
                System.Drawing.Bitmap image= null;

                Camera.Memory.ToBitmap(s32MemID, out image);

...

p.s. (DeviceParameter.Wait is according to IDS deprecated but if it solves your issue who gives a damn :-) )

A. Dzebo
  • 558
  • 6
  • 13