Bonsai_Triggered_Recording - KravitzLab/KreedLabWiki GitHub Wiki

  1. Open the "singleTriggeredCamera" workflow, available here. This workflow will monitor a camera, and when a pulse is detected on an Arduino pin it will record a video that starts N seconds before the pulse, and records for M seconds after.

  2. Plug in a USB camera and Arduino via USB. Make sure the Arduino is flashed with "Firmata Standard" code (it's in the Arduino IDE examples).
    image

Also make sure the Digital Input node has the correct port and pin settings for the Arduino image

  1. Check that the correct camera is selected. This is set by changing the "Index" argument in VideoCaptureDevice, you may see the name of the camera pop up, but if not just try changing the index to 0, 1, or 2 and see which camera shows up. image

  2. Open the "Select Many" node and make sure the VideoWriter path is set to where you want to write videos. It is critical to give the file an extension, ie: ".avi", so a full path might be: Yiru\TriggeredSocialVideos\SocialVideo.avi image

  3. If you want to set the duration of the video before the pulse change the "Delay" node: image

  4. If you want to change the duration of the video after the pulse change the "WindowTrigger" node: image

  5. If you open the "Crop" node you can see the live view of the camera, and if you open the "VideoWriter" node when triggered you will see what's being written to the video file (this will start seconds before the pulse) image

  6. This script will result in a library of videos, recorded for each pulse: image