Jump to content

Contributions:WebcamLogger: Difference between revisions

From BCI2000 Wiki
Pbrunner (talk | contribs)
No edit summary
Pbrunner (talk | contribs)
Line 49: Line 49:
*<code>SelectCodec</code>  - Use OpenCV's GUI for selecting codecs available on system. Each connected camera will prompt for a codec to be selected. The default codec is DIVX.
*<code>SelectCodec</code>  - Use OpenCV's GUI for selecting codecs available on system. Each connected camera will prompt for a codec to be selected. The default codec is DIVX.


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.
Video is saved with a resolution of the camera being used.


==Event Variables==
==Event Variables==

Revision as of 18:31, 28 November 2018

Synopsis

A Extension that records video from one or more webcams to an avi file, and stores frame numbers as state variables.

Location

http://www.bci2000.org/svn/trunk/src/contrib/Extensions/WebcamLogger

Versioning

Authors

Adam Wilson (adam.wilson@uc.edu) & Alex Belsten (belsten@neurotechcenter.org)

Version History

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

07/13/2011 - Bugfixes

11/28/2018 - Updated openCV to v2.4.3 for x32/x64 Windows and added functionality for recording from multiple cameras

Source Code Revisions

  • Initial development: --
  • Tested under: 5828
  • Known to compile under: 5828
  • Broken since: 5828 for MinGW

TODO

Update MinGW openCV library

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).

PROTIP: This module can also be used to perform screen capture with the proper virtual screencast webcam driver. Dubious website, but this product works well: http://www.pcwinsoft.com/screencamera/

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.

Usage

Webcams should be installed and configured per the device instructions. The Webcam logger uses the OpenCV (version 2.4.3) library for display and saving.

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

Parameters

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 - Used to select one camera to record from on systems with multiple cameras. Use value 0 for the default camera.
  • RecordAll - Enables the recording of cameras from StartIndex to EndIndex.
  • StartIndex - Index to start searching for cameras at.
  • EndIndex - Index to stop searching for cameras at.
  • Decimation - The decimation factor for saving and viewing video; the logger saves/displays every Nth frame.
  • DateTimeLocation - The location of the date/time overlay in saved video (0: none, 1: UpperRight, 2: UpperLeft, 3: LowerRight, 4: LowerLeft).
  • DisplayStream - Display the each connected cameras stream. Display stream is identical to what is being recorded in the .avi file.
  • SelectCodec - Use OpenCV's GUI for selecting codecs available on system. Each connected camera will prompt for a codec to be selected. The default codec is DIVX.

Video is saved with a resolution of the camera being used.

Event Variables

WebcamFrame<0-n>

The frame number of the video recorded on camera with index i. i must be less than or equal to n due to the nature of event declarations. The default value of n is 3, allowing for the recording of up to 4 cameras. To record from more cameras, change the NUM_OF_WEBCAM_EVENTS macro in WebcamLogger.cpp to to number of cameras you want to record from and recompile. Event values 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, Programming Reference:Events