elerac / EasyPySpin

cv2.VideoCapture like wrapper for FLIR Spinnaker SDK
MIT License
99 stars 19 forks source link

Accesing FrameID and Timestamp #13

Closed nriaziat closed 1 year ago

nriaziat commented 1 year ago

Is there any way to access a frame's ID and timestamp? I tried via VideoCapture.cam.Timestamp.GetValue() but it throws

_PySpin.SpinnakerException: Spinnaker: Invalid handle of type IntegerNode. [-1006]

Is something wrong with how I am trying to access the frame's timestamp? I'd like to verify the communication delay in the system.

elerac commented 1 year ago

Hi @nriaziat !

Essentially this issue is caused by the original PySpin (NOT EasyPySpin). But I suggest the following code.

import EasyPySpin

cap = EasyPySpin.VideoCapture(0)

cap.set_pyspin_value("ChunkSelector", "FrameID")
cap.set_pyspin_value("ChunkEnable", True)
cap.set_pyspin_value("ChunkSelector", "Timestamp")
cap.set_pyspin_value("ChunkEnable", True)
cap.set_pyspin_value("ChunkModeActive", True)

for i in range(10):
    ret, img_raw = cap.read()
    frame_id = cap.get_pyspin_value("ChunkFrameID")
    time_stamp = cap.get_pyspin_value("ChunkTimestamp")
    print(f"i={i}, frame_id={frame_id}, time_stamp={time_stamp}")

The output in my case is

i=0, frame_id=1, time_stamp=9093758624
i=1, frame_id=2, time_stamp=9143909432
i=2, frame_id=3, time_stamp=9194061160
i=3, frame_id=4, time_stamp=9244212456
i=4, frame_id=5, time_stamp=9294364672
i=5, frame_id=6, time_stamp=9344515648
i=6, frame_id=7, time_stamp=9394667000
i=7, frame_id=8, time_stamp=9444818432
i=8, frame_id=9, time_stamp=9494970648
i=9, frame_id=10, time_stamp=9545122192
nriaziat commented 1 year ago

Thanks!