JARVIS-MoCap / JARVIS-AcquisitionTool

AcquisitionTool to record multi-camera recordings for the JARVIS 3D Markerless Pose Estimation Toolbox
https://jarvis-mocap.github.io/jarvis-docs/
GNU Lesser General Public License v2.1
19 stars 3 forks source link

Digitial input on FLIR cameras with AcquisitionTool #13

Open timsainb opened 2 years ago

timsainb commented 2 years ago

Is there any functionality built in to AcquisitionTool to read/save signals from the digital input on FLIR cameras? e.g. for syncing data with other acquisition devices? If so, where is that information saved?

DIO documentation for FLIR cameras here. and here

timsainb commented 2 years ago

I think this would involve checking LineStatus in recordFrame and saving that info to metadata.csv?

JARVIS-MoCap commented 2 years ago

Currently there is no way to read the GPIO Pins of the FLIR cameras. From having a brief look at it it seems like that might be feature that is pretty quick to add, so I will definitely consider adding it.

We are currently working on adding support for reading the GPIO pins of the trigger microcontroller and logging that to a file though, this should also make it possible to sync the cameras with external devices. As with many features this is not very well documented at the moment I'm afraid, so you might have to dig into the TriggerFirmware a little bit to make it work for your usecase. I'm gonna refer you to @padok again, since he's the one who implemented all this.

Hope this helps, Timo

padok commented 2 years ago

[1/2] Current method of synchronization

If you use our external trigger, a similar functionality is already supported. Most of the supported microcontroller boards log the inputs at pins 16-23 in a triggerdata.csv file.

For synchronization, the microcontroller board logs the first inputs at the time the first pulse was sent. This way you can synchronize the first images of the cameras and their internal clock to the internal clock of the external trigger.

                           ┌─────┐     ┌─────┐     ┌─       ─┐
         ...               │     │     │     │     │   ...   │ ...
              ─────────────┘     └─────┘     └─────┘         └───────────
wavestate           0      │  1  │  0  │  1  │  0  │ 1     n │     0
pulse_count     UINT32_MAX │  0  │  0  │  1  │  1  │ 2     n │ UINT32_MAX
pulse_count (cont.) n      │ n+1 │ n+1 │ n+2 │ n+2 │n+3   n+m│    n+m
sync_rising_edge == true   ┴     │
sync_rising_edge == false        ┴

The file contents will look similar to this:

metadata.csv

frame_camera_serial ;frame_camera_name ;frame_id ;frame_timestamp ;frame_image_uid
           19415034 ;Camera_4          ;       0 ;597449368203896 ; 94017979513872
           19415037 ;Camera_3          ;       0 ;163273368203367 ; 94017967892976
           19415033 ;Camera_1          ;       0 ;272583328921019 ; 94017972152896
           21013374 ;Camera_0          ;       0 ;770316960921060 ; 94017962792256
           19415035 ;Camera_2          ;       0 ;855758496921019 ; 94017968796096
           19415037 ;Camera_3          ;       1 ;163273382493569 ; 94017975321952
           19415033 ;Camera_1          ;       1 ;272583343210976 ; 94017978831696
           19415035 ;Camera_2          ;       1 ;855758511211505 ; 94017973880432
           21013374 ;Camera_0          ;       1 ;770316975211505 ; 94017966449648
           19415034 ;Camera_4          ;       1 ;597449382494016 ; 94017981830272
           19415037 ;Camera_3          ;       2 ;163273396783772 ; 94017979597136
           21013374 ;Camera_0          ;       2 ;770316989501708 ; 94017966467888
           19415033 ;Camera_1          ;       2 ;272583357501546 ; 94017995748160
           19415035 ;Camera_2          ;       2 ;855758525501505 ; 94017978237504
           19415034 ;Camera_4          ;       2 ;597449396784219 ; 94017990808464
...

triggerdata.csv

flag_0 ;flag_1 ;flag_2 ;flag_3 ;flag_4 ;flag_5 ;flag_6 ;flag_7 ;pulse_id ;uptime_us
true   ;true   ;true   ;true   ;true   ;true   ;true   ;true   ;       0 ;2508068633
false  ;true   ;true   ;true   ;true   ;true   ;true   ;true   ;   57822 ;3086494592
true   ;true   ;true   ;true   ;true   ;true   ;true   ;true   ;  155876 ;4067383774
false  ;true   ;true   ;true   ;true   ;true   ;true   ;true   ;  155876 ;4067383785
true   ;true   ;true   ;true   ;true   ;true   ;true   ;true   ;  156850 ;4077121115
false  ;true   ;true   ;true   ;true   ;true   ;true   ;true   ;  163316 ;4141801073
true   ;true   ;true   ;true   ;true   ;true   ;true   ;true   ;  163316 ;4141801084
false  ;true   ;true   ;true   ;true   ;true   ;true   ;true   ;  167740 ;4186060281
true   ;true   ;true   ;true   ;true   ;true   ;true   ;true   ;  171554 ;4224218818
false  ;true   ;true   ;true   ;true   ;true   ;true   ;true   ;  172716 ;4235837376
...

If your setup is working correctly, pulse_id and frame_id should also align within their time intervals.

Please note that if you rely on the external trigger or the in-camera clocks, you will need to correct them for longer recordings as they will drift away from each other since they are not real-time clocks. Also, unfortunately, the trigger uptime is currently only a 32-bit unsigned integer, which means it overflows every 71 minutes and 35 seconds.

[2/2] Requested method of synchronization

Yes, I would absolutely like to add camera input recording. But unfortunately I don't know yet how the Spinnaker SDK exposes this information to us. I need to take a closer look at this first. I have a feeling LineStatusAll might lead somewhere, but it doesn't look quite right yet.

timsainb commented 2 years ago

Thanks! The DIO on the external trigger met my needs, but I'll leave this open.