PiImageStreamer
Loading...
Searching...
No Matches
SWE4211RPi::ContourOverlay Class Reference

#include <ContourOverlay.h>

Inheritance diagram for SWE4211RPi::ContourOverlay:
Collaboration diagram for SWE4211RPi::ContourOverlay:

Public Member Functions

 ContourOverlay (std::vector< std::vector< cv::Point > > contour, cv::Scalar color, cv::Size baseImageSize)
 
virtual ~ContourOverlay ()
 
void applyOverlay (cv::Mat *image)
 
void applyScaledOverlay (cv::Mat *image)
 
- Public Member Functions inherited from SWE4211RPi::AbstractImageOverlay
 AbstractImageOverlay ()
 
virtual ~AbstractImageOverlay ()
 
long getOverlaySerialNumber ()
 

Private Attributes

std::vector< std::vector< cv::Point > > contour
 
std::vector< std::vector< cv::Point > > scaledContour
 
cv::Size baseImageSize
 
cv::Size scaledContourSize
 
cv::Scalar color
 

Detailed Description

This class is an overlay that draws a set of contours onto an image.

Constructor & Destructor Documentation

◆ ContourOverlay()

ContourOverlay::ContourOverlay ( std::vector< std::vector< cv::Point > >  contour,
cv::Scalar  color,
cv::Size  baseImageSize 
)

This will construct a new contour overlay.

Parameters
contourThese are the contours to draw, in the coordinates of the base image.
colorThis is the color that the contours are to be drawn in.
baseImageSizeThis is the size of the image that the contours were found in.

◆ ~ContourOverlay()

ContourOverlay::~ContourOverlay ( )
virtual

This is the destructor for the class.

This is the destructor for the class. The base class destructor is called automatically after this one, so it must not be called explicitly here.

Member Function Documentation

◆ applyOverlay()

void ContourOverlay::applyOverlay ( cv::Mat *  image)
virtual

This method will draw the contours onto the given image, using their original coordinates.

Parameters
imageThis is the image that the contours are to be drawn on.

Implements SWE4211RPi::AbstractImageOverlay.

◆ applyScaledOverlay()

void ContourOverlay::applyScaledOverlay ( cv::Mat *  image)
virtual

This method will draw the contours onto the given image, scaling them to match the size of the image.

Parameters
imageThis is the image that the contours are to be drawn on.

This method will draw the contours onto the given image, scaling them to match the size of the image. The scaled contours are kept, so the scaling is only redone when the image size changes.

Parameters
imageThis is the image that the contours are to be drawn on.
  1. If the contours have not yet been scaled, or the image is a different size than they were last scaled for,

    1. Clear out the previously scaled contours.

    2. Determine the scale factors from the base image size to this image's size.

    3. Scale each point of each contour, rounding to the nearest pixel.

    4. Remember the size the contours were scaled for.

  2. Draw all of the scaled contours onto the image with a line thickness of 3.

Implements SWE4211RPi::AbstractImageOverlay.

Member Data Documentation

◆ baseImageSize

cv::Size SWE4211RPi::ContourOverlay::baseImageSize
private

This is the size of the image that the contours were found in.

◆ color

cv::Scalar SWE4211RPi::ContourOverlay::color
private

This is the color that the contours are drawn in.

◆ contour

std::vector<std::vector<cv::Point> > SWE4211RPi::ContourOverlay::contour
private

These are the contours to draw, in the coordinates of the base image. Each contour is a list of points.

◆ scaledContour

std::vector<std::vector<cv::Point> > SWE4211RPi::ContourOverlay::scaledContour
private

These are the contours scaled to the size of the image they were last drawn on. They are kept so that the scaling only needs to be redone when the image size changes.

◆ scaledContourSize

cv::Size SWE4211RPi::ContourOverlay::scaledContourSize
private

This is the size of the image that scaledContour has been scaled to.


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