fixstars / ion-kit

Modernized graph-based data processing framework
MIT License
7 stars 6 forks source link

Return -1 for devices has no frame count #253

Closed Fixstars-momoko closed 4 months ago

Fixstars-momoko commented 4 months ago

With Basler, arv_buffer_get_frame_id obtained blockid of U3V leader, which starts at 0 and increments by 1 for each frame.

The log with frame number:

[2024-03-01 16:09:50.531] [ion] [info] Start building pipeline
[2024-03-01 16:09:50.532] [ion] [debug] Determine free port _ion_iport_0 as input_images on Node 7ba02f55-2d1e-4b2a-b0f9-7a0287f13d00
[2024-03-01 16:09:50.532] [ion] [debug] Determine free port _ion_iport_1 as input_deviceinfo on Node 7ba02f55-2d1e-4b2a-b0f9-7a0287f13d00
[2024-03-01 16:09:50.532] [ion] [debug] Determine free port _ion_iport_2 as frame_count on Node 7ba02f55-2d1e-4b2a-b0f9-7a0287f13d00
[2024-03-01 16:09:50.533] [ion] [debug] Determine free port _ion_iport_3 as width on Node 7ba02f55-2d1e-4b2a-b0f9-7a0287f13d00
[2024-03-01 16:09:50.533] [ion] [debug] Determine free port _ion_iport_4 as height on Node 7ba02f55-2d1e-4b2a-b0f9-7a0287f13d00
[2024-03-01 16:09:50.533] [ion] [info] Builder::register_disposer
[2024-03-01 16:09:50.533] [ion] [info] Builder::register_disposer
[2024-03-01 16:09:51.146] [ion] [info] Create U3V instance: 730dcfcc-9666-4dea-ba6d-ba327571bab3
[2024-03-01 16:09:51.146] [ion] [debug] U3V:: 23-11-18 : updating obtain and write
[2024-03-01 16:09:51.147] [ion] [info] Using aravis-0.8.31
[2024-03-01 16:09:52.172] [ion] [info] Creating U3V instance with 1 devices...
[2024-03-01 16:09:52.173] [ion] [info] Acquisition option::frame_sync_ is false
[2024-03-01 16:09:52.175] [ion] [info] Acquisition option::realtime_display_mode_ is false
[2024-03-01 16:09:52.176] [ion] [info]  Device/USB 0::DeviceID : Basler-26760158A14A-22585674
[2024-03-01 16:09:52.245] [ion] [info]  Device/USB 0::PixelFormat : RGB8
[2024-03-01 16:09:52.247] [ion] [info]  Device/USB 0::PayloadSize : 3686400
[2024-03-01 16:09:52.249] [ion] [info]  Device/USB 0::GenDC : Not Supported
[2024-03-01 16:09:52.250] [ion] [info]  Device/USB 0::Width : 1280
[2024-03-01 16:09:52.250] [ion] [info]  Device/USB 0::Height : 960
[2024-03-01 16:09:52.252] [ion] [info]  Device/USB 0::Buffer Size : 1073741824
[2024-03-01 16:09:52.252] [ion] [info]  Device/USB 0::Number of Buffers : 292
[2024-03-01 16:09:52.252] [ion] [info]  Device/USB 0::Command : AcquisitionMode
[2024-03-01 16:09:52.257] [ion] [info]  Device/USB 0::Command : AcquisitionStart
[2024-03-01 16:09:52.293] [ion] [trace] All-Popped Frames (USB0, USB1)=(                   0,                     )
[2024-03-01 16:09:52.294] [ion] [trace] Obtained Frame from USB0: 0
[2024-03-01 16:09:52.295] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.316] [ion] [trace] All-Popped Frames (USB0, USB1)=(                   1,                     )
[2024-03-01 16:09:52.320] [ion] [trace] Obtained Frame from USB0: 1
[2024-03-01 16:09:52.322] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.339] [ion] [trace] All-Popped Frames (USB0, USB1)=(                   2,                     )
[2024-03-01 16:09:52.341] [ion] [trace] Obtained Frame from USB0: 2
[2024-03-01 16:09:52.342] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.362] [ion] [trace] All-Popped Frames (USB0, USB1)=(                   3,                     )
[2024-03-01 16:09:52.364] [ion] [trace] Obtained Frame from USB0: 3
[2024-03-01 16:09:52.364] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.385] [ion] [trace] All-Popped Frames (USB0, USB1)=(                   4,                     )
[2024-03-01 16:09:52.387] [ion] [trace] Obtained Frame from USB0: 4
[2024-03-01 16:09:52.387] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.409] [ion] [trace] All-Popped Frames (USB0, USB1)=(                   5,                     )
[2024-03-01 16:09:52.410] [ion] [trace] Obtained Frame from USB0: 5
[2024-03-01 16:09:52.410] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.432] [ion] [trace] All-Popped Frames (USB0, USB1)=(                   6,                     )
[2024-03-01 16:09:52.433] [ion] [trace] Obtained Frame from USB0: 6
[2024-03-01 16:09:52.434] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.455] [ion] [trace] All-Popped Frames (USB0, USB1)=(                   7,                     )
[2024-03-01 16:09:52.456] [ion] [trace] Obtained Frame from USB0: 7
[2024-03-01 16:09:52.457] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.478] [ion] [trace] All-Popped Frames (USB0, USB1)=(                   8,                     )
[2024-03-01 16:09:52.479] [ion] [trace] Obtained Frame from USB0: 8
[2024-03-01 16:09:52.480] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.501] [ion] [trace] All-Popped Frames (USB0, USB1)=(                   9,                     )
[2024-03-01 16:09:52.503] [ion] [trace] Obtained Frame from USB0: 9
[2024-03-01 16:09:52.503] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.524] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  10,                     )
[2024-03-01 16:09:52.526] [ion] [trace] Obtained Frame from USB0: 10
[2024-03-01 16:09:52.527] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.548] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  11,                     )
[2024-03-01 16:09:52.549] [ion] [trace] Obtained Frame from USB0: 11
[2024-03-01 16:09:52.550] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.571] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  12,                     )
[2024-03-01 16:09:52.572] [ion] [trace] Obtained Frame from USB0: 12
[2024-03-01 16:09:52.573] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.594] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  13,                     )
[2024-03-01 16:09:52.595] [ion] [trace] Obtained Frame from USB0: 13
[2024-03-01 16:09:52.596] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.617] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  14,                     )
[2024-03-01 16:09:52.621] [ion] [trace] Obtained Frame from USB0: 14
[2024-03-01 16:09:52.622] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.640] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  15,                     )
[2024-03-01 16:09:52.642] [ion] [trace] Obtained Frame from USB0: 15
[2024-03-01 16:09:52.643] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.663] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  16,                     )
[2024-03-01 16:09:52.665] [ion] [trace] Obtained Frame from USB0: 16
[2024-03-01 16:09:52.665] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.687] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  17,                     )
[2024-03-01 16:09:52.688] [ion] [trace] Obtained Frame from USB0: 17
[2024-03-01 16:09:52.689] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.710] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  18,                     )
[2024-03-01 16:09:52.711] [ion] [trace] Obtained Frame from USB0: 18
[2024-03-01 16:09:52.712] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.733] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  19,                     )
[2024-03-01 16:09:52.734] [ion] [trace] Obtained Frame from USB0: 19
[2024-03-01 16:09:52.735] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.756] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  20,                     )
[2024-03-01 16:09:52.758] [ion] [trace] Obtained Frame from USB0: 20
[2024-03-01 16:09:52.758] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.779] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  21,                     )
[2024-03-01 16:09:52.781] [ion] [trace] Obtained Frame from USB0: 21
[2024-03-01 16:09:52.781] [ion] [trace] Obtained Device info USB0
[2024-03-01 16:09:52.803] [ion] [trace] All-Popped Frames (USB0, USB1)=(                  22,                     )
...
Fixstars-momoko commented 4 months ago

CHANGE THE API DESIGN

frame count is originally designed for frame sync, and the value should be the unique number generated by device, not U3V transfer protocol.

The following log shows the test to display frame count stored in GenDC descriptor and frame id which is stored in U3V DataBlock with 2 cameras.

[2024-03-02 10:36:36.768] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5310,                    0)
[2024-03-02 10:36:36.769] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5310,                    0)
[2024-03-02 10:36:36.772] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5311,                    1)
[2024-03-02 10:36:36.773] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5311,                    1)
[2024-03-02 10:36:36.776] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5312,                    2)
[2024-03-02 10:36:36.776] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5312,                    2)
[2024-03-02 10:36:36.781] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5313,                    3)
[2024-03-02 10:36:36.781] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5313,                    3)
[2024-03-02 10:36:36.784] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5314,                    4)
[2024-03-02 10:36:36.785] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5314,                    4)
[2024-03-02 10:36:36.789] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5315,                    5)
[2024-03-02 10:36:36.789] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5315,                    5)
[2024-03-02 10:36:36.793] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5316,                    6)
[2024-03-02 10:36:36.793] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5316,                    6)
[2024-03-02 10:36:36.797] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5317,                    7)
[2024-03-02 10:36:36.797] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5317,                    7)
[2024-03-02 10:36:36.801] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5318,                    8)
[2024-03-02 10:36:36.802] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5318,                    8)
[2024-03-02 10:36:36.805] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5319,                    9)
[2024-03-02 10:36:36.806] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5319,                    9)
[2024-03-02 10:36:36.810] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5320,                   10)
[2024-03-02 10:36:36.810] [ion] [debug] Comparing GenDC Descriptor Framecount vs U3V frame id = (                5320,                   10)

We do not treat them in the same API, so if device has no frame count, we will return -1 instead of frame count.

TODO @Fixstars-momoko : update the code

Fixstars-momoko commented 4 months ago

Now return -1 if frame count method is neither typespecific (GenDC) nor timestamp. 86b47a1

By adding the exception on user application side,

                if ctypes.c_long(fc & 0xFFFFFFFF).value  == -1:
                    raise Exception("This U3V Camera does not support Frame count.")
xinyuli1204 commented 4 months ago

Done by https://github.com/fixstars/ion-kit/pull/254