jordens / pydc1394

python libdc1394 wrapper
GNU Lesser General Public License v3.0
3 stars 9 forks source link

External Trigger mode #6

Open eghbalhosseini opened 6 years ago

eghbalhosseini commented 6 years ago

Hi I am trying to run camera with external trigger, but when I use frame = cam.dequeue(poll=True) the output is always false. Here is how I initialize the camera:


cam=Camera()
modes=cam.modes
cam.mode=modes[1]
cam.mode.setup((360,360), (300,200), "MONO8") # head free setup 
sr = cam.shutter.absolute_range
cam.shutter.setup(0.001)
ex = cam.exposure.absolute_range
cam.exposure.setup(ex[0])
cam.exposure.active = False
cam.gamma.active = False
cam.brightness.value
cam.gain.setup(15)
cam.gamma.setup(1)
cam.brightness.setup(0)
cur_Dir = getvar('saveDir')
cam.trigger.mode = "0"
cam.trigger.source = "0"
cam.trigger.active="True"`

and I read the frames as follows: 
`cam.start_capture()
cam.start_video()
time.sleep(1)
frame=None
frame = cam.dequeue(poll=True)
cam.stop_video()
cam.stop_capture()

I'd appreciate if I could have your help on this issue

Thanks, Eghbal

jordens commented 6 years ago
cam.trigger.mode = "0"
cam.trigger.source = "0"
cam.trigger.active="True"`

does not make sense. Those are not strings. Please clean up your code and produce a minimal example.

eghbalhosseini commented 6 years ago

Thanks, I updated the file and currently using this code, while sending a pulse to input zero of the Grasshopper GPIO line. The Frame output is alway none, if I try poll=False, it remain indefinitely to the capture state. I am wondering if there is an alternative way to capture for trigger mode, or if there is an example code I can start with.

cam=Camera()
modes=cam.modes
cam.mode=modes[1]
cam.mode.setup((360,360), (300,200), "MONO8") # head free setup 
cam.exposure.active = False
cam.gamma.active = False
cam.trigger.mode = '0'
cam.trigger.source = '0'
cam.trigger.active=True
cam.trigger.source
cam.start_capture()
cam.start_video()
time.sleep(1)
frame=None
frame = cam.dequeue(poll=True)
cam.stop_video()
cam.stop_capture()
jordens commented 6 years ago

And you are sure trigger mode 0 and source 0 are what works with your camera and setup? What do sources() and modes() give you? Are you using the correct polarity? I remember that mode 14 and source 0 worked fine with the chameleon 2.

eghbalhosseini commented 6 years ago

I am using point gray grasshopper so I think the hardware setups are similar for sources I get:

 [u'0', u'2', u'3', u'SOFTWARE']

and I use this as a reference : https://www.ptgrey.com/KB/10250 and for modes:

[<pydc1394.camera2.Format7 at 0x11656d4d0>,
 <pydc1394.camera2.Format7 at 0x11656d510>,
 <pydc1394.camera2.Format7 at 0x11656d550>]

is there a sample code for external trigger that I could look into

jordens commented 6 years ago

trigger.modes(), not Camera.modes().

eghbalhosseini commented 6 years ago

sorry about that

cam.trigger.modes()
[u'0', u'1', u'14', u'15']
jordens commented 6 years ago

Hmm. Then I don't know. I don't have access to those cameras anymore. Maybe someone else can provide the answer. In general pydc1394 is a very thin wrapper over libdc1394. If you can do it over libdc1394 you can do it here as well.