TinyRobotics
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
CameraImageDiff Class Reference

Computes pixel-wise differences between consecutive grayscale camera images. More...

#include <CameraImageDiff.h>

Public Member Functions

void process (const uint8_t *image, size_t width, size_t height)
 
void threshold (uint8_t thresh)
 Simple thresholding: convert difference to binary mask.
 
uint32_t countChanges ()
 Count number of pixels above threshold.
 
std::tuple< uint32_t, uint32_t, uint32_t > countChangesSplitVertical ()
 
std::tuple< uint32_t, uint32_t, uint32_t > countChangesSplitHorizontal ()
 
void end ()
 
int getWidth () const
 
int getHeight () const
 
int getPixelCount () const
 
uint8_t * getDiff ()
 

Protected Attributes

int width_ = 0
 
int height_ = 0
 
std::vector< uint8_t, AllocatorPSRAM< uint8_t > > prevImage_
 
std::vector< uint8_t, AllocatorPSRAM< uint8_t > > diff_
 
std::vector< uint8_t, AllocatorPSRAM< uint8_t > > mask_
 

Detailed Description

Computes pixel-wise differences between consecutive grayscale camera images.

This class is designed for simple motion or change detection in a sequence of grayscale images. It calculates the absolute difference between the current and previous image, applies a threshold, and provides methods to count the number of changed pixels globally or in image regions.

Features:

Usage Example:

diff.process(image, width, height);
diff.threshold(30);
uint32_t changed = diff.countChanges();
auto [left, center, right] = diff.countChangesSplitVertical();
auto [top, center, bottom] = diff.countChangesSplitHorizontal();
Computes pixel-wise differences between consecutive grayscale camera images.
Definition: CameraImageDiff.h:41
std::tuple< uint32_t, uint32_t, uint32_t > countChangesSplitVertical()
Definition: CameraImageDiff.h:77
uint32_t countChanges()
Count number of pixels above threshold.
Definition: CameraImageDiff.h:65
std::tuple< uint32_t, uint32_t, uint32_t > countChangesSplitHorizontal()
Definition: CameraImageDiff.h:102
void threshold(uint8_t thresh)
Simple thresholding: convert difference to binary mask.
Definition: CameraImageDiff.h:57

Member Function Documentation

◆ countChangesSplitHorizontal()

std::tuple< uint32_t, uint32_t, uint32_t > countChangesSplitHorizontal ( )
inline

Count number of changed pixels in top, center, and bottom thirds of the image.

Returns
std::tuple<uint32_t, uint32_t, uint32_t> (top, center, bottom)

◆ countChangesSplitVertical()

std::tuple< uint32_t, uint32_t, uint32_t > countChangesSplitVertical ( )
inline

Count number of changed pixels in left, center, and right thirds of the image.

Returns
std::tuple<uint32_t, uint32_t, uint32_t> (left, center, right)

◆ getDiff()

uint8_t * getDiff ( )
inline

Provides the raw difference buffer (grayscale values 0–255) for external use or debugging.


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