From BCI2000 Wiki
Revision as of 15:34, 6 July 2011 by Awilson (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


A filter that records video recorded from a webcam to an avi file, and stores the frame number in a State variable.




Adam Wilson (

Version History

07/06/11 - Full commit with support for MSVC and MinGW.

Source Code Revisions


  • Add geometry decimation (e.g., save other than 320x240).

Functional Description

For many experiments, visual information about how a subject is behaving during an experiment is desired. This extension acquires video from most webcams, and writes to an AVI video file. It also records the current frame number as a state variable, so that the video can be synchronized with brain data with a resolution of the block size. Other options include the ability to overlay the date and time directly on the video (useful for long-term monitoring), and time decimation (i.e., save every Nth frame).

Integration into BCI2000

Compile the extension into your source module by enabling contributed extensions in your CMake configuration. You can do this by going into your root build folder and deleting CMakeCache.txt and re-running the project batch file, or by running cmake -i and enabling BUILD_WEBCAMLOGGER. Once the extension is built into the source module, enable it by starting the source module with the --LogWebcam=1 command line argument.


The webcam should be installed and configured per the device instructions. The Webcam logger uses the OpenCV library for display and saving; supported webcams can be found at: [1].

Camera options are found in the Source tab of the Configuration window.


The Webcam logger is configured in the Source tab within the WebcamLogger section. The configurable parameters are:

  • LogWebcam - Enables/Disables logging of Webcam states
  • CameraNumber - the webcam number for systems with multiple cameras, 0 for the default camera
  • WebcamDecimation - The decimation factor for saving and viewing video; the logger saves/displays every Nth frame.
  • WebcamDateTimeLocation - The location of the date/time overlay in saved video (0: none, 1: UpperRight, 2: UpperLeft, 3: LowerRight, 4: LowerLeft).

The video is saved with a resolution of 320x240 pixels. A parameter that allows configuration of the geometry will be provided in a future version.

State Variables


The frame number of the video. This can be used to synchronize the video with the recorded neural data. It is a 24-bit value, allowing 16,777,216 frames before overflowing. If the webcam can capture at 30 frame/sec, and is decimated at a factor of 5 (i.e., 6 frames/sec), this allows more than a month of video before it will go back to frame 0. In other words, this should not be an issue for most users.

See also

User Reference:Logging Input, Contributions:Extensions