morefigs / py-ic-imaging-control

Python wrapper for the IC Imaging Control SDK from The Imaging Source (TIS)
MIT License
33 stars 22 forks source link

taking series of images #6

Closed nanoballs closed 7 years ago

nanoballs commented 8 years ago

hi, i am trying to take 50 images into a for loop at 7.5 fps but it seemes to me that it isnt really doing what i expect...

``

from pyicic.IC_ImagingControl import IC_ImagingControl from time import sleep, time from ctypes import* import numpy as np

ic_ic = IC_ImagingControl() ic_ic.init_library()

cam_names = ic_ic.get_unique_device_names() cam = ic_ic.get_device(cam_names[0]) cam.open() cam.set_video_format('Y800 (1024x768)')

cam.set_frame_rate(7.5) cam.enable_continuous_mode(True) cam.start_live(show_display=True) immall=[] t0=time() for i in np.linspace(0,50,51):

if not cam.callback_registered:
    cam.register_frame_ready_callback()  # needed to wait for frame ready callback
cam.reset_frame_ready()
cam.wait_til_frame_ready(1000)

img_height = cam.get_video_format_height()
img_width = cam.get_video_format_width()
img_depth = 3  # 3 colours for RGB
buffer_size = img_height * img_width * img_depth * sizeof(c_uint8)

img_ptr = cam.get_image_ptr()
img_data = cast(img_ptr, POINTER(c_ubyte * buffer_size))

imm = np.ndarray(buffer=img_data.contents,
                 dtype=np.uint8,
                 shape=(img_height, img_width, img_depth))

print time()-t0
immall.append(imm.transpose()[1][:][:].transpose())
sleep(1./7)

cam.close()

`` it seemes i only get 4 different images which are repeated all the time.. probably i am doing something stupid in looking at the buffer memory? thanks for help!

morefigs commented 8 years ago

You don't seem to be using a software trigger, do you have a hardware trigger? If so, are you synchronising the hardware trigger with the image capture somehow? If you are not using a hardware trigger try adding a software trigger like this:

cam.reset_frame_ready()                 # reset frame ready flag

# send hardware trigger OR call cam.send_trigger() here
cam.send_trigger()

cam.wait_til_frame_ready(1000)              # wait for frame ready due to trigger
morefigs commented 7 years ago

Assumed fixed, closing.