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

Simple line-following algorithm for grayscale camera images. More...

#include <CameraLineFollower.h>

Inheritance diagram for CameraLineFollower:
Inheritance graph
[legend]
Collaboration diagram for CameraLineFollower:
Collaboration graph
[legend]

Classes

struct  Result
 

Public Member Functions

 CameraLineFollower (uint8_t threshold=80, int minWidth=3)
 
Result process (const uint8_t *image, size_t width, size_t height)
 
- Public Member Functions inherited from MessageSource
void subscribe (MessageHandler &handler, MessageOrigin origin=MessageOrigin::Undefined, MessageContent content=MessageContent::Undefined)
 Subscribe a message handler to this source, with optional filtering.
 
void unsubscribeAll ()
 Remove all registered message handlers.
 
void sendMessage (Message< float > &msg)
 Publish a message to all registered handlers.
 
void sendMessage (const Message< Coordinate< float > > &msg)
 Publish a message to all registered handlers.
 
void sendMessage (const Message< GPSCoordinate > &msg)
 Publish a message to all registered handlers.
 
void sendMessage (const Message< MotionState3D > &msg)
 Overload for MotionState3D messages.
 

Protected Attributes

uint8_t _threshold
 
int _minWidth
 
int _lastPosition
 
- Protected Attributes inherited from MessageSource
std::vector< MessageHandlerEntrymessageHandlers_
 

Detailed Description

Simple line-following algorithm for grayscale camera images.

This class scans a horizontal row of a grayscale image (e.g., from a camera or line sensor) to detect the center of the widest dark line (such as a tape or path on the floor). It is useful for basic line-following robots.

Features:

Note
Expected format:
  • The input image should be a grayscale buffer (uint8_t*)
  • The pixel intensity is expected to be in the range 0 (black) to 255 (white).
  • The layout of the image buffer should be row-major (i.e., pixel at (x,y) is at index y*width + x).
  • on ESP32 e.g. PIXFORMAT_GRAYSCALE, FRAMESIZE_QVGA (320 x 240)

Usage Example:

CameraLineFollower follower(80, 5); // threshold=80, minWidth=5
auto result = follower.process(image, width, height);
if (result.found) {
// Use result.position or result.error for steering
}
Simple line-following algorithm for grayscale camera images.
Definition: CameraLineFollower.h:44

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