Photometrics / PyVCAM

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

Threading and buffering, 1 #20

Closed kasasxav closed 3 years ago

kasasxav commented 3 years ago

This would fix issue #18 part 1.

stevebellinger commented 3 years ago

The changes to not wait forever in pvc_get_frame and allow the queue to grow in live mode look correct. I see you've also brought in changes to poll the latest frame rather than the oldest.

I'm moderately concerned that allowing the live frame queue to grow indefinitely will give you strange results if you don't pull frames from the queue quickly enough. The queue of frames are backed by a circular buffer of 16 frames. If your queue is longer than 16 frames you will end up with duplicate and out of order frames. I recommend keeping a close eye on how deep the frame queue gets (a printf should do the trick) and make sure the frame buffer can hold at least 2x the worst case. You can change the queue depth in pvc_start_live by adjusting the circBufferFrames variable.

As for making a wrapper function to get all available frames, I really don't recommend that. The existing poll functions will return extremely quickly. I would just call them in a python loop to get a list of frames. I doubt you will get a noticeable performance improvement if you form the list at the .cpp level.

This pull request won't be merged to master since that's not our process for implementing such large changes. Our process is to develop PyVCAM in house, perform a formal validation against a range of cameras and host computers, then update master from that validated version. The next release should be posted in July, definitely by the end of Q3. Part of that release will include at least some of these features you've identified.

Please continue to keep me posted on your progress.

kasasxav commented 3 years ago

Sounds good thanks, I think it did the trick like now. I did it indeed in a foor loop and seems to get all frames nicely. Thank you for your help!