libVision  1.0
A vision library made by FRC team #4529
Public Member Functions | Public Attributes | List of all members
TargetDetector Class Reference

Vision processing/target acquisition code. More...

#include <TargetDetector.h>

Public Member Functions

 TargetDetector (Mat &_image)
 TargetDetector constructor. More...
 
virtual ~TargetDetector ()
 TargetDetector destructor.
 
void prepareImage ()
 Prepare/threshold input frame. More...
 
void findContours ()
 Cleans old data and prepares contour shells via OpenCV. More...
 
bool filterContours ()
 Filter contours to find shells that match the target. More...
 
LineResult getContours ()
 Process and retrieve resulting contours. More...
 

Public Attributes

int thresholdVal
 Threshold value for cuttoff when running prepareImage. More...
 

Detailed Description

Vision processing/target acquisition code.

Order of calling:

  1. prepareImage()
  2. findContours()
  3. filterContours()
  4. getContours()

Constructor & Destructor Documentation

TargetDetector::TargetDetector ( Mat &  _image)

TargetDetector constructor.

Parameters
_imageReference to source cv::Mat for processing

Member Function Documentation

bool TargetDetector::filterContours ( )

Filter contours to find shells that match the target.

Filters through the found contours, leaving only the contours that match the target.

Returns
bool Whether or not you will be able to reliably get contours, according to the number of shells found.
void TargetDetector::findContours ( )

Cleans old data and prepares contour shells via OpenCV.

Clears data from previous the frame, finds contours in the binary image and decimate the found shells.

LineResult TargetDetector::getContours ( )

Process and retrieve resulting contours.

Processes filtered contours, returning more specific information about the found target.

Returns
LineResult contour data
Note
If this was run already on the current frame, it will instantly return the previous result.
Warning
If there was an issue with the frame, it will return instantly with LineResult::isProcessed being false, and all other values being old or random data.
In this case, you MUST close and attempt to re-open the camera or feed to be able to get a good frame again.
You will NOT be able to get any more data otherwise.
void TargetDetector::prepareImage ( )

Prepare/threshold input frame.

Note
Must be called before running other functions.

Member Data Documentation

int TargetDetector::thresholdVal

Threshold value for cuttoff when running prepareImage.

Set by setThreshold().

Note
Defaults to 234.

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