8 #ifndef META_OCEAN_CV_DETECTOR_FRAME_CHANGE_DETECTOR_H
9 #define META_OCEAN_CV_DETECTOR_FRAME_CHANGE_DETECTOR_H
42 static constexpr
unsigned int kNumberIntensityBins = 16u;
45 static constexpr
unsigned int kIntensityBinWidth = 16u;
69 unsigned int targetFrameWidth = 0u;
72 unsigned int targetFrameHeight = 0u;
75 unsigned int spatialBinSize = 40u;
90 double minimumTimeBetweenKeyframes = 0.0;
116 inline bool isValid()
const;
169 inline const Options& options()
const;
175 inline unsigned int tileRows()
const;
181 inline unsigned int tileColumns()
const;
187 inline const Matrix& tileScores()
const;
193 inline bool isValid()
const;
220 void computeTileHistogramsSubset(
const uint8_t* yFrame,
const unsigned int yFrameStride,
bool shouldComputeHistogramDistances,
unsigned int tileIndexStart,
unsigned int numTilesToProcess);
284 options_(other.options_),
285 tileRows_(other.tileRows_),
286 tileColumns_(other.tileColumns_),
287 tileHistograms_(std::move(other.tileHistograms_)),
288 keyframeTileHistograms_(std::move(other.keyframeTileHistograms_)),
289 lastTimestamp_(other.lastTimestamp_),
290 priorLastTimestamp_(other.priorLastTimestamp_),
291 keyframeTimestamp_(other.keyframeTimestamp_),
292 lastLargeMotionTimestamp_(other.lastLargeMotionTimestamp_),
293 histogramDistances_(std::move(other.histogramDistances_)),
294 world_R_keyframe_(std::move(other.world_R_keyframe_))
329 tileRows_ = other.tileRows_;
330 tileColumns_ = other.tileColumns_;
331 tileHistograms_ = std::move(other.tileHistograms_);
332 keyframeTileHistograms_ = std::move(other.keyframeTileHistograms_);
333 lastTimestamp_ = other.lastTimestamp_;
334 priorLastTimestamp_ = other.priorLastTimestamp_;
335 keyframeTimestamp_ = other.keyframeTimestamp_;
336 lastLargeMotionTimestamp_ = other.lastLargeMotionTimestamp_;
337 histogramDistances_ = std::move(other.histogramDistances_);
338 world_R_keyframe_ = std::move(other.world_R_keyframe_);
This class implements a simple detection algorithm to compute whether a camera's image content has si...
Definition: FrameChangeDetector.h:38
void addAccelerationSample(const Vector3 &acceleration, const Timestamp ×tamp)
Records a new acceleration reading from an accelerometer.
Quaternion world_R_keyframe_
3DOF rotation of the last keyframe relative to a world coordinate frame. If rotations are not availab...
Definition: FrameChangeDetector.h:263
Timestamp lastTimestamp_
Timestamp of the last frame that was processed.
Definition: FrameChangeDetector.h:248
const Matrix & tileScores() const
Returns the most recently computed set of histogram distances for this detector.
Definition: FrameChangeDetector.h:314
void addGyroSample(const Vector3 &rotationRate, const Timestamp ×tamp)
Records a new rotational motion reading from a gyroscope.
Timestamp lastLargeMotionTimestamp_
Last timestamp at which large motion was detected from the accelerometer or gyro (if any).
Definition: FrameChangeDetector.h:257
unsigned int tileColumns_
Number of tile blocks in the horizontal dimension.
Definition: FrameChangeDetector.h:239
unsigned int tileRows_
Number of tile blocks in the vertical dimension.
Definition: FrameChangeDetector.h:236
Timestamp priorLastTimestamp_
Timestamp of frame prior to the last frame that was processed.
Definition: FrameChangeDetector.h:251
const Options & options() const
Returns the set of options that were specified when this detector was created.
Definition: FrameChangeDetector.h:299
TileHistograms tileHistograms_
Flattened grid of 2D histograms for the most recently processed frame, stored row-major.
Definition: FrameChangeDetector.h:242
std::array< uint32_t, kNumberIntensityBins > TileHistogram
Histogram type for a one-channel image.
Definition: FrameChangeDetector.h:48
void computeTileHistograms(const Frame &yFrame, bool shouldComputeHistogramDistances, Worker *worker)
Computes the local intensity histograms for all tiles in the image.
Timestamp keyframeTimestamp_
Timestamp of the current keyframe.
Definition: FrameChangeDetector.h:254
FrameChangeResult detectFrameChange(const Frame &yFrame, const Quaternion &world_R_camera, Worker *worker=nullptr)
Handles one frame of input and determines whether a significant change in visual content has occurred...
Matrix histogramDistances_
Flattened grid of 2D histogram distances between the most recently processed frame and the current ke...
Definition: FrameChangeDetector.h:260
unsigned int tileRows() const
Returns the number of rows in the associated tile matrix.
Definition: FrameChangeDetector.h:304
FrameChangeDetector(const Options &options)
Creates a new frame change detector with the given parameters.
FrameChangeResult
Different possible results for processFrame().
Definition: FrameChangeDetector.h:57
Options options_
Set of options for the detector.
Definition: FrameChangeDetector.h:233
void computeTileHistogramsSubset(const uint8_t *yFrame, const unsigned int yFrameStride, bool shouldComputeHistogramDistances, unsigned int tileIndexStart, unsigned int numTilesToProcess)
Computes the local intensity histograms for a subset of image tiles.
TileHistograms keyframeTileHistograms_
Flattened grid of 2D histograms for the current keyframe.
Definition: FrameChangeDetector.h:245
FrameChangeDetector()
Creates an invalid frame change detector.
Definition: FrameChangeDetector.h:271
bool isValid() const
Checks whether the detector was created with valid parameters.
Definition: FrameChangeDetector.h:319
static Scalar computeHistogramDistance(const TileHistogram &tileHistogram1, const TileHistogram &tileHistogram2)
Computes a distance score between two histograms.
unsigned int tileColumns() const
Returns the number of columns in the associated tile matrix.
Definition: FrameChangeDetector.h:309
FrameChangeDetector(const FrameChangeDetector &other)
Copy constructor.
std::vector< TileHistogram > TileHistograms
A vector of histograms for tiles in the image.
Definition: FrameChangeDetector.h:51
FrameChangeDetector & operator=(FrameChangeDetector &&other) noexcept
Move operator.
Definition: FrameChangeDetector.h:324
This class implements Ocean's image class.
Definition: Frame.h:1792
static constexpr T pi()
Returns PI which is equivalent to 180 degree.
Definition: Numeric.h:926
static constexpr T maxValue()
Returns the max scalar value.
Definition: Numeric.h:3244
This class implements a timestamp.
Definition: Timestamp.h:36
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
float Scalar
Definition of a scalar type.
Definition: Math.h:128
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15
Definition: FrameChangeDetector.h:67
unsigned int targetFrameHeight
Target frame height in pixels, with range (0, infinity). Input frames will be resized to this resolut...
Definition: FrameChangeDetector.h:72
unsigned int targetFrameWidth
Target frame width in pixels, with range (0, infinity). Input frames will be resized to this resoluti...
Definition: FrameChangeDetector.h:69
double preferredMaximumTimeBetweenKeyframes
Preferred threshold on the maximum amount of time between keyframes, in seconds, with range (minimumT...
Definition: FrameChangeDetector.h:95
Scalar rotationThreshold
Threshold on maximum total device rotation since the last keyframe, based on IMU, in radians with ran...
Definition: FrameChangeDetector.h:87
bool isValid() const
Checks whether the specified options are valid for processing.
Definition: FrameChangeDetector.h:266
Scalar histogramDistanceThreshold
Sets the maximum change considered when scoring a specific tile in the current image,...
Definition: FrameChangeDetector.h:105
Scalar minimumHistogramDistance
Minimum histogram distance between the keyframe and the current frame for a tile to be considered as ...
Definition: FrameChangeDetector.h:102
unsigned int spatialBinSize
Side length, in pixels, of each spatial bin used for local intensity histogram computation,...
Definition: FrameChangeDetector.h:75
double minimumTimeBetweenKeyframes
Threshold on the minimum amount of time between keyframes, in seconds, with range [0,...
Definition: FrameChangeDetector.h:90
double absoluteMaximumTimeBetweenKeyframes
Absolute threshold on the maximum amount of time between keyframes, in seconds, with range [preferred...
Definition: FrameChangeDetector.h:99