Skip to content
a Python API to record video & system timestamps from Imaging Source USB cameras
Python Batchfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE adding DOI Aug 5, 2019
TISGrabberSetup_3.4.0.51.exe hello world Aug 2, 2019
camera_env.yaml hello world Aug 2, 2019 hello world Aug 2, 2019
install2.bat Update install2.bat Aug 4, 2019

cam cntrl

record video and system timestamps from Imaging Source USB3 cameras

Python GUI + scripts to record video sync'ed to behavior. Can record from multiple imaging source camera feeds while simultaneously grabbing system timestamps for each recorded frame. One can also record timestamps from one NIDAQ card signal to sync with a behavioral task (records timestamp on the rising edge of a TTL signal).

This software package was written by Gary Kane, post-doctoral fellow @ the Adaptive Motor Control Lab.

Prerequisite Software:

  1. Windows 10
  2. Anaconda
  3. Git

Required Hardware:

  1. Imaging Source USB cameras
  2. (Optional) NIDAQ card. Necessary to record timestamps from a behavioral task. Signal must be a TTL wired to digital input channel that is not dual-PFI (one that has hardware interrupt capabilities).

Instructions for Installation:

  1. Clone this repository. Open command prompt (type "cmd" into the search bar and hit enter), then type:

    git clone

  2. Open the camera control directory, right-click 'install1.bat' and select 'Run as administrator'

    This script will install imaging source libraries, ffmpeg for command prompt, and create a new conda environment 'camera27'. Upon completion, the window will close suddenly.

  3. Run 'install2.bat'.

    This script will finish setting up the conda environment and create a desktop shortcut to open the GUI.

  4. Edit the '' script according to your system's camera configuration. A template is provided (, please do not edit the template. The '' script will write a dictionary to the file 'camera_details.json' containing the following fields:

    • a dictionary for each imaging source camera with the fields:

      • name = camera name

      • crop = cropping parameters

      • rotate = rotation angle of image

      • exposure = integer exposure values; can edit this in the GUI

      • output_dir = default directory to save videos; can edit this in the GUI

      • Example:

        cam_0 = {'name' : 'Cog Rig',
                'crop' : {'top' : 150, 'left' : 225, 'height' : 250, 'width' : 300},
                'rotate' : 0,
                'exposure' : -14,
                'output_dir' : 'C:/Users/user1/Desktop/video'}
    • subjects = a list of experimental subjects to select. Can be manually entered in GUI

    • labview = a list of labview channels to select, e.g. ['Dev1/port0/line0'] (optional). Can be manually entered in GUI

To Run the Program:

Double click the cameraGUI.bat file on the Desktop or open command prompt, navigate to the camera_control directory, and run: python

  1. Select the number of cameras to record from
  2. Select and initialize each cameras
  3. Select subject, frame rate and output directory, then click 'Set Up Video'
    • Will default to the output directory from 'camera_details.json'
    • Drop down menus for subject and output directory are populated via 'camera_details.json'
  4. To start recording, click the On button. Recording can be turned Off/On multiple times -- frames, system timestamps, and timestamps from the nidaq card will be stored only when 'Record' is set to 'On'.
  5. Once finished recording, click 'Save Video', 'Compress & Save Video', or 'Delete Video'
    • 'Save Video' saves an .avi file using the DIVX codec to 'output_dir/CameraName_Subject_Date.avi' and timestamp files to 'output_dir/TIMESTAMPS_CameraName_Subject_Date.npy' and (if applicable) 'output_dir/LABVIEW_Subject_Date.npy'. There will be one timestamps file per camera, but only one labview timestamp file per session.
    • 'Compress & Save Video' saves as above, but also saves an .mp4 file using ffmpeg compression to 'output_dir/CameraName_Subject_Date.mp4'
    • 'Delete Video' will not save any videos of timestamp files. Preliminary video files will be deleted.
  6. To record more videos, return to step iii.




If you find this software useful for your research, please cite: DOI

You can’t perform that action at this time.