Hi Liron,
I forget which example code I used, but just use any one where arducam_capture() retrieves the frame. Once you’ve got that working, add arducam_set_mode(camera_instance, 16); to change the camera mode to one of the externally triggered ones. Once you’ve done that, arducam_capture() should start returning only after a sync pulse is received by the camera (or it times out).
Here’s a list of all the camera modes:
mode: 0, width: 1280, height: 800, pixelformat: GREY, desc: Used for ov9281 1lane raw8
mode: 1, width: 1280, height: 720, pixelformat: GREY, desc: Used for ov9281 1lane raw8
mode: 2, width: 640, height: 400, pixelformat: GREY, desc: Used for ov9281 1lane raw8
mode: 3, width: 320, height: 200, pixelformat: GREY, desc: Used for ov9281 1lane raw8
mode: 4, width: 160, height: 100, pixelformat: GREY, desc: Used for ov9281 1lane raw8
mode: 5, width: 1280, height: 800, pixelformat: GREY, desc: Used for ov9281 2lanes raw8
mode: 6, width: 1280, height: 800, pixelformat: Y10P, desc: Used for ov9281 2lanes raw10
mode: 7, width: 2560, height: 800, pixelformat: Y10P, desc: Used for synchronized stereo camera HAT 1280x8002
mode: 8, width: 2560, height: 720, pixelformat: Y10P, desc: Used for synchronized stereo camera HAT 2560x7202
mode: 9, width: 1280, height: 400, pixelformat: Y10P, desc: Used for synchronized stereo camera HAT 640x4802
mode: 10, width: 640, height: 200, pixelformat: Y10P, desc: Used for synchronized stereo camera HAT 320x2002
mode: 11, width: 320, height: 100, pixelformat: Y10P, desc: Used for synchronized stereo camera HAT 160x100*2
mode: 12, width: 1280, height: 800, pixelformat: GREY, desc: Used for ov9281 1lane raw8 1280x800 external trigger mode
mode: 13, width: 1280, height: 720, pixelformat: GREY, desc: Used for ov9281 1lane raw8 1280x720 external trigger mode
mode: 14, width: 640, height: 400, pixelformat: GREY, desc: Used for ov9281 1lane raw8 640x400 external trigger mode
mode: 15, width: 320, height: 200, pixelformat: GREY, desc: Used for ov9281 1lane raw8 320x200 external trigger mode
mode: 16, width: 1280, height: 800, pixelformat: GREY, desc: Used for ov9281 2lanes raw8 1280x800 external trigger mode
mode: 17, width: 1280, height: 800, pixelformat: Y10P, desc: Used for ov9281 2lanes raw10 1280x800 external trigger mode
mode: 18, width: 1280, height: 720, pixelformat: GREY, desc: Used for ov9281 2lanes raw8 1280x720 external trigger mode
mode: 19, width: 640, height: 400, pixelformat: GREY, desc: Used for ov9281 2lanes raw8 640x400 external trigger mode
mode: 20, width: 320, height: 200, pixelformat: GREY, desc: Used for ov9281 2lanes raw8 320x200 external trigger mode
To save a video file, I ended up using opencv’s video writer. To covert the frame buffer that arducam returns to a mat you can use the following line:
Mat temp = Mat(cv::Size(camera_width, camera_height), CV_8UC1, frame_buffer->data);
Note that this doesn’t actually allocate new memory, it just creates a mat that refers to the existing data.
One other trick I used was to save 600 or more frame buffers to ram, then write them when I was done recording. (Each frame buffer is about 1MB).