Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
pangea_survey::ImageFraming Class Reference

Produce a bounded crop/resample view over a source BGRA image. More...

#include <image_framing.h>

Data Structures

struct  Sample
struct  Crop
 Source-space crop and uniform scale needed for an output frame. More...
struct  View

Public Member Functions

View apply (const unsigned char *bgra, int sourceWidth, int sourceHeight, int stride, int width, int height, int inset=0, double rotationDegrees=0, double rotationBoundDegrees=0)
 Frame BGRA pixels into a crop, resampled image, or rotated image.

Static Public Member Functions

static Crop crop (int sourceWidth, int sourceHeight, int width, int height, int inset=0, double rotationBoundDegrees=0)
 Fit an output aspect ratio inside source bounds and rotation margin.

Private Types

using Channels = std::array<float, 4>

Static Private Member Functions

static Channels splat (float value)
 Broadcast a scalar to all four portable BGRA lanes.
static Channels sum (Channels first, Channels second)
 Accumulate channel values without mixing color and alpha.
static Channels difference (Channels first, Channels second)
 Form independent channel deltas for interpolation.
static Channels product (Channels first, Channels second)
 Multiply each channel by its corresponding weight.
static Channels load (const float *values)
 Load four floating-point channel values in BGRA order.
static void store (float *target, Channels values)
 Store channels in the order expected by byte conversion.
static Channels channels (const unsigned char *pixel)
 Widen a packed BGRA pixel for floating-point interpolation.
template<typename SamplePixel>
static void writeRow (unsigned char *destination, int width, SamplePixel &&sample)
 Write one sampled row to the byte raster.
static void samples (std::vector< Sample > &result, int count, int sourceSize, double offset, double scale)
 Precompute bilinear indices and fractions along one output axis.

Private Attributes

int sourceWidth_ = 0
int sourceHeight_ = 0
int width_ = 0
int height_ = 0
int inset_ = 0
double rotationBound_ = 0
std::vector< Sample > columns_
std::vector< Sample > rows_
std::vector< unsigned char > buffer_
std::vector< float > horizontal_ [2]

Detailed Description

Produce a bounded crop/resample view over a source BGRA image.

The view may borrow the source pixels for an exact crop or point to this object's reusable output buffer after resampling/rotation. In the latter case, the bytes remain valid only until the next call to apply.

Definition at line 62 of file image_framing.h.

Member Typedef Documentation

◆ Channels

using pangea_survey::ImageFraming::Channels = std::array<float, 4>
private

Definition at line 141 of file image_framing.h.

Member Function Documentation

◆ apply()

View pangea_survey::ImageFraming::apply ( const unsigned char * bgra,
int sourceWidth,
int sourceHeight,
int stride,
int width,
int height,
int inset = 0,
double rotationDegrees = 0,
double rotationBoundDegrees = 0 )
inline

Frame BGRA pixels into a crop, resampled image, or rotated image.

Parameters
[in]bgraBorrowed source pixel buffer.
[in]sourceWidthSource width in pixels.
[in]sourceHeightSource height in pixels.
[in]strideSource row stride in bytes.
[in]widthRequested output width in pixels.
[in]heightRequested output height in pixels.
[in]insetExcluded border in source pixels.
[in]rotationDegreesApplied rotation in the renderer's image coordinates.
[in]rotationBoundDegreesMaximum rotation used when selecting a safe crop.
Returns
BGRA view and the source crop represented by its pixels.
Exceptions
std::runtime_errorIf input bounds or the rotated footprint are invalid.
Note
A returned pointer to internal storage is invalidated by the next call.

Definition at line 277 of file image_framing.h.

◆ channels()

Channels pangea_survey::ImageFraming::channels ( const unsigned char * pixel)
inlinestaticprivate

Widen a packed BGRA pixel for floating-point interpolation.

Parameters
pixelFour readable bytes in BGRA order.
Returns
The same channel values without byte-range arithmetic.

Definition at line 184 of file image_framing.h.

◆ crop()

Crop pangea_survey::ImageFraming::crop ( int sourceWidth,
int sourceHeight,
int width,
int height,
int inset = 0,
double rotationBoundDegrees = 0 )
inlinestatic

Fit an output aspect ratio inside source bounds and rotation margin.

Parameters
[in]sourceWidthSource image width in pixels.
[in]sourceHeightSource image height in pixels.
[in]widthRequested output width in pixels.
[in]heightRequested output height in pixels.
[in]insetMinimum source-edge margin in pixels.
[in]rotationBoundDegreesMaximum absolute rotation to accommodate.
Returns
Centered crop rectangle and the common scale for both axes.
Exceptions
std::runtime_errorIf dimensions, margin, or rotation are invalid.

Definition at line 239 of file image_framing.h.

◆ difference()

Channels pangea_survey::ImageFraming::difference ( Channels first,
Channels second )
inlinestaticprivate

Form independent channel deltas for interpolation.

Parameters
firstReference values.
secondValues to subtract.
Returns
Lane-wise difference.

Definition at line 158 of file image_framing.h.

◆ load()

Channels pangea_survey::ImageFraming::load ( const float * values)
inlinestaticprivate

Load four floating-point channel values in BGRA order.

Parameters
valuesFour readable floats.
Returns
Loaded channels.

Definition at line 173 of file image_framing.h.

◆ product()

Channels pangea_survey::ImageFraming::product ( Channels first,
Channels second )
inlinestaticprivate

Multiply each channel by its corresponding weight.

Parameters
firstFirst lane vector.
secondSecond lane vector.
Returns
Lane-wise product.

Definition at line 166 of file image_framing.h.

◆ samples()

void pangea_survey::ImageFraming::samples ( std::vector< Sample > & result,
int count,
int sourceSize,
double offset,
double scale )
inlinestaticprivate

Precompute bilinear indices and fractions along one output axis.

Parameters
[out]resultOne entry per output sample.
countOutput samples on the axis.
sourceSizePositive source extent in pixels.
offsetCrop offset in source pixels.
scaleSource pixels per output sample.

Map pixel centers and clamp before computing neighbors. Reusing these entries avoids repeated coordinate arithmetic in each row.

Definition at line 212 of file image_framing.h.

◆ splat()

Channels pangea_survey::ImageFraming::splat ( float value)
inlinestaticprivate

Broadcast a scalar to all four portable BGRA lanes.

Parameters
valueWeight to broadcast.
Returns
Four identical lanes.

Definition at line 145 of file image_framing.h.

◆ store()

void pangea_survey::ImageFraming::store ( float * target,
Channels values )
inlinestaticprivate

Store channels in the order expected by byte conversion.

Parameters
[out]targetFour writable floats.
valuesChannel values in BGRA order.

Definition at line 177 of file image_framing.h.

◆ sum()

Channels pangea_survey::ImageFraming::sum ( Channels first,
Channels second )
inlinestaticprivate

Accumulate channel values without mixing color and alpha.

Parameters
firstLeft operand.
secondRight operand.
Returns
Lane-wise sum.

Definition at line 150 of file image_framing.h.

◆ writeRow()

template<typename SamplePixel>
void pangea_survey::ImageFraming::writeRow ( unsigned char * destination,
int width,
SamplePixel && sample )
inlinestaticprivate

Write one sampled row to the byte raster.

Template Parameters
SamplePixelCallable yielding four lanes for an output column.
Parameters
[out]destinationRow storage of at least four bytes per pixel.
widthOutput column count.
sampleInterpolating sampler.

Round and clamp at the byte boundary, not during interpolation.

Definition at line 195 of file image_framing.h.

Field Documentation

◆ buffer_

std::vector<unsigned char> pangea_survey::ImageFraming::buffer_
private

Definition at line 70 of file image_framing.h.

◆ columns_

std::vector<Sample> pangea_survey::ImageFraming::columns_
private

Definition at line 69 of file image_framing.h.

◆ height_

int pangea_survey::ImageFraming::height_ = 0
private

Definition at line 67 of file image_framing.h.

◆ horizontal_

std::vector<float> pangea_survey::ImageFraming::horizontal_[2]
private

Definition at line 71 of file image_framing.h.

◆ inset_

int pangea_survey::ImageFraming::inset_ = 0
private

Definition at line 67 of file image_framing.h.

◆ rotationBound_

double pangea_survey::ImageFraming::rotationBound_ = 0
private

Definition at line 68 of file image_framing.h.

◆ rows_

std::vector<Sample> pangea_survey::ImageFraming::rows_
private

Definition at line 69 of file image_framing.h.

◆ sourceHeight_

int pangea_survey::ImageFraming::sourceHeight_ = 0
private

Definition at line 67 of file image_framing.h.

◆ sourceWidth_

int pangea_survey::ImageFraming::sourceWidth_ = 0
private

Definition at line 67 of file image_framing.h.

◆ width_

int pangea_survey::ImageFraming::width_ = 0
private

Definition at line 67 of file image_framing.h.


The documentation for this class was generated from the following file: