mabl / PyPylon

An experimental python wrapper around the Basler Pylon 5 library
BSD 3-Clause "New" or "Revised" License
53 stars 34 forks source link

How can I grab frames triggered by arduino? #33

Open javierrenton opened 7 years ago

javierrenton commented 7 years ago

I would like to ask you about some hints on how to grab the frames I obtained with an external Arduino trigger. The frames are obtained with a Trigger Width Exposure mode, and Falling Edge configuration, 0/1 digital pin, from a given line. Whenever I try to get the frames from the buffer, I get in trouble.

Herein is how my code looks up to now:

#  This is my camera:
icam = py.InstantCamera(py.TlFactory.GetInstance().CreateFirstDevice())
icam.AcquisitionStart() 
# Trigger mode and exposure mode:
on_off=0
triggermode = ['On','Off']                        # Trigger mode, char 'On' or 'Off'
icam.TriggerMode = triggermode[on_off]
Nframes = time * FrameRate
if (icam.TriggerMode() == 'On'):
    icam.ExposureMode = 'TriggerWidth'
    icam.TriggerSource = 'Line4'
    icam.TriggerActivation = 'FallingEdge'
    icam.AcquisitionStatusSelector = 'FrameTriggerWait'
else: icam.ExposureTime = Texp;

* [...]    <-- External triggering, Arduino part of the code *

# we retrieve the set of frames:

 # to control how many pics we are grabbing:
itemnumb=0     
while(itemnumb <= Nframes):
     gray.append(icam.RetrieveResult)
     itemnumb+=1
# then we end the acquisition
icam.AcquisitionStop()

My intention is that gray has all the Nframes saved as a set of arrays

Thanks in advance!

horsto commented 7 years ago

Hi! Does this code work? Did you gain any further insights into how to work with triggered acquisition?