Contributions:WebcamLogger
Synopsis
An 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)
- Alexander Belsten (belsten@neurotechcenter.org)
- Juergen Mellinger (mellinger@neurotechcenter.org)
Version History
07/06/2011 - Full commit with support for MSVC and MinGW.
07/13/2011 - Bugfixes
11/28/2018 - Updated openCV library to v2.4.3 for x86/x64 Windows and added functionality for recording from multiple cameras
3/16/2021 - Updated openCV library to v4.5.1 for x86/x64 Windows.
2/2/2022 - Rewrite WebcamLogger to use a helper app that records camera data to a file and allows previewing
Source Code Revisions
- Initial development: --
- Tested under: 7227
- Known to compile under: 7227
- Broken since: 5828 for MinGW
Known Issues
None.
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 MP4 video file. It also records the current frame number as a state variable, so that the video can be synchronized with brain data at sample resolution (max. 1ms). 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. In your root build folder, run Configure.sh.cmd in order to bring up the CMake GUI; there, enable EXTENSIONS_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 Windows Media Foundation (WMF) library for display and saving. Desired resolution may be chosen per webcam, and will be matched agains available resolutions.
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 video stream from each connected camera. Display stream is identical to what is being recorded in the .mp4 file.
WebcamFormat
For each camera index, you may specify a video width, height, and fps. These are matched against the formats provided by the camera, and the closest one is chosen.
In the last column of the WebcamFormat matrix parameter, an optional webcam URL may be specified. If an URL is present, it will be used to acquire video data rather than the webcam with the specified index attached to the machine. The URL parameter supports format supported by the Microsoft Media Foundation. Currently, these are restricted to ASF and MPEG-1.
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