VisionServer  v2.1.1-1-g21dc5465
FRC vision library
vision.h File Reference
#include <type_traits>
#include <algorithm>
#include <vector>
#include <array>
#include <opencv2/core/types.hpp>
#include <networktables/NetworkTableInstance.h>
#include <networktables/NetworkTable.h>
#include <cameraserver/CameraServer.h>
#include <wpi/StringExtras.h>
#include "visioncamera.h"
+ Include dependency graph for vision.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

cv::Size getResolution (cs::VideoMode vm)
 
cs::VideoMode getJsonVideoMode (const wpi::json &config)
 
template<typename num_t , typename dnum_t >
static cv::Size_< num_t > operator/ (cv::Size_< num_t > input, dnum_t scale)
 
template<typename num_t >
bool inRange (num_t a, num_t lower, num_t upper)
 
template<typename t >
void reinsert (std::vector< t > &vec, size_t idx)
 
template<typename t >
void swapIdx (std::vector< t > &vec, size_t idx1, size_t idx2)
 
template<typename num_t >
int sgn (num_t val)
 
template<typename num_t >
cv::Size_< num_t > distance (const cv::Point_< num_t > &a, const cv::Point_< num_t > &b)
 
template<typename num_t >
cv::Point3_< num_t > distance (const cv::Point3_< num_t > &a, const cv::Point3_< num_t > &b)
 
template<typename num_t >
bool operator< (const cv::Size_< num_t > &a, const cv::Size_< num_t > &b)
 
template<typename num_t >
bool operator<= (const cv::Size_< num_t > &a, const cv::Size_< num_t > &b)
 
template<typename num_t >
bool operator> (const cv::Size_< num_t > &a, const cv::Size_< num_t > &b)
 
template<typename num_t >
bool operator>= (const cv::Size_< num_t > &a, const cv::Size_< num_t > &b)
 
template<typename num_t >
cv::Point_< num_t > operator- (const cv::Point_< num_t > &a, const cv::Size_< num_t > &b)
 
template<typename num_t >
cv::Point_< num_t > operator+ (const cv::Point_< num_t > &a, const cv::Size_< num_t > &b)
 
template<typename num_t >
cv::Size_< num_t > operator- (const cv::Size_< num_t > &a, const cv::Point_< num_t > &b)
 
template<typename num_t >
cv::Size_< num_t > operator+ (const cv::Size_< num_t > &a, const cv::Point_< num_t > &b)
 
template<typename inum1_t , typename inum2_t , typename onum_t >
cv::Size_< onum_t > operator/ (const cv::Size_< inum1_t > &a, const cv::Size_< inum2_t > &b)
 
template<typename num_t >
void operator-= (const cv::Point_< num_t > &a, const cv::Size_< num_t > &b)
 
template<typename num_t >
void operator+= (const cv::Point_< num_t > &a, const cv::Size_< num_t > &b)
 
template<typename num_t >
void operator-= (const cv::Size_< num_t > &a, const cv::Point_< num_t > &b)
 
template<typename num_t >
void operator+= (const cv::Size_< num_t > &a, const cv::Point_< num_t > &b)
 
template<typename num_t >
void rescale (std::vector< cv::Point_< num_t > > &points, size_t scale)
 
template<typename num_t >
void _rescale (std::vector< cv::Point_< num_t > > &points, size_t scale)
 
template<typename num_t >
void rescale (std::vector< cv::Point_< num_t > > &points, double scale)
 
template<typename num_t >
void rescale (std::vector< std::vector< cv::Point_< num_t > > > &contours, double scale)
 
template<typename num_t >
void rescale (std::vector< cv::Rect_< num_t > > &rects, double scale)
 
template<typename num_t >
cv::Point_< num_t > findCenter (const std::vector< cv::Point_< num_t > > &contour)
 
template<typename onum_t , typename inum_t >
cv::Point_< onum_t > findCenter (const std::vector< cv::Point_< inum_t > > &contour)
 
template<typename num_t >
cv::Point3_< num_t > findCenter3D (const std::vector< cv::Point3_< num_t > > &contour)
 
template<typename onum_t , typename inum_t >
cv::Point3_< onum_t > findCenter3D (const std::vector< cv::Point3_< inum_t > > &contour)
 
template<typename num_t >
cv::Point_< num_t > findCenter (const cv::Rect_< num_t > &rect)
 
template<typename onum_t , typename inum_t >
cv::Point_< onum_t > findCenter (const cv::Rect_< inum_t > &rect)
 
template<typename num_t >
void reorderClockWise (std::vector< cv::Point_< num_t > > &points)
 
template<typename num_t >
void reorderCClockWise (std::vector< cv::Point_< num_t > > &points)
 
template<typename num_t , size_t s>
std::array< cv::Point3_< num_t >, s > operator+ (const std::array< cv::Point_< num_t >, s > &base, num_t depth)
 
template<typename num_t , size_t s>
std::array< cv::Point3_< num_t >, s > operator+ (const std::array< cv::Point3_< num_t >, s > &base, num_t depth)
 
template<typename num_t , size_t s>
void operator+= (std::array< cv::Point3_< num_t >, s > &base, num_t depth)
 
template<typename num_t >
std::vector< cv::Point3_< num_t > > operator+ (const std::vector< cv::Point_< num_t > > &base, num_t depth)
 
template<typename num_t >
std::vector< cv::Point3_< num_t > > operator+ (const std::vector< cv::Point3_< num_t > > &base, num_t depth)
 
template<typename num_t >
void operator+= (std::vector< cv::Point3_< num_t > > &base, num_t depth)
 

Variables

template<typename num_t , size_t s>
const auto extend_array = operator+=<num_t, s>
 
template<typename num_t >
const auto extend_vector = operator+=<num_t>
 

Function Documentation

◆ getResolution()

cv::Size getResolution ( cs::VideoMode  vm)
inline

This file contains vision-related helper functions used throughout the framework Starts a stream and creates a networktable value for changing which camera is streamed

Parameters
camerasA vector of VisionCameras to be used
tableA networktable in which to put the camera index entries
Returns
A cs::CvSink which is is the source for the stream Extracts the height and width of a cs::VideoMode object and converts to cv::Size
Parameters
vmThe cs::VideoMode object to get resolution from
Returns
The resolutuion in cv::Size format

Definition at line 38 of file vision.h.

◆ getJsonVideoMode()

cs::VideoMode getJsonVideoMode ( const wpi::json &  config)

Extracts videomode properties from a config json - 0-values returned if config is invalid

Returns
The VideoMode object

Definition at line 32 of file vision.cpp.

◆ operator/() [1/2]

template<typename num_t , typename dnum_t >
static cv::Size_< num_t > operator/ ( cv::Size_< num_t >  input,
dnum_t  scale 
)
inlinestatic

Adds a networktable entry to the provided networktable with a listener that will update the variable to match the networktable entry

Parameters
num_tAny numeric type - does not need to be explicitly provided
varA reference to the numeric variable
nameThe name of the entry
tableThe root networktable Adds a networktable entry to the provided networktable with a listener that will update the variable to match the networktable entry
varA reference to the boolean variable
nameThe name of the entry
tableThe root networktable Divides a both parts of a cv::Size object by the specified scale
num_tThe numberic type used in the cv::Size input (and function output) - does not need to be explicitly provided
dnum_tThe numberic type used for the devisor
inputThe input size
scaleThe amount to be divided by
Returns
A new cv::Size representing the division

Definition at line 72 of file vision.h.

◆ inRange()

template<typename num_t >
bool inRange ( num_t  a,
num_t  lower,
num_t  upper 
)
inline

Definition at line 84 of file vision.h.

◆ reinsert()

template<typename t >
void reinsert ( std::vector< t > &  vec,
size_t  idx 
)

Definition at line 91 of file vision.h.

◆ swapIdx()

template<typename t >
void swapIdx ( std::vector< t > &  vec,
size_t  idx1,
size_t  idx2 
)
inline

Definition at line 96 of file vision.h.

◆ sgn()

template<typename num_t >
int sgn ( num_t  val)
inline

Definition at line 101 of file vision.h.

◆ distance() [1/2]

template<typename num_t >
cv::Size_< num_t > distance ( const cv::Point_< num_t > &  a,
const cv::Point_< num_t > &  b 
)
inline

Definition at line 104 of file vision.h.

◆ distance() [2/2]

template<typename num_t >
cv::Point3_< num_t > distance ( const cv::Point3_< num_t > &  a,
const cv::Point3_< num_t > &  b 
)
inline

Definition at line 109 of file vision.h.

◆ operator<()

template<typename num_t >
bool operator< ( const cv::Size_< num_t > &  a,
const cv::Size_< num_t > &  b 
)
inline

Definition at line 115 of file vision.h.

◆ operator<=()

template<typename num_t >
bool operator<= ( const cv::Size_< num_t > &  a,
const cv::Size_< num_t > &  b 
)
inline

Definition at line 120 of file vision.h.

◆ operator>()

template<typename num_t >
bool operator> ( const cv::Size_< num_t > &  a,
const cv::Size_< num_t > &  b 
)
inline

Definition at line 125 of file vision.h.

◆ operator>=()

template<typename num_t >
bool operator>= ( const cv::Size_< num_t > &  a,
const cv::Size_< num_t > &  b 
)
inline

Definition at line 130 of file vision.h.

◆ operator-() [1/2]

template<typename num_t >
cv::Point_< num_t > operator- ( const cv::Point_< num_t > &  a,
const cv::Size_< num_t > &  b 
)
inline

Definition at line 136 of file vision.h.

◆ operator+() [1/6]

template<typename num_t >
cv::Point_< num_t > operator+ ( const cv::Point_< num_t > &  a,
const cv::Size_< num_t > &  b 
)
inline

Definition at line 141 of file vision.h.

◆ operator-() [2/2]

template<typename num_t >
cv::Size_< num_t > operator- ( const cv::Size_< num_t > &  a,
const cv::Point_< num_t > &  b 
)
inline

Definition at line 146 of file vision.h.

◆ operator+() [2/6]

template<typename num_t >
cv::Size_< num_t > operator+ ( const cv::Size_< num_t > &  a,
const cv::Point_< num_t > &  b 
)
inline

Definition at line 151 of file vision.h.

◆ operator/() [2/2]

template<typename inum1_t , typename inum2_t , typename onum_t >
cv::Size_< onum_t > operator/ ( const cv::Size_< inum1_t > &  a,
const cv::Size_< inum2_t > &  b 
)
inline

Definition at line 157 of file vision.h.

◆ operator-=() [1/2]

template<typename num_t >
void operator-= ( const cv::Point_< num_t > &  a,
const cv::Size_< num_t > &  b 
)

◆ operator+=() [1/4]

template<typename num_t >
void operator+= ( const cv::Point_< num_t > &  a,
const cv::Size_< num_t > &  b 
)

◆ operator-=() [2/2]

template<typename num_t >
void operator-= ( const cv::Size_< num_t > &  a,
const cv::Point_< num_t > &  b 
)

◆ operator+=() [2/4]

template<typename num_t >
void operator+= ( const cv::Size_< num_t > &  a,
const cv::Point_< num_t > &  b 
)

◆ rescale() [1/4]

template<typename num_t >
void rescale ( std::vector< cv::Point_< num_t > > &  points,
size_t  scale 
)

vision.inc

Definition at line 250 of file vision.h.

◆ _rescale()

template<typename num_t >
void _rescale ( std::vector< cv::Point_< num_t > > &  points,
size_t  scale 
)

Definition at line 257 of file vision.h.

◆ rescale() [2/4]

template<typename num_t >
void rescale ( std::vector< cv::Point_< num_t > > &  points,
double  scale 
)

Definition at line 264 of file vision.h.

◆ rescale() [3/4]

template<typename num_t >
void rescale ( std::vector< std::vector< cv::Point_< num_t > > > &  contours,
double  scale 
)

Definition at line 271 of file vision.h.

◆ rescale() [4/4]

template<typename num_t >
void rescale ( std::vector< cv::Rect_< num_t > > &  rects,
double  scale 
)

Definition at line 280 of file vision.h.

◆ findCenter() [1/4]

template<typename num_t >
cv::Point_< num_t > findCenter ( const std::vector< cv::Point_< num_t > > &  contour)

Definition at line 291 of file vision.h.

◆ findCenter() [2/4]

template<typename onum_t , typename inum_t >
cv::Point_< onum_t > findCenter ( const std::vector< cv::Point_< inum_t > > &  contour)

Definition at line 306 of file vision.h.

◆ findCenter3D() [1/2]

template<typename num_t >
cv::Point3_< num_t > findCenter3D ( const std::vector< cv::Point3_< num_t > > &  contour)

Definition at line 322 of file vision.h.

◆ findCenter3D() [2/2]

template<typename onum_t , typename inum_t >
cv::Point3_< onum_t > findCenter3D ( const std::vector< cv::Point3_< inum_t > > &  contour)

Definition at line 339 of file vision.h.

◆ findCenter() [3/4]

template<typename num_t >
cv::Point_< num_t > findCenter ( const cv::Rect_< num_t > &  rect)

Definition at line 358 of file vision.h.

◆ findCenter() [4/4]

template<typename onum_t , typename inum_t >
cv::Point_< onum_t > findCenter ( const cv::Rect_< inum_t > &  rect)

Definition at line 368 of file vision.h.

◆ reorderClockWise()

template<typename num_t >
void reorderClockWise ( std::vector< cv::Point_< num_t > > &  points)

Definition at line 380 of file vision.h.

◆ reorderCClockWise()

template<typename num_t >
void reorderCClockWise ( std::vector< cv::Point_< num_t > > &  points)

Definition at line 394 of file vision.h.

◆ operator+() [3/6]

template<typename num_t , size_t s>
std::array< cv::Point3_< num_t >, s > operator+ ( const std::array< cv::Point_< num_t >, s > &  base,
num_t  depth 
)

Definition at line 409 of file vision.h.

◆ operator+() [4/6]

template<typename num_t , size_t s>
std::array< cv::Point3_< num_t >, s > operator+ ( const std::array< cv::Point3_< num_t >, s > &  base,
num_t  depth 
)

Definition at line 418 of file vision.h.

◆ operator+=() [3/4]

template<typename num_t , size_t s>
void operator+= ( std::array< cv::Point3_< num_t >, s > &  base,
num_t  depth 
)

Definition at line 427 of file vision.h.

◆ operator+() [5/6]

template<typename num_t >
std::vector< cv::Point3_< num_t > > operator+ ( const std::vector< cv::Point_< num_t > > &  base,
num_t  depth 
)

Definition at line 434 of file vision.h.

◆ operator+() [6/6]

template<typename num_t >
std::vector< cv::Point3_< num_t > > operator+ ( const std::vector< cv::Point3_< num_t > > &  base,
num_t  depth 
)

Definition at line 443 of file vision.h.

◆ operator+=() [4/4]

template<typename num_t >
void operator+= ( std::vector< cv::Point3_< num_t > > &  base,
num_t  depth 
)

Definition at line 452 of file vision.h.

Variable Documentation

◆ extend_array

template<typename num_t , size_t s>
const auto extend_array = operator+=<num_t, s>

Definition at line 217 of file vision.h.

◆ extend_vector

template<typename num_t >
const auto extend_vector = operator+=<num_t>

Definition at line 219 of file vision.h.