Video Input from a Raspberry Pi B+ Camera Module
Although the steps I've outlined below might seem trivial, there are a number of conflicting sources on how to access the video feed from the Raspberry Pi B+ using OpenCV, many of which do not work. The following guide is designed to help you quickly and efficiently work recording video into your project. Please note that my instructions were tested using Python 2 with OpenCV.
==Step 1: Import OpenCV into your Python File
Assuming that you've successfully installed OpenCV on your Raspberry Pi B+, you need to include
at the top of your .py project file. This will allow you to use the OpenCV methods.
Step 2: Specify Location, Length, and FPS
Next, I would suggest creating global variables for: 1. The location on the Raspberry Pi where you would like to save your video clip, which will include the clip's name (it's usually best to use an absolute path in case you end up moving your project file) 2. The intended duration (in milliseconds) of your video clip 3. The number of frames per second in your video (I successfully tested values up to 90 FPS)
For example, under the previously described import statement: