basler / pypylon-samples

BSD 3-Clause "New" or "Revised" License
39 stars 14 forks source link

`GrabStrategy_LatestImageOnly` question #7

Open mflova opened 3 months ago

mflova commented 3 months ago

I would like to have two USB-based cameras synchronized. Currently I have a difference of 50ms as I am just acquiring images in a sequential manner with the default grab strategy. I have been reading about the PTP protocol but it is already discarded as this only applies to gigE-based cameras. Therefore it seems that the only option I have is using an external trigger (which I read here https://github.com/basler/pypylon/issues/470). Before doing that, I was wondering about a specific grab strategy. This is GrabStrategy_LatestImageOnly.

My question is, when you do something like:

cameras.StartGrabbing(pylon.GrabStrategy_LatestImageOnly, pylon.GrabLoop_ProvidedByUser)

Is the signal that triggers the start of the image acquisition somehow "aligned"? Some points to give context about what I mean with this:

Is there any other simpler approach without going with the hardware trigger? About the sync I need, I would be expecting something around 1ms ideally.

Thanks!

sebastianbasler commented 3 months ago

Hey mflova,

the best way to synchronized grabbing images of 2 cameras without using a hardware trigger would be a GigE camera using PTP and Scheduled Action Commands.

I don not know if you are already working with it, but you can try to work with SoftwareTrigger to trigger both cameras as parallel as possible. Therefore you need to configure the cameras for the triggered image acquisition with software trigger as trigger. When you start the grabbing now, the cameras wait for the software trigger and immediately start the exposure if it is present.

However, i would still expect an unpredictable difference in the start of the exposure of both cameras, which depends on when the PC is actually working on the command (OS and CPU dependent I think).

But you may want to try it out to see if this is accurate enough for your application.

Sebastian

thiesmoeller commented 3 months ago

Do you need only one image pair? Or a continuous stream of synchronous image pairs at e.g. 30 fps?

mflova commented 3 months ago

Hey mflova,

the best way to synchronized grabbing images of 2 cameras without using a hardware trigger would be a GigE camera using PTP and Scheduled Action Commands.

I don not know if you are already working with it, but you can try to work with SoftwareTrigger to trigger both cameras as parallel as possible. Therefore you need to configure the cameras for the triggered image acquisition with software trigger as trigger. When you start the grabbing now, the cameras wait for the software trigger and immediately start the exposure if it is present.

However, i would still expect an unpredictable difference in the start of the exposure of both cameras, which depends on when the PC is actually working on the command (OS and CPU dependent I think).

But you may want to try it out to see if this is accurate enough for your application.

Sebastian

Thanks for the tip. That was quite useful! I only have the USB cameras so I will have to work on those. In any case, it should be possible with the external trigger by using an electrical signal, right? I have been reading about it and at some point I might end up needing it

Do you need only one image pair? Or a continuous stream of synchronous image pairs at e.g. 30 fps?

I need multiple images paired. The fact that it ends up being even 31 fps or 29 fps due to inaccuracies of the OS is not a problem. It does not matter if the time between consecutive images is not constant. However, whenever I take one image I would like to know that the other one is as close as possible.