basler / pypylon

The official python wrapper for the pylon Camera Software Suite
http://www.baslerweb.com
BSD 3-Clause "New" or "Revised" License
557 stars 207 forks source link

Asynchronous grabbing from a 2-camera array #766

Open fhaibach opened 1 month ago

fhaibach commented 1 month ago

Describe what you want to implement and what the issue & the steps to reproduce it are:

grabmultiplecameras.py is an example of synchronous grabbing of frames. I need to do asynchronous grabbing from two cameras. For example, lets label the cameras as "1" and "2", then the sequence might be 1 1 1 1 2 1 1 1 2 1 1 1 1 1 The pattern that interleaves 2 is irregular. While I could get both images synchronously and just ignore unused images from 2, I was hoping for something cleaner and with less overhead.

Is your camera operational in Basler pylon viewer on your platform

Yes

Hardware setup & camera model(s) used

RPi 4, Raspbian/Debian OS USB4 - direct connection via 30 cm cables

Runtime information:

>>> import sys, pypylon.pylon, platform
>>> print(f'python: {sys.version}')
python: 3.11.2 (main, May  2 2024, 11:59:08) [GCC 12.2.0]
>>> print(f'platform: {sys.platform}/{platform.machine()}/{platform.release()}')
platform: linux/aarch64/6.6.31+rpt-rpi-v8
>>> print(f'pypylon: {pypylon.pylon.__version__} / {".".join([str(i) for i in pypylon.pylon.GetPylonVersion()])}')
pypylon: 4.0.0 / 8.0.0.10
thiesmoeller commented 1 month ago

Are the cameras HW triggered ?

fhaibach commented 1 month ago

The camera can be software triggered. There is no hw triggering in this setup.

FgH...

Frederick Haibach Sr. Director, Spectroscopy and Applications Direct: 774.462.6711 @.***https://www.kpmanalytics.com/

From: Thies Möller @.> Sent: Friday, July 19, 2024 6:28 PM To: basler/pypylon @.> Cc: Fred Haibach @.>; Author @.> Subject: Re: [basler/pypylon] Asynchronous grabbing from a 2-camera array (Issue #766)

You don't often get email from @.*** Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

Are the cameras HW triggered ?

- Reply to this email directly, view it on GitHubhttps://github.com/basler/pypylon/issues/766#issuecomment-2240410067, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BFV3HB4AFHAUGVLVDI2ARR3ZNGHFTAVCNFSM6AAAAABLFIYHICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBQGQYTAMBWG4. You are receiving this because you authored the thread.Message ID: @.***>

SMA2016a commented 1 month ago

are you using same camera model? and the resulting frame rate of both camera is same?

may be the camera 2 running slower or it is losing images.

HighImp commented 1 month ago

Hi, you want the irregular pattern, but you dont know how to trigger the second camera irregular, did i get that correct? Can you tell the fps and when do you know if the second camera should take an Image? Is the irregular pattern known from the beginning or do you react to something during the process?

HighImp commented 1 month ago

Also, you don't necessarily have to use the InstantCameraArray.

You can also create two instances of InstantCameras and call camera.RetrieveResult for each camera individually. If you use the Grab method: LatestImageOnly, pylon will automatically discard any uncaptured images.

The cameras will continue to grab images in freerun. So if you want to avoid traffic to your host, a software trigger solution might be the best, but then you need to know the pattern in advance.

One additional thing, because you say "grabmultiplecameras.py is an example of synchronous grabbing": The fact that both cameras start recording at the same time does not mean that they are necessarily synchronised. Over time, they will definitely be out of sync. To achieve a stable synchronised exposure, you need to use a trigger. I understand that you want asynchronous images, but I want to be sure that you don't expect the exposure of the two cameras to occur simultaneously when an image is taken from both cameras.