OSVR-Core
Namespaces | Enumerations | Functions
cvUtils.h File Reference

Header. More...

#include <BlobExtractor.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <cstdint>
#include <random>
#include <utility>
#include <vector>

Go to the source code of this file.

Namespaces

 osvr
 The main namespace for all C++ elements of the framework, internal and external.
 

Enumerations

enum  { HIERARCHY_NEXT_SIBLING_CONTOUR = 0, HIERARCHY_PREV_SIBLING_CONTOUR = 1, HIERARCHY_FIRST_CHILD_CONTOUR = 2, HIERARCHY_PARENT_CONTOUR = 3 }
 Names for the indices in the hierarchy structure from findContours, so we don't have constants floating around.
 

Functions

cv::Point2f osvr::vbtracker::castPointToFloat (cv::Point2d const &p)
 
void osvr::vbtracker::drawSubpixelPoint (cv::Mat image, cv::Point2d point, cv::Scalar color=cv::Scalar(0, 0, 0), double radius=1., std::uint8_t fractionalBits=3)
 
template<typename F >
cv::Mat osvr::vbtracker::drawFunctorColoredContours (cv::Mat const &baseImage, std::vector< ContourType > const &contours, F &&colorFunc, bool fillContours=false, double centerDotRadius=1.2, bool colorCenterDot=true)
 Draw contours on a copy of the base image (converted to BGR, if required), with each contour a potentially a unique color thanks to functors! If you choose not to fill the contours, the center of each will have a subpixel-accurate circle plotted at it. More...
 
cv::Mat osvr::vbtracker::drawColoredContours (cv::Mat const &baseImage, std::vector< ContourType > const &contours, bool deterministic=true, bool fillContours=false, double centerDotRadius=1.2, bool colorCenterDot=true)
 Draw contours on a copy of the base image (converted to BGR, if required), with each contour a unique color thanks to a Mersenne Twister! If you choose not to fill the contours, the center of each will have a subpixel-accurate circle plotted at it. More...
 
cv::Mat osvr::vbtracker::drawSingleColoredContours (cv::Mat const &baseImage, std::vector< ContourType > const &contours, cv::Scalar color, bool fillContours=false, double centerDotRadius=1.2, bool colorCenterDot=true)
 Draw contours on a copy of the base image (converted to BGR, if required), with all contours the same color. More...
 
template<typename F >
std::vector< ContourType > osvr::vbtracker::getOutsidesOfConnectedComponents (cv::Mat input, F &&additionalPredicate)
 
template<typename F >
void osvr::vbtracker::consumeHolesOfConnectedComponents (cv::InputOutputArray input, std::vector< ContourType > &contoursTempStorage, std::vector< cv::Vec4i > &hierarchyTempStorage, F &&continuation)
 Calls a continuation on every hole of a connected component. More...
 
template<typename F >
void osvr::vbtracker::consumeHolesOfConnectedComponents (cv::InputOutputArray input, F &&continuation)
 Calls a continuation on every hole of a connected component.
 

Detailed Description

Header.

Date
2016
Author
Sensics, Inc. http://sensics.com/osvr

Function Documentation

§ consumeHolesOfConnectedComponents()

template<typename F >
void osvr::vbtracker::consumeHolesOfConnectedComponents ( cv::InputOutputArray  input,
std::vector< ContourType > &  contoursTempStorage,
std::vector< cv::Vec4i > &  hierarchyTempStorage,
F &&  continuation 
)
inline

Calls a continuation on every hole of a connected component.

This version lets you pass your own temporary vectors to reduce/re-use allocations during operation

Loop through the outside connected components.

We want all first-level children of connected components.

§ drawColoredContours()

cv::Mat osvr::vbtracker::drawColoredContours ( cv::Mat const &  baseImage,
std::vector< ContourType > const &  contours,
bool  deterministic = true,
bool  fillContours = false,
double  centerDotRadius = 1.2,
bool  colorCenterDot = true 
)
inline

Draw contours on a copy of the base image (converted to BGR, if required), with each contour a unique color thanks to a Mersenne Twister! If you choose not to fill the contours, the center of each will have a subpixel-accurate circle plotted at it.

Parameters
baseImageImage to have the contours drawn on top of - will not be modified - just cloned.
contoursThe contours you'd like drawn.
deterministicShould we use a deterministic seed?
fillContoursWhether contours should be drawn filled, or just as outlines with a center point plotted (default)
centerDotRadiusRadius, in pixels, of the center dot to plot if fillContours is false.
colorCenterDotWhether the center dots drawn if fillContours is false should match the corresponding contour color (default), or if they should all be black.

Our desired range is a power of two, so we can just mask.

§ drawFunctorColoredContours()

template<typename F >
cv::Mat osvr::vbtracker::drawFunctorColoredContours ( cv::Mat const &  baseImage,
std::vector< ContourType > const &  contours,
F &&  colorFunc,
bool  fillContours = false,
double  centerDotRadius = 1.2,
bool  colorCenterDot = true 
)
inline

Draw contours on a copy of the base image (converted to BGR, if required), with each contour a potentially a unique color thanks to functors! If you choose not to fill the contours, the center of each will have a subpixel-accurate circle plotted at it.

Parameters
baseImageImage to have the contours drawn on top of - will not be modified - just cloned.
contoursThe contours you'd like drawn.
colorFunca callable taking ContourType const &, std::size_t (index) and returning a cv::Scalar color.
fillContoursWhether contours should be drawn filled, or just as outlines with a center point plotted (default)
centerDotRadiusRadius, in pixels, of the center dot to plot if fillContours is false.
colorCenterDotWhether the center dots drawn if fillContours is false should match the corresponding contour color (default), or if they should all be black.

Draw a subpixel-accurate dot in the middle.

§ drawSingleColoredContours()

cv::Mat osvr::vbtracker::drawSingleColoredContours ( cv::Mat const &  baseImage,
std::vector< ContourType > const &  contours,
cv::Scalar  color,
bool  fillContours = false,
double  centerDotRadius = 1.2,
bool  colorCenterDot = true 
)
inline

Draw contours on a copy of the base image (converted to BGR, if required), with all contours the same color.

If you choose not to fill the contours, the center of each will have a subpixel-accurate circle plotted at it.

Parameters
baseImageImage to have the contours drawn on top of - will not be modified - just cloned.
contoursThe contours you'd like drawn.
colorThe color you want the contour drawn.
fillContoursWhether contours should be drawn filled, or just as outlines with a center point plotted (default)
centerDotRadiusRadius, in pixels, of the center dot to plot if fillContours is false.
colorCenterDotWhether the center dots drawn if fillContours is false should match the corresponding contour color (default), or if they should all be black.