Photometrics / PyVCAM

Python3.X wrapper for Photometrics and QImaging PVCAM based cameras
MIT License
36 stars 17 forks source link

clarification on api #12

Closed kasliwalr closed 3 years ago

kasliwalr commented 3 years ago

System information:

Could you clarify how PyVCAM API corresponds to PVCAM SDK C++ API for the following cases:

  1. I would like to do software-triggered live/sequence acquisition, at maximum possible speed. I was trying to adapt the sw_trigger.py example but it seems the start_live or start_sequence API do not wait for software-trigger. If you comment out the TriggerThreadRun section as shown below, you would expect the start_live() to wait forever, but instead it runs to completion.
# example: [sw_trigger.py](https://github.com/Photometrics/PyVCAM/blob/master/pyvcam_wrapper/tests/sw_trigger.py)
def main():
    # Initialize PVCAM and find the first available camera.
    pvc.init_pvcam()

    cam = [cam for cam in Camera.detect_camera()][0]
    cam.open()
    cam.speed_table_index = 0
    cam.exp_mode = 'Edge Trigger'
    print(cam.exp_modes)
    # Start a thread for executing the trigger
    # t1 = TriggerThreadRun(cam)
    # t1.start()

    # Collect frames in live mode
    cam.start_live()
    framesReceived = collectFrames(cam)
    cam.finish()
    print('Received live frames: ' + str(framesReceived) + '\n')

    # Collect frames in sequence mode
    # cam.start_seq(num_frames=NUM_FRAMES)
    # framesReceived = collectFrames(cam)
    # cam.finish()
    # print('Received seq frames: ' + str(framesReceived) + '\n')

    # t1.stop()
    cam.close()
    pvc.uninit_pvcam()

    print('Done')
  1. ~How you set buffer size in PyVCAM API: I would like to do sequence acquisition, but I want to set the buffer size to say 100 frames worth of space, how can I do that using PyVCAM API? If I cannot do that, how to find the buffer size, what is the default?~ Looking at the .cpp code does clarify things for me (correct me if I am wrong) - allocating memory based on number of frames passed

  2. ~poll_frame: In start_seq, what happens if poll_frame is called at a slower rate than FPS? will the underlying buffer be overwritten? In C++ SDK, one could set the buffer size and is thus assured that it will not be overwritten. In live acquisition (C++), the buffer is overwritten if circular mode is set.~ When using poll_frame, are frames returned in FIFO order? Also, have you confirmed that poll_frame times-out when trigger is not received. I tried with Edge trigger and the program kept waiting for trigger. Can we set timeout from Python API?

stevebellinger commented 3 years ago
  1. IRIS15 doesn't support software trigger.
  2. Correct, memory is allocated based on the number of frames requested.
  3. Frames are returned in FIFO order. You can not set a poll_frame time out. I have added this feature to our backlog for a future release, but that will likely not be ready until the end of March. Do you need this feature in the near term? If so, it can be implemented in a branch.
kasliwalr commented 3 years ago

Thanks! for the clarification. poll_frame timeout is not a big/urgent issue for us, a "monitoring" thread in python to interrupt the acquisition should do the trick I think.

stevebellinger commented 3 years ago

Yes, that should work.

kasliwalr commented 3 years ago

I also don't see any option to set buffer size of circular buffer in start_live. It is set to 16 frames ~ 500MB. Can you make this settable?

stevebellinger commented 3 years ago

I have added a feature to our backlog to add support for specifying the buffer size in live mode. Let me know if you need this in a branch prior to the release.

kasliwalr commented 3 years ago

prior to release, and as soon as possible if you can. will hard-coding in c++ file, and reinstalling PyVCAM work?

stevebellinger commented 3 years ago

Yes, hard-coding the number of frames will work. Please see pvcmodule.cpp:517

kasliwalr commented 3 years ago

does PyVCAM's poll_frame() return a copy of the frame, or is it still referencing the memory in the circular buffer. I need to know if I have to do copying in python to protect the frame?

stevebellinger commented 3 years ago

Yes, a copy occurs. Please see camera.py:374