Capture
The Capture plugin provides an interface for accessing and configuring camera capture devices in Tellusim applications. It supports image, video, and preview capture with configurable formats such as H264, JPEG, and raw. The plugin exposes detailed control over camera parameters including resolution, orientation, white balance, exposure, focus, ISO sensitivity, and compression settings. The Capture class offers callback mechanisms for receiving captured image or video data and supports live preview using Texture objects. This functionality enables advanced real-time camera integration across multiple platforms, both during development and in production. The plugin is compatible with Windows, Linux, and macOS, Android, iOS, and Raspberry PI, and does not require external dependencies.
#include <platform/capture/include/TellusimCapture.h>
Example
// Create capture
Capture capture;
if(!capture.setSize(width, height)) return false;
// Open capture
if(!capture.info()) return false;
if(!capture.isOpened() && capture.hasFlag(Capture::FlagFormatH264) && !capture.open(Capture::FlagCaptureVideo | Capture::FlagFormatH264)) return false;
if(!capture.isOpened() && capture.hasFlag(Capture::FlagFormatJPEG) && !capture.open(Capture::FlagCaptureVideo | Capture::FlagFormatJPEG)) return false;
if(!capture.isOpened()) return false;
// Capture info
TS_LOGT(Message, "{0} {1} ({2})\n", capture.getTypeName(), capture.getName(), capture.getFlagsName());
// Video callback
File file;
volatile bool done = false;
auto video_callback = [&](const uint8_t *data, size_t size, uint64_t frame) {
if(!file.isOpened() && capture.hasFlag(Capture::FlagFormatH264)) file.open("video.h264", "wb");
if(!file.isOpened() && capture.hasFlag(Capture::FlagFormatJPEG)) file.open("video.mjpeg", "wb");
TS_LOGF(Message, "Frame: %u \r", (uint32_t)frame);
if(frame >= 64) done = true;
file.write(data, size);
};
// Capture video
if(!capture.beginVideo(video_callback)) return false;
while(!done) Time::sleep(100);
capture.endVideo();
// Close capture
capture.close();