WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
RawFrame.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stddef.h> // NOLINT
8#include <stdint.h>
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14/**
15 * Raw Frame
16 */
17typedef struct WPI_RawFrame { // NOLINT
18 // image data
19 uint8_t* data;
20 // function to free image data (may be NULL)
21 void (*freeFunc)(void* cbdata, void* data, size_t capacity);
22 void* freeCbData; // data passed to freeFunc
23 size_t capacity; // data buffer capacity, in bytes
24 size_t size; // actual size of data, in bytes
25 int pixelFormat; // WPI_PixelFormat
26 int width; // width of image, in pixels
27 int height; // height of image, in pixels
28 int stride; // size of each row of data, in bytes (may be 0)
29 uint64_t timestamp; // image capture timestamp
30 int timestampSrc; // WPI_TimestampSource
32
33/**
34 * Timestamp metadata. Timebase is the same as wpi::util::Now
35 */
37 WPI_TIMESRC_UNKNOWN = 0, // unknown
38 WPI_TIMESRC_FRAME_DEQUEUE, // wpi::util::Now when the new frame was dequeued
39 // by CSCore. Does not account for camera exposure
40 // time or V4L latency.
41 WPI_TIMESRC_V4L_EOF, // End of Frame. Same as V4L2_BUF_FLAG_TSTAMP_SRC_EOF,
42 // translated into wpi::util::Now's timebase.
43 WPI_TIMESRC_V4L_SOE, // Start of Exposure. Same as
44 // V4L2_BUF_FLAG_TSTAMP_SRC_SOE, translated into
45 // wpi::util::Now's timebase.
46};
47
48// Returns nonzero if the frame data was allocated/reallocated
49int WPI_AllocateRawFrameData(WPI_RawFrame* frame, size_t requestedSize);
51void WPI_SetRawFrameData(WPI_RawFrame* frame, void* data, size_t size,
52 size_t capacity, void* cbdata,
53 void (*freeFunc)(void* cbdata, void* data,
54 size_t capacity));
55
56#ifdef __cplusplus
57} // extern "C"
58#endif
int WPI_AllocateRawFrameData(WPI_RawFrame *frame, size_t requestedSize)
WPI_TimestampSource
Timestamp metadata.
Definition RawFrame.h:36
@ WPI_TIMESRC_UNKNOWN
Definition RawFrame.h:37
@ WPI_TIMESRC_V4L_SOE
Definition RawFrame.h:43
@ WPI_TIMESRC_V4L_EOF
Definition RawFrame.h:41
@ WPI_TIMESRC_FRAME_DEQUEUE
Definition RawFrame.h:38
void WPI_SetRawFrameData(WPI_RawFrame *frame, void *data, size_t size, size_t capacity, void *cbdata, void(*freeFunc)(void *cbdata, void *data, size_t capacity))
void WPI_FreeRawFrameData(WPI_RawFrame *frame)
Raw Frame.
Definition RawFrame.h:17
int pixelFormat
Definition RawFrame.h:25
uint64_t timestamp
Definition RawFrame.h:29
void * freeCbData
Definition RawFrame.h:22
void(* freeFunc)(void *cbdata, void *data, size_t capacity)
Definition RawFrame.h:21
size_t capacity
Definition RawFrame.h:23
uint8_t * data
Definition RawFrame.h:19
size_t size
Definition RawFrame.h:24
int height
Definition RawFrame.h:27
int stride
Definition RawFrame.h:28
int width
Definition RawFrame.h:26
int timestampSrc
Definition RawFrame.h:30