OpenCV conversions library¶
OpenCV is one of most frequently used C++ libraries in computer vision. This support library provides conversion functions so that protocol image and region objects can be quickly converted to corresponding OpenCV objects and vice-versa.
Requirements and building¶
To compile the module you have to enable the BUILD_OPENCV
flag in CMake build system (check out the tutorial on compiling the project for more details). You will of course need OpenCV library available on the system, version 2.4 or higher is supported.
Documentation¶
-
cv::Mat
image_to_mat
(const Image &image)¶ Converts a protocol image object to an OpenCV matrix that represents the image.
Parameters: image – Protocol image object Returns: OpenCV matrix object
-
cv::Rect
region_to_rect
(const Region ®ion)¶ Converts a protocol region object to an OpenCV rectangle structure.
Parameters: image – Protocol region object Returns: OpenCV rectangle structure
-
std::vector<cv::Point2f>
region_to_points
(const Region ®ion)¶ Converts a protocol region object to a list of OpenCV points.
Parameters: image – Protocol region object Returns: List of points
-
Image
mat_to_image
(const cv::Mat &mat)¶ Converts an OpenCV matrix to a new protocol image object.
Parameters: mat – OpenCV image Returns: Protocol image object
-
Region
rect_to_region
(const cv::Rect rect)¶ Converts an OpenCV rectangle structure to a protocol region object of type rectangle.
Parameters: rect – Rectangle structure Returns: Protocol region object
-
Region
points_to_region
(const std::vector<cv::Point2f> points)¶ Converts a list of OpenCV points to a protocol region object of type polygon.
Parameters: rect – List of points Returns: Protocol region object
-
void
draw_region
(cv::Mat &canvas, const Region ®ion, cv::Scalar color, int width = 1)¶ Draws a given region to an OpenCV image with a given color and line width.
Parameters: - canvas – Target OpenCV image to which the region is drawn
- region – Protocol region object
- color – Color of the line as a an OpenCV scalar structure
- width – Width of the line