mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #18292 from smirnov-alexey:as/osd_serialization
[G-API]: Support render primitives serialization * Add GOpaque and GArray serialization support * Address review comments * Remove holds() method * Add serialization mechanism for render primitives * Fix standalone mode * Fix wchar_t error on win64 * Fix assert on windows * Address review comments * Fix GArray and GOpaque reset() method to store proper kind * Reset wchar before deserializing it * Fix wchar_t cross-platform issue * Address review comments * Fix wchar_t serialization and tests * Remove FText serialization
This commit is contained in:
@@ -261,8 +261,8 @@ namespace detail
|
||||
template<typename T> void reset()
|
||||
{
|
||||
if (!m_ref) m_ref.reset(new VectorRefT<T>());
|
||||
|
||||
check<T>();
|
||||
storeKind<T>();
|
||||
static_cast<VectorRefT<T>&>(*m_ref).reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <opencv2/gapi/util/optional.hpp>
|
||||
#include <opencv2/gapi/own/exports.hpp>
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
#include <opencv2/gapi/render/render_types.hpp>
|
||||
|
||||
namespace cv {
|
||||
|
||||
@@ -48,6 +49,7 @@ namespace detail
|
||||
CV_RECT, // cv::Rect user G-API data
|
||||
CV_SCALAR, // cv::Scalar user G-API data
|
||||
CV_MAT, // cv::Mat user G-API data
|
||||
CV_PRIM, // cv::gapi::wip::draw::Prim user G-API data
|
||||
};
|
||||
|
||||
// Type traits helper which simplifies the extraction of kind from type
|
||||
@@ -62,10 +64,12 @@ namespace detail
|
||||
template<> struct GOpaqueTraits<cv::Mat> { static constexpr const OpaqueKind kind = OpaqueKind::CV_MAT; };
|
||||
template<> struct GOpaqueTraits<cv::Rect> { static constexpr const OpaqueKind kind = OpaqueKind::CV_RECT; };
|
||||
template<> struct GOpaqueTraits<cv::GMat> { static constexpr const OpaqueKind kind = OpaqueKind::CV_MAT; };
|
||||
template<> struct GOpaqueTraits<cv::gapi::wip::draw::Prim>
|
||||
{ static constexpr const OpaqueKind kind = OpaqueKind::CV_PRIM; };
|
||||
// GArray is not supporting bool type for now due to difference in std::vector<bool> implementation
|
||||
using GOpaqueTraitsArrayTypes = std::tuple<int, double, cv::Size, cv::Scalar, cv::Point, cv::Mat, cv::Rect>;
|
||||
using GOpaqueTraitsArrayTypes = std::tuple<int, double, cv::Size, cv::Scalar, cv::Point, cv::Mat, cv::Rect, cv::gapi::wip::draw::Prim>;
|
||||
// GOpaque is not supporting cv::Mat and cv::Scalar since there are GScalar and GMat types
|
||||
using GOpaqueTraitsOpaqueTypes = std::tuple<bool, int, double, cv::Size, cv::Point, cv::Rect>;
|
||||
using GOpaqueTraitsOpaqueTypes = std::tuple<bool, int, double, cv::Size, cv::Point, cv::Rect, cv::gapi::wip::draw::Prim>;
|
||||
} // namespace detail
|
||||
|
||||
// This definition is here because it is reused by both public(?) and internal
|
||||
|
||||
@@ -250,8 +250,8 @@ namespace detail
|
||||
template<typename T> void reset()
|
||||
{
|
||||
if (!m_ref) m_ref.reset(new OpaqueRefT<T>());
|
||||
|
||||
check<T>();
|
||||
storeKind<T>();
|
||||
static_cast<OpaqueRefT<T>&>(*m_ref).reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,23 +2,16 @@
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// Copyright (C) 2018-2020 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_RENDER_HPP
|
||||
#define OPENCV_GAPI_RENDER_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <opencv2/gapi/render/render_types.hpp>
|
||||
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <opencv2/gapi.hpp>
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/util/variant.hpp>
|
||||
#include <opencv2/gapi/own/exports.hpp>
|
||||
|
||||
|
||||
/** \defgroup gapi_draw G-API Drawing and composition functionality
|
||||
* @{
|
||||
*
|
||||
@@ -77,309 +70,9 @@ namespace wip
|
||||
namespace draw
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief This structure specifies which FreeType font to use by FText primitives.
|
||||
*/
|
||||
struct freetype_font
|
||||
{
|
||||
/*@{*/
|
||||
std::string path; //!< The path to the font file (.ttf)
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
//! @addtogroup gapi_draw_prims
|
||||
//! @{
|
||||
/**
|
||||
* @brief This structure represents a text string to draw.
|
||||
*
|
||||
* Parameters match cv::putText().
|
||||
*/
|
||||
struct Text
|
||||
{
|
||||
/**
|
||||
* @brief Text constructor
|
||||
*
|
||||
* @param text_ The text string to be drawn
|
||||
* @param org_ The bottom-left corner of the text string in the image
|
||||
* @param ff_ The font type, see #HersheyFonts
|
||||
* @param fs_ The font scale factor that is multiplied by the font-specific base size
|
||||
* @param color_ The text color
|
||||
* @param thick_ The thickness of the lines used to draw a text
|
||||
* @param lt_ The line type. See #LineTypes
|
||||
* @param bottom_left_origin_ When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner
|
||||
*/
|
||||
Text(const std::string& text_,
|
||||
const cv::Point& org_,
|
||||
int ff_,
|
||||
double fs_,
|
||||
const cv::Scalar& color_,
|
||||
int thick_ = 1,
|
||||
int lt_ = cv::LINE_8,
|
||||
bool bottom_left_origin_ = false) :
|
||||
text(text_), org(org_), ff(ff_), fs(fs_),
|
||||
color(color_), thick(thick_), lt(lt_), bottom_left_origin(bottom_left_origin_)
|
||||
{
|
||||
}
|
||||
|
||||
/*@{*/
|
||||
std::string text; //!< The text string to be drawn
|
||||
cv::Point org; //!< The bottom-left corner of the text string in the image
|
||||
int ff; //!< The font type, see #HersheyFonts
|
||||
double fs; //!< The font scale factor that is multiplied by the font-specific base size
|
||||
cv::Scalar color; //!< The text color
|
||||
int thick; //!< The thickness of the lines used to draw a text
|
||||
int lt; //!< The line type. See #LineTypes
|
||||
bool bottom_left_origin; //!< When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents a text string to draw using
|
||||
* FreeType renderer.
|
||||
*
|
||||
* If OpenCV is built without FreeType support, this primitive will
|
||||
* fail at the execution stage.
|
||||
*/
|
||||
struct FText
|
||||
{
|
||||
/**
|
||||
* @brief FText constructor
|
||||
*
|
||||
* @param text_ The text string to be drawn
|
||||
* @param org_ The bottom-left corner of the text string in the image
|
||||
* @param fh_ The height of text
|
||||
* @param color_ The text color
|
||||
*/
|
||||
FText(const std::wstring& text_,
|
||||
const cv::Point& org_,
|
||||
int fh_,
|
||||
const cv::Scalar& color_) :
|
||||
text(text_), org(org_), fh(fh_), color(color_)
|
||||
{
|
||||
}
|
||||
|
||||
/*@{*/
|
||||
std::wstring text; //!< The text string to be drawn
|
||||
cv::Point org; //!< The bottom-left corner of the text string in the image
|
||||
int fh; //!< The height of text
|
||||
cv::Scalar color; //!< The text color
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents a rectangle to draw.
|
||||
*
|
||||
* Parameters match cv::rectangle().
|
||||
*/
|
||||
struct Rect
|
||||
{
|
||||
/**
|
||||
* @brief Rect constructor
|
||||
*
|
||||
* @param rect_ Coordinates of the rectangle
|
||||
* @param color_ The bottom-left corner of the text string in the image
|
||||
* @param thick_ The thickness of lines that make up the rectangle. Negative values, like #FILLED, mean that the function has to draw a filled rectangle
|
||||
* @param lt_ The type of the line. See #LineTypes
|
||||
* @param shift_ The number of fractional bits in the point coordinates
|
||||
*/
|
||||
Rect(const cv::Rect& rect_,
|
||||
const cv::Scalar& color_,
|
||||
int thick_ = 1,
|
||||
int lt_ = cv::LINE_8,
|
||||
int shift_ = 0) :
|
||||
rect(rect_), color(color_), thick(thick_), lt(lt_), shift(shift_)
|
||||
{
|
||||
}
|
||||
|
||||
/*@{*/
|
||||
cv::Rect rect; //!< Coordinates of the rectangle
|
||||
cv::Scalar color; //!< The rectangle color or brightness (grayscale image)
|
||||
int thick; //!< The thickness of lines that make up the rectangle. Negative values, like #FILLED, mean that the function has to draw a filled rectangle
|
||||
int lt; //!< The type of the line. See #LineTypes
|
||||
int shift; //!< The number of fractional bits in the point coordinates
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents a circle to draw.
|
||||
*
|
||||
* Parameters match cv::circle().
|
||||
*/
|
||||
struct Circle
|
||||
{
|
||||
/**
|
||||
* @brief Circle constructor
|
||||
*
|
||||
* @param center_ The center of the circle
|
||||
* @param radius_ The radius of the circle
|
||||
* @param color_ The color of the circle
|
||||
* @param thick_ The thickness of the circle outline, if positive. Negative values, like #FILLED, mean that a filled circle is to be drawn
|
||||
* @param lt_ The Type of the circle boundary. See #LineTypes
|
||||
* @param shift_ The Number of fractional bits in the coordinates of the center and in the radius value
|
||||
*/
|
||||
Circle(const cv::Point& center_,
|
||||
int radius_,
|
||||
const cv::Scalar& color_,
|
||||
int thick_ = 1,
|
||||
int lt_ = cv::LINE_8,
|
||||
int shift_ = 0) :
|
||||
center(center_), radius(radius_), color(color_), thick(thick_), lt(lt_), shift(shift_)
|
||||
{
|
||||
}
|
||||
|
||||
/*@{*/
|
||||
cv::Point center; //!< The center of the circle
|
||||
int radius; //!< The radius of the circle
|
||||
cv::Scalar color; //!< The color of the circle
|
||||
int thick; //!< The thickness of the circle outline, if positive. Negative values, like #FILLED, mean that a filled circle is to be drawn
|
||||
int lt; //!< The Type of the circle boundary. See #LineTypes
|
||||
int shift; //!< The Number of fractional bits in the coordinates of the center and in the radius value
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents a line to draw.
|
||||
*
|
||||
* Parameters match cv::line().
|
||||
*/
|
||||
struct Line
|
||||
{
|
||||
/**
|
||||
* @brief Line constructor
|
||||
*
|
||||
* @param pt1_ The first point of the line segment
|
||||
* @param pt2_ The second point of the line segment
|
||||
* @param color_ The line color
|
||||
* @param thick_ The thickness of line
|
||||
* @param lt_ The Type of the line. See #LineTypes
|
||||
* @param shift_ The number of fractional bits in the point coordinates
|
||||
*/
|
||||
Line(const cv::Point& pt1_,
|
||||
const cv::Point& pt2_,
|
||||
const cv::Scalar& color_,
|
||||
int thick_ = 1,
|
||||
int lt_ = cv::LINE_8,
|
||||
int shift_ = 0) :
|
||||
pt1(pt1_), pt2(pt2_), color(color_), thick(thick_), lt(lt_), shift(shift_)
|
||||
{
|
||||
}
|
||||
|
||||
/*@{*/
|
||||
cv::Point pt1; //!< The first point of the line segment
|
||||
cv::Point pt2; //!< The second point of the line segment
|
||||
cv::Scalar color; //!< The line color
|
||||
int thick; //!< The thickness of line
|
||||
int lt; //!< The Type of the line. See #LineTypes
|
||||
int shift; //!< The number of fractional bits in the point coordinates
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents a mosaicing operation.
|
||||
*
|
||||
* Mosaicing is a very basic method to obfuscate regions in the image.
|
||||
*/
|
||||
struct Mosaic
|
||||
{
|
||||
/**
|
||||
* @brief Mosaic constructor
|
||||
*
|
||||
* @param mos_ Coordinates of the mosaic
|
||||
* @param cellSz_ Cell size (same for X, Y)
|
||||
* @param decim_ Decimation (0 stands for no decimation)
|
||||
*/
|
||||
Mosaic(const cv::Rect& mos_,
|
||||
int cellSz_,
|
||||
int decim_) :
|
||||
mos(mos_), cellSz(cellSz_), decim(decim_)
|
||||
{
|
||||
}
|
||||
|
||||
/*@{*/
|
||||
cv::Rect mos; //!< Coordinates of the mosaic
|
||||
int cellSz; //!< Cell size (same for X, Y)
|
||||
int decim; //!< Decimation (0 stands for no decimation)
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents an image to draw.
|
||||
*
|
||||
* Image is blended on a frame using the specified mask.
|
||||
*/
|
||||
struct Image
|
||||
{
|
||||
/**
|
||||
* @brief Mosaic constructor
|
||||
*
|
||||
* @param org_ The bottom-left corner of the image
|
||||
* @param img_ Image to draw
|
||||
* @param alpha_ Alpha channel for image to draw (same size and number of channels)
|
||||
*/
|
||||
Image(const cv::Point& org_,
|
||||
const cv::Mat& img_,
|
||||
const cv::Mat& alpha_) :
|
||||
org(org_), img(img_), alpha(alpha_)
|
||||
{
|
||||
}
|
||||
|
||||
/*@{*/
|
||||
cv::Point org; //!< The bottom-left corner of the image
|
||||
cv::Mat img; //!< Image to draw
|
||||
cv::Mat alpha; //!< Alpha channel for image to draw (same size and number of channels)
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents a polygon to draw.
|
||||
*/
|
||||
struct Poly
|
||||
{
|
||||
/**
|
||||
* @brief Mosaic constructor
|
||||
*
|
||||
* @param points_ Points to connect
|
||||
* @param color_ The line color
|
||||
* @param thick_ The thickness of line
|
||||
* @param lt_ The Type of the line. See #LineTypes
|
||||
* @param shift_ The number of fractional bits in the point coordinate
|
||||
*/
|
||||
Poly(const std::vector<cv::Point>& points_,
|
||||
const cv::Scalar& color_,
|
||||
int thick_ = 1,
|
||||
int lt_ = cv::LINE_8,
|
||||
int shift_ = 0) :
|
||||
points(points_), color(color_), thick(thick_), lt(lt_), shift(shift_)
|
||||
{
|
||||
}
|
||||
|
||||
/*@{*/
|
||||
std::vector<cv::Point> points; //!< Points to connect
|
||||
cv::Scalar color; //!< The line color
|
||||
int thick; //!< The thickness of line
|
||||
int lt; //!< The Type of the line. See #LineTypes
|
||||
int shift; //!< The number of fractional bits in the point coordinate
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
using Prim = util::variant
|
||||
< Text
|
||||
, FText
|
||||
, Rect
|
||||
, Circle
|
||||
, Line
|
||||
, Mosaic
|
||||
, Image
|
||||
, Poly
|
||||
>;
|
||||
|
||||
using Prims = std::vector<Prim>;
|
||||
//! @} gapi_draw_prims
|
||||
|
||||
using GMat2 = std::tuple<cv::GMat,cv::GMat>;
|
||||
using GMatDesc2 = std::tuple<cv::GMatDesc,cv::GMatDesc>;
|
||||
|
||||
|
||||
//! @addtogroup gapi_draw_api
|
||||
//! @{
|
||||
/** @brief The function renders on the input image passed drawing primitivies
|
||||
|
||||
@@ -0,0 +1,347 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_RENDER_TYPES_HPP
|
||||
#define OPENCV_GAPI_RENDER_TYPES_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/util/variant.hpp>
|
||||
#include <opencv2/gapi/own/exports.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace gapi
|
||||
{
|
||||
namespace wip
|
||||
{
|
||||
namespace draw
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief This structure specifies which FreeType font to use by FText primitives.
|
||||
*/
|
||||
struct freetype_font
|
||||
{
|
||||
/*@{*/
|
||||
std::string path; //!< The path to the font file (.ttf)
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
//! @addtogroup gapi_draw_prims
|
||||
//! @{
|
||||
/**
|
||||
* @brief This structure represents a text string to draw.
|
||||
*
|
||||
* Parameters match cv::putText().
|
||||
*/
|
||||
struct Text
|
||||
{
|
||||
/**
|
||||
* @brief Text constructor
|
||||
*
|
||||
* @param text_ The text string to be drawn
|
||||
* @param org_ The bottom-left corner of the text string in the image
|
||||
* @param ff_ The font type, see #HersheyFonts
|
||||
* @param fs_ The font scale factor that is multiplied by the font-specific base size
|
||||
* @param color_ The text color
|
||||
* @param thick_ The thickness of the lines used to draw a text
|
||||
* @param lt_ The line type. See #LineTypes
|
||||
* @param bottom_left_origin_ When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner
|
||||
*/
|
||||
Text(const std::string& text_,
|
||||
const cv::Point& org_,
|
||||
int ff_,
|
||||
double fs_,
|
||||
const cv::Scalar& color_,
|
||||
int thick_ = 1,
|
||||
int lt_ = 8,
|
||||
bool bottom_left_origin_ = false) :
|
||||
text(text_), org(org_), ff(ff_), fs(fs_),
|
||||
color(color_), thick(thick_), lt(lt_), bottom_left_origin(bottom_left_origin_)
|
||||
{
|
||||
}
|
||||
|
||||
Text() = default;
|
||||
|
||||
/*@{*/
|
||||
std::string text; //!< The text string to be drawn
|
||||
cv::Point org; //!< The bottom-left corner of the text string in the image
|
||||
int ff; //!< The font type, see #HersheyFonts
|
||||
double fs; //!< The font scale factor that is multiplied by the font-specific base size
|
||||
cv::Scalar color; //!< The text color
|
||||
int thick; //!< The thickness of the lines used to draw a text
|
||||
int lt; //!< The line type. See #LineTypes
|
||||
bool bottom_left_origin; //!< When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents a text string to draw using
|
||||
* FreeType renderer.
|
||||
*
|
||||
* If OpenCV is built without FreeType support, this primitive will
|
||||
* fail at the execution stage.
|
||||
*/
|
||||
struct FText
|
||||
{
|
||||
/**
|
||||
* @brief FText constructor
|
||||
*
|
||||
* @param text_ The text string to be drawn
|
||||
* @param org_ The bottom-left corner of the text string in the image
|
||||
* @param fh_ The height of text
|
||||
* @param color_ The text color
|
||||
*/
|
||||
FText(const std::wstring& text_,
|
||||
const cv::Point& org_,
|
||||
int fh_,
|
||||
const cv::Scalar& color_) :
|
||||
text(text_), org(org_), fh(fh_), color(color_)
|
||||
{
|
||||
}
|
||||
|
||||
FText() = default;
|
||||
|
||||
/*@{*/
|
||||
std::wstring text; //!< The text string to be drawn
|
||||
cv::Point org; //!< The bottom-left corner of the text string in the image
|
||||
int fh; //!< The height of text
|
||||
cv::Scalar color; //!< The text color
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents a rectangle to draw.
|
||||
*
|
||||
* Parameters match cv::rectangle().
|
||||
*/
|
||||
struct Rect
|
||||
{
|
||||
/**
|
||||
* @brief Rect constructor
|
||||
*
|
||||
* @param rect_ Coordinates of the rectangle
|
||||
* @param color_ The bottom-left corner of the text string in the image
|
||||
* @param thick_ The thickness of lines that make up the rectangle. Negative values, like #FILLED, mean that the function has to draw a filled rectangle
|
||||
* @param lt_ The type of the line. See #LineTypes
|
||||
* @param shift_ The number of fractional bits in the point coordinates
|
||||
*/
|
||||
Rect(const cv::Rect& rect_,
|
||||
const cv::Scalar& color_,
|
||||
int thick_ = 1,
|
||||
int lt_ = 8,
|
||||
int shift_ = 0) :
|
||||
rect(rect_), color(color_), thick(thick_), lt(lt_), shift(shift_)
|
||||
{
|
||||
}
|
||||
|
||||
Rect() = default;
|
||||
|
||||
/*@{*/
|
||||
cv::Rect rect; //!< Coordinates of the rectangle
|
||||
cv::Scalar color; //!< The rectangle color or brightness (grayscale image)
|
||||
int thick; //!< The thickness of lines that make up the rectangle. Negative values, like #FILLED, mean that the function has to draw a filled rectangle
|
||||
int lt; //!< The type of the line. See #LineTypes
|
||||
int shift; //!< The number of fractional bits in the point coordinates
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents a circle to draw.
|
||||
*
|
||||
* Parameters match cv::circle().
|
||||
*/
|
||||
struct Circle
|
||||
{
|
||||
/**
|
||||
* @brief Circle constructor
|
||||
*
|
||||
* @param center_ The center of the circle
|
||||
* @param radius_ The radius of the circle
|
||||
* @param color_ The color of the circle
|
||||
* @param thick_ The thickness of the circle outline, if positive. Negative values, like #FILLED, mean that a filled circle is to be drawn
|
||||
* @param lt_ The Type of the circle boundary. See #LineTypes
|
||||
* @param shift_ The Number of fractional bits in the coordinates of the center and in the radius value
|
||||
*/
|
||||
Circle(const cv::Point& center_,
|
||||
int radius_,
|
||||
const cv::Scalar& color_,
|
||||
int thick_ = 1,
|
||||
int lt_ = 8,
|
||||
int shift_ = 0) :
|
||||
center(center_), radius(radius_), color(color_), thick(thick_), lt(lt_), shift(shift_)
|
||||
{
|
||||
}
|
||||
|
||||
Circle() = default;
|
||||
|
||||
/*@{*/
|
||||
cv::Point center; //!< The center of the circle
|
||||
int radius; //!< The radius of the circle
|
||||
cv::Scalar color; //!< The color of the circle
|
||||
int thick; //!< The thickness of the circle outline, if positive. Negative values, like #FILLED, mean that a filled circle is to be drawn
|
||||
int lt; //!< The Type of the circle boundary. See #LineTypes
|
||||
int shift; //!< The Number of fractional bits in the coordinates of the center and in the radius value
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents a line to draw.
|
||||
*
|
||||
* Parameters match cv::line().
|
||||
*/
|
||||
struct Line
|
||||
{
|
||||
/**
|
||||
* @brief Line constructor
|
||||
*
|
||||
* @param pt1_ The first point of the line segment
|
||||
* @param pt2_ The second point of the line segment
|
||||
* @param color_ The line color
|
||||
* @param thick_ The thickness of line
|
||||
* @param lt_ The Type of the line. See #LineTypes
|
||||
* @param shift_ The number of fractional bits in the point coordinates
|
||||
*/
|
||||
Line(const cv::Point& pt1_,
|
||||
const cv::Point& pt2_,
|
||||
const cv::Scalar& color_,
|
||||
int thick_ = 1,
|
||||
int lt_ = 8,
|
||||
int shift_ = 0) :
|
||||
pt1(pt1_), pt2(pt2_), color(color_), thick(thick_), lt(lt_), shift(shift_)
|
||||
{
|
||||
}
|
||||
|
||||
Line() = default;
|
||||
|
||||
/*@{*/
|
||||
cv::Point pt1; //!< The first point of the line segment
|
||||
cv::Point pt2; //!< The second point of the line segment
|
||||
cv::Scalar color; //!< The line color
|
||||
int thick; //!< The thickness of line
|
||||
int lt; //!< The Type of the line. See #LineTypes
|
||||
int shift; //!< The number of fractional bits in the point coordinates
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents a mosaicing operation.
|
||||
*
|
||||
* Mosaicing is a very basic method to obfuscate regions in the image.
|
||||
*/
|
||||
struct Mosaic
|
||||
{
|
||||
/**
|
||||
* @brief Mosaic constructor
|
||||
*
|
||||
* @param mos_ Coordinates of the mosaic
|
||||
* @param cellSz_ Cell size (same for X, Y)
|
||||
* @param decim_ Decimation (0 stands for no decimation)
|
||||
*/
|
||||
Mosaic(const cv::Rect& mos_,
|
||||
int cellSz_,
|
||||
int decim_) :
|
||||
mos(mos_), cellSz(cellSz_), decim(decim_)
|
||||
{
|
||||
}
|
||||
|
||||
Mosaic() = default;
|
||||
|
||||
/*@{*/
|
||||
cv::Rect mos; //!< Coordinates of the mosaic
|
||||
int cellSz; //!< Cell size (same for X, Y)
|
||||
int decim; //!< Decimation (0 stands for no decimation)
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents an image to draw.
|
||||
*
|
||||
* Image is blended on a frame using the specified mask.
|
||||
*/
|
||||
struct Image
|
||||
{
|
||||
/**
|
||||
* @brief Mosaic constructor
|
||||
*
|
||||
* @param org_ The bottom-left corner of the image
|
||||
* @param img_ Image to draw
|
||||
* @param alpha_ Alpha channel for image to draw (same size and number of channels)
|
||||
*/
|
||||
Image(const cv::Point& org_,
|
||||
const cv::Mat& img_,
|
||||
const cv::Mat& alpha_) :
|
||||
org(org_), img(img_), alpha(alpha_)
|
||||
{
|
||||
}
|
||||
|
||||
Image() = default;
|
||||
|
||||
/*@{*/
|
||||
cv::Point org; //!< The bottom-left corner of the image
|
||||
cv::Mat img; //!< Image to draw
|
||||
cv::Mat alpha; //!< Alpha channel for image to draw (same size and number of channels)
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure represents a polygon to draw.
|
||||
*/
|
||||
struct Poly
|
||||
{
|
||||
/**
|
||||
* @brief Mosaic constructor
|
||||
*
|
||||
* @param points_ Points to connect
|
||||
* @param color_ The line color
|
||||
* @param thick_ The thickness of line
|
||||
* @param lt_ The Type of the line. See #LineTypes
|
||||
* @param shift_ The number of fractional bits in the point coordinate
|
||||
*/
|
||||
Poly(const std::vector<cv::Point>& points_,
|
||||
const cv::Scalar& color_,
|
||||
int thick_ = 1,
|
||||
int lt_ = 8,
|
||||
int shift_ = 0) :
|
||||
points(points_), color(color_), thick(thick_), lt(lt_), shift(shift_)
|
||||
{
|
||||
}
|
||||
|
||||
Poly() = default;
|
||||
|
||||
/*@{*/
|
||||
std::vector<cv::Point> points; //!< Points to connect
|
||||
cv::Scalar color; //!< The line color
|
||||
int thick; //!< The thickness of line
|
||||
int lt; //!< The Type of the line. See #LineTypes
|
||||
int shift; //!< The number of fractional bits in the point coordinate
|
||||
/*@{*/
|
||||
};
|
||||
|
||||
using Prim = util::variant
|
||||
< Text
|
||||
, FText
|
||||
, Rect
|
||||
, Circle
|
||||
, Line
|
||||
, Mosaic
|
||||
, Image
|
||||
, Poly
|
||||
>;
|
||||
|
||||
using Prims = std::vector<Prim>;
|
||||
//! @} gapi_draw_prims
|
||||
|
||||
} // namespace draw
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_RENDER_TYPES_HPP
|
||||
Reference in New Issue
Block a user