Raspberry Pi camera, recording video (raw .h264 converted to .mp4 on a background thread) and taking pictures.
More...
#include <PiCamera.h>
|
| | PiCamera () |
| | Builds a Pi camera component. More...
|
| |
| | ~PiCamera () |
| | Destroys the camera, joining any in-progress video-conversion thread and turning off first. More...
|
| |
| virtual void | TurnOn () override |
| | No-op: the camera is driven on demand via RecordVideo/TakePicture, so there is nothing to turn on. More...
|
| |
| virtual void | TurnOff () override |
| | No-op: the camera holds no persistent hardware state that needs releasing when turned off. More...
|
| |
| virtual void | ProcessRawValues () override |
| | No-op: the camera produces media files on demand, so there are no raw values to process. More...
|
| |
| virtual std::string | ToString () const override |
| | Serializes the camera to a string. More...
|
| |
| void | RecordVideo (const char *fileName, unsigned int durationInSeconds=5U) |
| | Records video to the given file for a duration, then converts the raw .h264 to .mp4 on a background thread. More...
|
| |
| void | RecordVideo (const char *fileName, unsigned int durationInSeconds, unsigned int width, unsigned int height, unsigned int fps, unsigned long bitRate) |
| | Records video with explicit resolution, frame rate, and bit rate, then converts the raw .h264 to .mp4 on a background thread. More...
|
| |
| void | TakePicture (const char *fileName, unsigned int delayInSeconds=1U) |
| | Takes a picture and saves it to the given file after a short delay. More...
|
| |
| | BaseComponent () |
| | Builds a base component with an unknown type and an empty name. More...
|
| |
| virtual | ~BaseComponent () |
| | Virtual destructor so deleting a component through a BaseComponent* also cleans up the concrete subclass. More...
|
| |
| virtual void | TurnOn ()=0 |
| | Turns the component on (e.g. More...
|
| |
| virtual void | TurnOff ()=0 |
| | Turns the component off. More...
|
| |
| virtual std::string | ToString () const =0 |
| | Serializes the component's current readings to a string (usually JSON). More...
|
| |
| virtual void | ProcessRawValues ()=0 |
| | Reads and processes the component's latest raw values (called once per poll). More...
|
| |
| virtual EComponentType | GetComponentType () const |
| | Gets the component's type. More...
|
| |
| const std::string & | GetName () const |
| | Gets the component's unique per-instance name. More...
|
| |
| void | SetName (const std::string &name) |
| | Sets the component's unique per-instance name. More...
|
| |
|
| int | SendCameraCommand (const char *programName, const char *fileName, unsigned int timeInSeconds, unsigned int width=0U, unsigned int height=0U, unsigned int fps=0U, unsigned long bitRate=0UL) |
| | Builds and runs a raspivid/raspistill OS command for the given program, output file, and optional video settings. More...
|
| |
|
| static void | ConvertH264ToMP4 (std::string fileName) |
| | Converts a raw .h264 video file to .mp4 (via MP4Box) and removes the original .h264 on success. More...
|
| |
Raspberry Pi camera, recording video (raw .h264 converted to .mp4 on a background thread) and taking pictures.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
◆ PiCamera()
| RumPi::PiCamera::PiCamera |
( |
| ) |
|
Builds a Pi camera component.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
PiCamera()
Builds a Pi camera component.
Definition: PiCamera.cpp:16
◆ ~PiCamera()
| RumPi::PiCamera::~PiCamera |
( |
| ) |
|
Destroys the camera, joining any in-progress video-conversion thread and turning off first.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
◆ ConvertH264ToMP4()
| void RumPi::PiCamera::ConvertH264ToMP4 |
( |
std::string |
fileName | ) |
|
|
staticprivate |
Converts a raw .h264 video file to .mp4 (via MP4Box) and removes the original .h264 on success.
Runs on a background thread and takes the file name by value so it owns its own copy.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
static void ConvertH264ToMP4(std::string fileName)
Converts a raw .h264 video file to .mp4 (via MP4Box) and removes the original .h264 on success.
Definition: PiCamera.cpp:271
- Parameters
-
| [in] | fileName | The file name (without extension) to convert. |
◆ ProcessRawValues()
| void RumPi::PiCamera::ProcessRawValues |
( |
| ) |
|
|
overridevirtual |
No-op: the camera produces media files on demand, so there are no raw values to process.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
camera.ProcessRawValues();
Implements RumPi::BaseComponent.
◆ RecordVideo() [1/2]
| void RumPi::PiCamera::RecordVideo |
( |
const char * |
fileName, |
|
|
unsigned int |
durationInSeconds, |
|
|
unsigned int |
width, |
|
|
unsigned int |
height, |
|
|
unsigned int |
fps, |
|
|
unsigned long |
bitRate |
|
) |
| |
Records video with explicit resolution, frame rate, and bit rate, then converts the raw .h264 to .mp4 on a background thread.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
camera.RecordVideo("clip", 5U, 1920U, 1080U, 30U, 10000000UL);
- Parameters
-
| [in] | fileName | The output file name (without extension). |
| [in] | durationInSeconds | How long to record, in seconds. |
| [in] | width | The video width, in pixels. |
| [in] | height | The video height, in pixels. |
| [in] | fps | The frame rate, in frames per second. |
| [in] | bitRate | The video bit rate. |
◆ RecordVideo() [2/2]
| void RumPi::PiCamera::RecordVideo |
( |
const char * |
fileName, |
|
|
unsigned int |
durationInSeconds = 5U |
|
) |
| |
Records video to the given file for a duration, then converts the raw .h264 to .mp4 on a background thread.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
camera.RecordVideo("clip", 5U);
- Parameters
-
| [in] | fileName | The output file name (without extension). |
| [in] | durationInSeconds | How long to record, in seconds. |
◆ SendCameraCommand()
| int RumPi::PiCamera::SendCameraCommand |
( |
const char * |
programName, |
|
|
const char * |
fileName, |
|
|
unsigned int |
timeInSeconds, |
|
|
unsigned int |
width = 0U, |
|
|
unsigned int |
height = 0U, |
|
|
unsigned int |
fps = 0U, |
|
|
unsigned long |
bitRate = 0UL |
|
) |
| |
|
private |
Builds and runs a raspivid/raspistill OS command for the given program, output file, and optional video settings.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
int SendCameraCommand(const char *programName, const char *fileName, unsigned int timeInSeconds, unsigned int width=0U, unsigned int height=0U, unsigned int fps=0U, unsigned long bitRate=0UL)
Builds and runs a raspivid/raspistill OS command for the given program, output file,...
Definition: PiCamera.cpp:217
- Parameters
-
| [in] | programName | The camera program to run ("raspivid" or "raspistill"). |
| [in] | fileName | The output file name (without extension). |
| [in] | timeInSeconds | The duration/delay, in seconds (converted to milliseconds internally). |
| [in] | width | The video width in pixels, or 0 to omit. |
| [in] | height | The video height in pixels, or 0 to omit. |
| [in] | fps | The frame rate, or 0 to omit. |
| [in] | bitRate | The video bit rate, or 0 to omit. |
- Returns
- The system() result, or -1 if the arguments were invalid.
◆ TakePicture()
| void RumPi::PiCamera::TakePicture |
( |
const char * |
fileName, |
|
|
unsigned int |
delayInSeconds = 1U |
|
) |
| |
Takes a picture and saves it to the given file after a short delay.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
camera.TakePicture("photo", 1U);
- Parameters
-
| [in] | fileName | The output file name (without extension). |
| [in] | delayInSeconds | How long to wait before capturing, in seconds. |
◆ ToString()
| std::string RumPi::PiCamera::ToString |
( |
| ) |
const |
|
overridevirtual |
Serializes the camera to a string.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
std::string data = camera.ToString();
- Returns
- A string identifying the camera.
Implements RumPi::BaseComponent.
◆ TurnOff()
| void RumPi::PiCamera::TurnOff |
( |
| ) |
|
|
overridevirtual |
No-op: the camera holds no persistent hardware state that needs releasing when turned off.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
Implements RumPi::BaseComponent.
◆ TurnOn()
| void RumPi::PiCamera::TurnOn |
( |
| ) |
|
|
overridevirtual |
No-op: the camera is driven on demand via RecordVideo/TakePicture, so there is nothing to turn on.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
Implements RumPi::BaseComponent.
◆ myConvertThread
| std::thread RumPi::PiCamera::myConvertThread |
|
private |
The background thread that converts recorded .h264 video to .mp4.
The documentation for this class was generated from the following files: