Namespaces | |
| namespace | detail |
Data Structures | |
| struct | FrameView |
| Borrowed same-exposure evidence, without object or navigation semantics. More... | |
| struct | FrameProcessor |
| Stack-owned model-specific operations; no dynamic plugin allocation. More... | |
| class | FrameLease |
| Exactly-once release of a borrowed frame, including exception exits. More... | |
| class | Camera |
| One exclusive IMX500 owner with bounded reusable YUV420 buffers. More... | |
Functions | |
| static bool | encode_frame_jpeg (const char *path, const std::array< const uint8_t *, 3 > &planes, unsigned width, unsigned height, unsigned stride, const FrameView *view, const FrameProcessor *processor) |
| Encode one YUV420 frame with optional same-exposure EXIF metadata. | |
| bool | encode_jpeg (const char *path, const std::array< const uint8_t *, 3 > &planes, unsigned width, unsigned height, unsigned stride) |
| Encode validated YUV420 planes directly, without full-frame RGB staging. | |
| bool | publish_frame (const FrameView &frame, const std::array< const uint8_t *, 3 > &planes, unsigned stride, const char *filename, const FrameProcessor &processor) |
| Publish caller-validated YUV420 planes and same-exposure evidence. | |
| int | run_worker (int argc, char **argv, const FrameProcessor &processor, const char *application) |
| Run the shared probe/capture/READY-SHOT-OK worker with supplied model policy. | |
| int | run_photo_worker (int argc, char **argv, const char *application) |
| Run photo-only probe, capture or serve without model loading or inference. | |
| constexpr bool | valid_capture_dimensions (unsigned width, unsigned height) |
| Check that capture dimensions meet the worker's raster policy. | |
Variables | |
| constexpr unsigned | sensor_width = 4056 |
| Physical IMX500 array width, used to reject an unexpected sensor geometry. | |
| constexpr unsigned | sensor_height = 3040 |
| Physical IMX500 array height; model input dimensions are separate policy. | |
Function Documentation
◆ encode_frame_jpeg()
|
static |
Encode one YUV420 frame with optional same-exposure EXIF metadata.
- Parameters
-
path New output path; exclusive creation never replaces an existing file. planes Borrowed Y, Cb and Cr starts, readable throughout encoding. width Positive even image width in pixels. height Positive even image height in pixels. stride Even luma byte stride; chroma uses half this stride. view Capture evidence to embed, or NULL for a pixels-only JPEG. processor Optional application callback for extending the EXIF document.
- Returns
- True after encoding, flushing, file sync and close; false on metadata rejection or I/O/codec failure. Partial files created here are removed.
- Precondition
- The caller has validated dimensions, strides and accessible plane lengths.
Metadata is prepared before opening the output or entering libjpeg's C error boundary, so a throwing embed callback leaves no partial JPEG behind.
Definition at line 278 of file imx500_camera.cpp.
◆ encode_jpeg()
| bool imx500::encode_jpeg | ( | const char * | path, |
| const std::array< const uint8_t *, 3 > & | planes, | ||
| unsigned | width, | ||
| unsigned | height, | ||
| unsigned | stride ) |
Encode validated YUV420 planes directly, without full-frame RGB staging.
Use the same encoder without capture/application metadata so pixels-only callers retain identical YUV layout and output-cleanup behavior.
- Parameters
-
path New output path; exclusive creation refuses overwrites. planes Accessible Y, Cb and Cr plane starts, immutable during encoding. width Positive even image width in pixels. height Positive even image height in pixels. stride Even luma byte stride, at least the width rounded up to 16; chroma uses half.
- Returns
- True after encoding, flush, file sync and close; false removes partial output.
- Precondition
- The caller has checked plane lengths and image/stride layout. This low-level encoder does not accept arbitrary unchecked external plane pointers.
Definition at line 359 of file imx500_camera.cpp.
◆ publish_frame()
| bool imx500::publish_frame | ( | const FrameView & | view, |
| const std::array< const uint8_t *, 3 > & | planes, | ||
| unsigned | stride, | ||
| const char * | filename, | ||
| const FrameProcessor & | processor ) |
Publish caller-validated YUV420 planes and same-exposure evidence.
Encode first, then attempt sidecar output, then link the complete JPEG into place. The JPEG is the final publication step, but JPEG and sidecar are not one atomic transaction; callbacks must remove their own partial outputs.
- Exceptions
-
std::exception Filesystem or processor exceptions propagate after cleanup.
- Parameters
-
view Borrowed evidence belonging to the supplied pixels. planes Accessible YUV420 planes retained by the caller. stride Luma byte stride; chroma uses half this stride. filename New absolute JPEG destination. processor Application's trusted sidecar suffix and writer callbacks.
- Returns
- True when the JPEG is published, regardless of missing analysis; false when publication fails. File/processor exceptions may also propagate.
- Precondition
- Plane spans cover the declared image/stride and remain immutable for this call. Capture retains its frame lease while invoking this routine.
Analysis failure retains a usable photograph. Publication failure removes successfully created sidecars from this operation, never an existing image.
- Warning
- JPEG and sidecars are not one filesystem transaction. Consumers must check file/exposure identity, and directory power-loss durability is not guaranteed.
Definition at line 712 of file imx500_camera.cpp.
◆ run_photo_worker()
| int imx500::run_photo_worker | ( | int | argc, |
| char ** | argv, | ||
| const char * | application ) |
Run photo-only probe, capture or serve without model loading or inference.
- Parameters
-
argc Argument count for the photo-only command. argv Command and mode-specific dimensions or destination. application Diagnostic prefix.
- Returns
- Zero for success, two for invalid arguments, one for runtime failure.
Definition at line 931 of file imx500_camera.cpp.
◆ run_worker()
| int imx500::run_worker | ( | int | argc, |
| char ** | argv, | ||
| const FrameProcessor & | processor, | ||
| const char * | application ) |
Run the shared probe/capture/READY-SHOT-OK worker with supplied model policy.
- Return values
-
0 Probe/capture succeeded, or the serving input ended cleanly. 1 Runtime, output or protocol-stream I/O failure. 2 Invalid arguments, dimensions, processor contract or command syntax.
A per-SHOT save failure emits ERROR without retrying the exposure. An exception terminates the worker after reporting the reason on stderr.
- Parameters
-
argc Argument count for a capture mode, excluding saved-photo matcher modes. argv Mode, RPK and mode-specific dimensions/destination tokens. processor Readiness and sidecar callbacks; never interpreted as navigation here. application Diagnostic prefix selected by the independent entry point.
- Returns
- Zero for success, two for syntax/configuration misuse, one for runtime failure.
The worker announces READY after a fresh frame and, for detection, model-specific validation. Every SHOT leases a new exposure without replay. Standard output is protocol-only while diagnostics go to standard error.
Definition at line 817 of file imx500_camera.cpp.
◆ valid_capture_dimensions()
|
constexpr |
Check that capture dimensions meet the worker's raster policy.
- Parameters
-
width Requested columns. height Requested rows.
- Returns
- True for an even raster within the physical array and minimum dimensions.
Check here before driver setup; this does not guarantee that the driver will accept a specific format or stream configuration.
Definition at line 68 of file imx500_camera.hpp.
Variable Documentation
◆ sensor_height
|
constexpr |
Physical IMX500 array height; model input dimensions are separate policy.
Definition at line 60 of file imx500_camera.hpp.
◆ sensor_width
|
constexpr |
Physical IMX500 array width, used to reject an unexpected sensor geometry.
Definition at line 58 of file imx500_camera.hpp.