添加项目文件。
This commit is contained in:
55
3rdparty/opencv/inc/opencv2/gapi/own/assert.hpp
vendored
Normal file
55
3rdparty/opencv/inc/opencv2/gapi/own/assert.hpp
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
// 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) 2018-2020 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_OWN_ASSERT_HPP
|
||||
#define OPENCV_GAPI_OWN_ASSERT_HPP
|
||||
|
||||
#include <opencv2/gapi/util/compiler_hints.hpp>
|
||||
|
||||
#define GAPI_DbgAssertNoOp(expr) { \
|
||||
constexpr bool _assert_tmp = false && (expr); \
|
||||
cv::util::suppress_unused_warning(_assert_tmp); \
|
||||
}
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
#include <opencv2/core/base.hpp>
|
||||
#define GAPI_Assert CV_Assert
|
||||
|
||||
#if defined _DEBUG || defined CV_STATIC_ANALYSIS
|
||||
# define GAPI_DbgAssert CV_DbgAssert
|
||||
#else
|
||||
# define GAPI_DbgAssert(expr) GAPI_DbgAssertNoOp(expr)
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <opencv2/gapi/util/throw.hpp>
|
||||
|
||||
namespace detail
|
||||
{
|
||||
[[noreturn]] inline void assert_abort(const char* str, int line, const char* file, const char* func)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << file << ":" << line << ": Assertion " << str << " in function " << func << " failed\n";
|
||||
cv::util::throw_error(std::logic_error(ss.str()));
|
||||
}
|
||||
}
|
||||
|
||||
#define GAPI_Assert(expr) \
|
||||
{ if (!(expr)) ::detail::assert_abort(#expr, __LINE__, __FILE__, __func__); }
|
||||
|
||||
|
||||
#ifdef NDEBUG
|
||||
# define GAPI_DbgAssert(expr) GAPI_DbgAssertNoOp(expr)
|
||||
#else
|
||||
# define GAPI_DbgAssert(expr) GAPI_Assert(expr)
|
||||
#endif
|
||||
|
||||
#endif // GAPI_STANDALONE
|
||||
|
||||
#endif // OPENCV_GAPI_OWN_ASSERT_HPP
|
||||
55
3rdparty/opencv/inc/opencv2/gapi/own/convert.hpp
vendored
Normal file
55
3rdparty/opencv/inc/opencv2/gapi/own/convert.hpp
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
// 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) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_OWN_CONVERT_HPP
|
||||
#define OPENCV_GAPI_OWN_CONVERT_HPP
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/own/mat.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
template<typename T>
|
||||
std::vector<T> to_own(const cv::MatSize &sz) {
|
||||
std::vector<T> result(sz.dims());
|
||||
for (int i = 0; i < sz.dims(); i++) {
|
||||
// Note: cv::MatSize is not iterable
|
||||
result[i] = static_cast<T>(sz[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
cv::gapi::own::Mat to_own(Mat&&) = delete;
|
||||
|
||||
inline cv::gapi::own::Mat to_own(Mat const& m) {
|
||||
return (m.dims == 2)
|
||||
? cv::gapi::own::Mat{m.rows, m.cols, m.type(), m.data, m.step}
|
||||
: cv::gapi::own::Mat{to_own<int>(m.size), m.type(), m.data};
|
||||
};
|
||||
|
||||
namespace gapi
|
||||
{
|
||||
namespace own
|
||||
{
|
||||
|
||||
inline cv::Mat to_ocv(Mat const& m) {
|
||||
return m.dims.empty()
|
||||
? cv::Mat{m.rows, m.cols, m.type(), m.data, m.step}
|
||||
: cv::Mat{m.dims, m.type(), m.data};
|
||||
}
|
||||
|
||||
cv::Mat to_ocv(Mat&&) = delete;
|
||||
|
||||
} // namespace own
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
#endif // OPENCV_GAPI_OWN_CONVERT_HPP
|
||||
166
3rdparty/opencv/inc/opencv2/gapi/own/cvdefs.hpp
vendored
Normal file
166
3rdparty/opencv/inc/opencv2/gapi/own/cvdefs.hpp
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
// 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) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_CV_DEFS_HPP
|
||||
#define OPENCV_GAPI_CV_DEFS_HPP
|
||||
|
||||
#if defined(GAPI_STANDALONE)
|
||||
// Simulate OpenCV definitions taken from various
|
||||
// OpenCV interface headers if G-API is built in a
|
||||
// standalone mode.
|
||||
|
||||
// interface.h:
|
||||
|
||||
typedef unsigned char uchar;
|
||||
typedef char schar;
|
||||
|
||||
typedef unsigned short ushort;
|
||||
|
||||
#define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0"
|
||||
|
||||
#define CV_CN_MAX 512
|
||||
#define CV_CN_SHIFT 3
|
||||
#define CV_DEPTH_MAX (1 << CV_CN_SHIFT)
|
||||
|
||||
#define CV_8U 0
|
||||
#define CV_8S 1
|
||||
#define CV_16U 2
|
||||
#define CV_16S 3
|
||||
#define CV_32S 4
|
||||
#define CV_32F 5
|
||||
#define CV_64F 6
|
||||
#define CV_16F 7
|
||||
|
||||
#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1)
|
||||
#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK)
|
||||
|
||||
#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT))
|
||||
#define CV_MAKE_TYPE CV_MAKETYPE
|
||||
|
||||
#define CV_8UC1 CV_MAKETYPE(CV_8U,1)
|
||||
#define CV_8UC2 CV_MAKETYPE(CV_8U,2)
|
||||
#define CV_8UC3 CV_MAKETYPE(CV_8U,3)
|
||||
#define CV_8UC4 CV_MAKETYPE(CV_8U,4)
|
||||
#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n))
|
||||
|
||||
#define CV_8SC1 CV_MAKETYPE(CV_8S,1)
|
||||
#define CV_8SC2 CV_MAKETYPE(CV_8S,2)
|
||||
#define CV_8SC3 CV_MAKETYPE(CV_8S,3)
|
||||
#define CV_8SC4 CV_MAKETYPE(CV_8S,4)
|
||||
#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n))
|
||||
|
||||
#define CV_16UC1 CV_MAKETYPE(CV_16U,1)
|
||||
#define CV_16UC2 CV_MAKETYPE(CV_16U,2)
|
||||
#define CV_16UC3 CV_MAKETYPE(CV_16U,3)
|
||||
#define CV_16UC4 CV_MAKETYPE(CV_16U,4)
|
||||
#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n))
|
||||
|
||||
#define CV_16SC1 CV_MAKETYPE(CV_16S,1)
|
||||
#define CV_16SC2 CV_MAKETYPE(CV_16S,2)
|
||||
#define CV_16SC3 CV_MAKETYPE(CV_16S,3)
|
||||
#define CV_16SC4 CV_MAKETYPE(CV_16S,4)
|
||||
#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n))
|
||||
|
||||
#define CV_32SC1 CV_MAKETYPE(CV_32S,1)
|
||||
#define CV_32SC2 CV_MAKETYPE(CV_32S,2)
|
||||
#define CV_32SC3 CV_MAKETYPE(CV_32S,3)
|
||||
#define CV_32SC4 CV_MAKETYPE(CV_32S,4)
|
||||
#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n))
|
||||
|
||||
#define CV_16FC1 CV_MAKETYPE(CV_16F,1)
|
||||
#define CV_16FC2 CV_MAKETYPE(CV_16F,2)
|
||||
#define CV_16FC3 CV_MAKETYPE(CV_16F,3)
|
||||
#define CV_16FC4 CV_MAKETYPE(CV_16F,4)
|
||||
#define CV_16FC(n) CV_MAKETYPE(CV_16F,(n))
|
||||
|
||||
#define CV_32FC1 CV_MAKETYPE(CV_32F,1)
|
||||
#define CV_32FC2 CV_MAKETYPE(CV_32F,2)
|
||||
#define CV_32FC3 CV_MAKETYPE(CV_32F,3)
|
||||
#define CV_32FC4 CV_MAKETYPE(CV_32F,4)
|
||||
#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n))
|
||||
|
||||
#define CV_64FC1 CV_MAKETYPE(CV_64F,1)
|
||||
#define CV_64FC2 CV_MAKETYPE(CV_64F,2)
|
||||
#define CV_64FC3 CV_MAKETYPE(CV_64F,3)
|
||||
#define CV_64FC4 CV_MAKETYPE(CV_64F,4)
|
||||
#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n))
|
||||
|
||||
// cvdef.h:
|
||||
|
||||
#ifndef CV_ALWAYS_INLINE
|
||||
# if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
# define CV_ALWAYS_INLINE inline __attribute__((always_inline))
|
||||
# elif defined(_MSC_VER)
|
||||
# define CV_ALWAYS_INLINE __forceinline
|
||||
# else
|
||||
# define CV_ALWAYS_INLINE inline
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT)
|
||||
#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1)
|
||||
#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1)
|
||||
#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK)
|
||||
#define CV_MAT_CONT_FLAG_SHIFT 14
|
||||
#define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT)
|
||||
#define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG)
|
||||
#define CV_IS_CONT_MAT CV_IS_MAT_CONT
|
||||
#define CV_SUBMAT_FLAG_SHIFT 15
|
||||
#define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT)
|
||||
#define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG)
|
||||
|
||||
//** Size of each channel item,
|
||||
// 0x8442211 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */
|
||||
#define CV_ELEM_SIZE1(type) \
|
||||
((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15)
|
||||
|
||||
#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK)
|
||||
|
||||
/** 0x3a50 = 11 10 10 01 01 00 00 ~ array of log2(sizeof(arr_type_elem)) */
|
||||
#define CV_ELEM_SIZE(type) \
|
||||
(CV_MAT_CN(type) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3))
|
||||
|
||||
#ifndef CV_OVERRIDE
|
||||
# define CV_OVERRIDE override
|
||||
#endif
|
||||
|
||||
// base.h:
|
||||
namespace cv
|
||||
{
|
||||
enum BorderTypes {
|
||||
BORDER_CONSTANT = 0, //!< `iiiiii|abcdefgh|iiiiiii` with some specified `i`
|
||||
BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh`
|
||||
BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb`
|
||||
BORDER_WRAP = 3, //!< `cdefgh|abcdefgh|abcdefg`
|
||||
BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba`
|
||||
BORDER_TRANSPARENT = 5, //!< `uvwxyz|abcdefgh|ijklmno`
|
||||
|
||||
BORDER_REFLECT101 = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
|
||||
BORDER_DEFAULT = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
|
||||
BORDER_ISOLATED = 16 //!< do not look outside of ROI
|
||||
};
|
||||
// imgproc.hpp:
|
||||
enum InterpolationFlags{
|
||||
INTER_NEAREST = 0,
|
||||
INTER_LINEAR = 1,
|
||||
INTER_CUBIC = 2,
|
||||
INTER_AREA = 3,
|
||||
INTER_LANCZOS4 = 4,
|
||||
INTER_LINEAR_EXACT = 5,
|
||||
INTER_MAX = 7,
|
||||
};
|
||||
} // namespace cv
|
||||
|
||||
static inline int cvFloor( double value )
|
||||
{
|
||||
int i = (int)value;
|
||||
return i - (i > value);
|
||||
}
|
||||
|
||||
#endif // defined(GAPI_STANDALONE)
|
||||
|
||||
#endif // OPENCV_GAPI_CV_DEFS_HPP
|
||||
42
3rdparty/opencv/inc/opencv2/gapi/own/exports.hpp
vendored
Normal file
42
3rdparty/opencv/inc/opencv2/gapi/own/exports.hpp
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// 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) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_OWN_TYPES_HPP
|
||||
#define OPENCV_GAPI_OWN_TYPES_HPP
|
||||
|
||||
# if defined(__OPENCV_BUILD)
|
||||
# include <opencv2/core/base.hpp>
|
||||
# define GAPI_EXPORTS CV_EXPORTS
|
||||
/* special informative macros for wrapper generators */
|
||||
# define GAPI_PROP CV_PROP
|
||||
# define GAPI_PROP_RW CV_PROP_RW
|
||||
# define GAPI_WRAP CV_WRAP
|
||||
# define GAPI_EXPORTS_W_SIMPLE CV_EXPORTS_W_SIMPLE
|
||||
# define GAPI_EXPORTS_W CV_EXPORTS_W
|
||||
# else
|
||||
# define GAPI_PROP
|
||||
# define GAPI_PROP_RW
|
||||
# define GAPI_WRAP
|
||||
# define GAPI_EXPORTS
|
||||
# define GAPI_EXPORTS_W_SIMPLE
|
||||
# define GAPI_EXPORTS_W
|
||||
|
||||
#if 0 // Note: the following version currently is not needed for non-OpenCV build
|
||||
# if defined _WIN32
|
||||
# define GAPI_EXPORTS __declspec(dllexport)
|
||||
# elif defined __GNUC__ && __GNUC__ >= 4
|
||||
# define GAPI_EXPORTS __attribute__ ((visibility ("default")))
|
||||
# endif
|
||||
|
||||
# ifndef GAPI_EXPORTS
|
||||
# define GAPI_EXPORTS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# endif
|
||||
|
||||
#endif // OPENCV_GAPI_OWN_TYPES_HPP
|
||||
354
3rdparty/opencv/inc/opencv2/gapi/own/mat.hpp
vendored
Normal file
354
3rdparty/opencv/inc/opencv2/gapi/own/mat.hpp
vendored
Normal file
@@ -0,0 +1,354 @@
|
||||
// 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) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_OWN_MAT_HPP
|
||||
#define OPENCV_GAPI_OWN_MAT_HPP
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/own/types.hpp>
|
||||
#include <opencv2/gapi/own/scalar.hpp>
|
||||
#include <opencv2/gapi/own/saturate.hpp>
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
|
||||
#include <memory> //std::shared_ptr
|
||||
#include <cstring> //std::memcpy
|
||||
#include <numeric> //std::accumulate
|
||||
#include <vector>
|
||||
#include <opencv2/gapi/util/throw.hpp>
|
||||
|
||||
namespace cv { namespace gapi { namespace own {
|
||||
namespace detail {
|
||||
template <typename T, unsigned char channels>
|
||||
void assign_row(void* ptr, int cols, Scalar const& s)
|
||||
{
|
||||
auto p = static_cast<T*>(ptr);
|
||||
for (int c = 0; c < cols; c++)
|
||||
{
|
||||
for (int ch = 0; ch < channels; ch++)
|
||||
{
|
||||
p[c * channels + ch] = saturate<T>(s[ch], roundd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline size_t default_step(int type, int cols)
|
||||
{
|
||||
return CV_ELEM_SIZE(type) * cols;
|
||||
}
|
||||
//Matrix header, i.e. fields that are unique to each Mat object.
|
||||
//Devoted class is needed to implement custom behavior on move (erasing state of moved from object)
|
||||
struct MatHeader{
|
||||
enum { AUTO_STEP = 0};
|
||||
enum { TYPE_MASK = 0x00000FFF };
|
||||
|
||||
MatHeader() = default;
|
||||
|
||||
MatHeader(int _rows, int _cols, int type, void* _data, size_t _step)
|
||||
: flags((type & TYPE_MASK)), rows(_rows), cols(_cols), data((uchar*)_data), step(_step == AUTO_STEP ? detail::default_step(type, _cols) : _step)
|
||||
{}
|
||||
|
||||
MatHeader(const std::vector<int> &_dims, int type, void* _data)
|
||||
: flags((type & TYPE_MASK)), data((uchar*)_data), step(0), dims(_dims)
|
||||
{}
|
||||
|
||||
MatHeader(const MatHeader& ) = default;
|
||||
MatHeader(MatHeader&& src) : MatHeader(src) // reuse copy constructor here
|
||||
{
|
||||
MatHeader empty; //give it a name to call copy(not move) assignment below
|
||||
src = empty;
|
||||
}
|
||||
MatHeader& operator=(const MatHeader& ) = default;
|
||||
MatHeader& operator=(MatHeader&& src)
|
||||
{
|
||||
*this = src; //calling a copy assignment here, not move one
|
||||
MatHeader empty; //give it a name to call copy(not move) assignment below
|
||||
src = empty;
|
||||
return *this;
|
||||
}
|
||||
/*! includes several bit-fields:
|
||||
- depth
|
||||
- number of channels
|
||||
*/
|
||||
int flags = 0;
|
||||
|
||||
//! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
|
||||
int rows = 0, cols = 0;
|
||||
//! pointer to the data
|
||||
uchar* data = nullptr;
|
||||
size_t step = 0;
|
||||
//! dimensions (ND-case)
|
||||
std::vector<int> dims;
|
||||
};
|
||||
} // namespace detail
|
||||
//concise version of cv::Mat suitable for GAPI needs (used when no dependence on OpenCV is required)
|
||||
class Mat : public detail::MatHeader{
|
||||
public:
|
||||
|
||||
Mat() = default;
|
||||
|
||||
/** @overload
|
||||
@param _rows Number of rows in a 2D array.
|
||||
@param _cols Number of columns in a 2D array.
|
||||
@param _type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or
|
||||
CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
|
||||
@param _data Pointer to the user data. Matrix constructors that take data and step parameters do not
|
||||
allocate matrix data. Instead, they just initialize the matrix header that points to the specified
|
||||
data, which means that no data is copied. This operation is very efficient and can be used to
|
||||
process external data using OpenCV functions. The external data is not automatically deallocated, so
|
||||
you should take care of it.
|
||||
@param _step Number of bytes each matrix row occupies. The value should include the padding bytes at
|
||||
the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed
|
||||
and the actual step is calculated as cols*elemSize(). See Mat::elemSize.
|
||||
*/
|
||||
Mat(int _rows, int _cols, int _type, void* _data, size_t _step = AUTO_STEP)
|
||||
: MatHeader (_rows, _cols, _type, _data, _step)
|
||||
{}
|
||||
|
||||
Mat(const std::vector<int> &_dims, int _type, void* _data)
|
||||
: MatHeader (_dims, _type, _data)
|
||||
{}
|
||||
|
||||
Mat(std::vector<int> &&_dims, int _type, void* _data)
|
||||
: MatHeader (std::move(_dims), _type, _data)
|
||||
{}
|
||||
|
||||
Mat(Mat const& src, const Rect& roi )
|
||||
: Mat(src)
|
||||
{
|
||||
rows = roi.height;
|
||||
cols = roi.width;
|
||||
data = ptr(roi.y, roi.x);
|
||||
}
|
||||
|
||||
Mat(Mat const& ) = default;
|
||||
Mat(Mat&& ) = default;
|
||||
|
||||
Mat& operator=(Mat const& ) = default;
|
||||
Mat& operator=(Mat&& ) = default;
|
||||
|
||||
/** @brief Sets all or some of the array elements to the specified value.
|
||||
@param s Assigned scalar converted to the actual array type.
|
||||
*/
|
||||
Mat& operator = (const Scalar& s)
|
||||
{
|
||||
constexpr unsigned max_channels = 4; //Scalar can't fit more than 4
|
||||
using func_p_t = void (*)(void*, int, Scalar const&);
|
||||
using detail::assign_row;
|
||||
#define TABLE_ENTRY(type) {assign_row<type, 1>, assign_row<type, 2>, assign_row<type, 3>, assign_row<type, 4>}
|
||||
static constexpr func_p_t func_tbl[][max_channels] = {
|
||||
TABLE_ENTRY(uchar),
|
||||
TABLE_ENTRY(schar),
|
||||
TABLE_ENTRY(ushort),
|
||||
TABLE_ENTRY(short),
|
||||
TABLE_ENTRY(int),
|
||||
TABLE_ENTRY(float),
|
||||
TABLE_ENTRY(double)
|
||||
};
|
||||
#undef TABLE_ENTRY
|
||||
|
||||
static_assert(CV_8U == 0 && CV_8S == 1 && CV_16U == 2 && CV_16S == 3
|
||||
&& CV_32S == 4 && CV_32F == 5 && CV_64F == 6,
|
||||
"OCV type ids used as indexes to array, thus exact numbers are important!"
|
||||
);
|
||||
|
||||
const auto depth = static_cast<unsigned int>(this->depth());
|
||||
GAPI_Assert(depth < sizeof(func_tbl)/sizeof(func_tbl[0]));
|
||||
|
||||
if (dims.empty())
|
||||
{
|
||||
const auto channels = static_cast<unsigned int>(this->channels());
|
||||
GAPI_Assert(channels <= max_channels);
|
||||
|
||||
auto* f = func_tbl[depth][channels - 1];
|
||||
for (int r = 0; r < rows; ++r)
|
||||
{
|
||||
(*f)(static_cast<void *>(ptr(r)), cols, s );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto* f = func_tbl[depth][0];
|
||||
// FIXME: better to refactor assign_row to use std::size_t by default
|
||||
(*f)(static_cast<void *>(data), static_cast<int>(total()), s);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Returns the matrix element size in bytes.
|
||||
|
||||
The method returns the matrix element size in bytes. For example, if the matrix type is CV_16SC3 ,
|
||||
the method returns 3\*sizeof(short) or 6.
|
||||
*/
|
||||
size_t elemSize() const
|
||||
{
|
||||
return CV_ELEM_SIZE(type());
|
||||
}
|
||||
/** @brief Returns the type of a matrix element.
|
||||
|
||||
The method returns a matrix element type. This is an identifier compatible with the CvMat type
|
||||
system, like CV_16SC3 or 16-bit signed 3-channel array, and so on.
|
||||
*/
|
||||
int type() const {return CV_MAT_TYPE(flags);}
|
||||
|
||||
/** @brief Returns the depth of a matrix element.
|
||||
|
||||
The method returns the identifier of the matrix element depth (the type of each individual channel).
|
||||
For example, for a 16-bit signed element array, the method returns CV_16S . A complete list of
|
||||
matrix types contains the following values:
|
||||
- CV_8U - 8-bit unsigned integers ( 0..255 )
|
||||
- CV_8S - 8-bit signed integers ( -128..127 )
|
||||
- CV_16U - 16-bit unsigned integers ( 0..65535 )
|
||||
- CV_16S - 16-bit signed integers ( -32768..32767 )
|
||||
- CV_32S - 32-bit signed integers ( -2147483648..2147483647 )
|
||||
- CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN )
|
||||
- CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN )
|
||||
*/
|
||||
int depth() const {return CV_MAT_DEPTH(flags);}
|
||||
|
||||
/** @brief Returns the number of matrix channels.
|
||||
|
||||
The method returns the number of matrix channels.
|
||||
If matrix is N-dimensional, -1 is returned.
|
||||
*/
|
||||
int channels() const {return dims.empty() ? CV_MAT_CN(flags) : -1;}
|
||||
|
||||
/**
|
||||
@param _rows New number of rows.
|
||||
@param _cols New number of columns.
|
||||
@param _type New matrix type.
|
||||
*/
|
||||
void create(int _rows, int _cols, int _type)
|
||||
{
|
||||
create(Size{_cols, _rows}, _type);
|
||||
}
|
||||
/** @overload
|
||||
@param _size Alternative new matrix size specification: Size(cols, rows)
|
||||
@param _type New matrix type.
|
||||
*/
|
||||
void create(Size _size, int _type)
|
||||
{
|
||||
GAPI_Assert(_size.height >= 0 && _size.width >= 0);
|
||||
if (_size != Size{cols, rows} )
|
||||
{
|
||||
Mat tmp{_size.height, _size.width, _type, nullptr};
|
||||
tmp.memory.reset(new uchar[ tmp.step * tmp.rows], [](uchar * p){delete[] p;});
|
||||
tmp.data = tmp.memory.get();
|
||||
|
||||
*this = std::move(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
void create(const std::vector<int> &_dims, int _type)
|
||||
{
|
||||
// FIXME: make a proper reallocation-on-demands
|
||||
// WARNING: no tensor views, so no strides
|
||||
Mat tmp{_dims, _type, nullptr};
|
||||
// FIXME: this accumulate duplicates a lot
|
||||
const auto sz = std::accumulate(_dims.begin(), _dims.end(), 1, std::multiplies<int>());
|
||||
tmp.memory.reset(new uchar[CV_ELEM_SIZE(_type)*sz], [](uchar * p){delete[] p;});
|
||||
tmp.data = tmp.memory.get();
|
||||
*this = std::move(tmp);
|
||||
}
|
||||
|
||||
/** @brief Creates a full copy of the matrix and the underlying data.
|
||||
|
||||
The method creates a full copy of the matrix. The original step[] is not taken into account.
|
||||
So, the copy has a continuous buffer occupying total() * elemSize() bytes.
|
||||
*/
|
||||
Mat clone() const
|
||||
{
|
||||
Mat m;
|
||||
copyTo(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
/** @brief Copies the matrix to another one.
|
||||
|
||||
The method copies the matrix data to another matrix. Before copying the data, the method invokes :
|
||||
@code
|
||||
m.create(this->size(), this->type());
|
||||
@endcode
|
||||
so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the
|
||||
function does not handle the case of a partial overlap between the source and the destination
|
||||
matrices.
|
||||
*/
|
||||
void copyTo(Mat& dst) const
|
||||
{
|
||||
if (dims.empty())
|
||||
{
|
||||
dst.create(rows, cols, type());
|
||||
for (int r = 0; r < rows; ++r)
|
||||
{
|
||||
std::copy_n(ptr(r), detail::default_step(type(),cols), dst.ptr(r));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dst.create(dims, depth());
|
||||
std::copy_n(data, total()*elemSize(), data);
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief Returns true if the array has no elements.
|
||||
|
||||
The method returns true if Mat::total() is 0 or if Mat::data is NULL. Because of pop_back() and
|
||||
resize() methods `M.total() == 0` does not imply that `M.data == NULL`.
|
||||
*/
|
||||
bool empty() const
|
||||
{
|
||||
return data == 0 || total() == 0;
|
||||
}
|
||||
|
||||
/** @brief Returns the total number of array elements.
|
||||
|
||||
The method returns the number of array elements (a number of pixels if the array represents an
|
||||
image).
|
||||
*/
|
||||
size_t total() const
|
||||
{
|
||||
return dims.empty()
|
||||
? (static_cast<std::size_t>(rows) * cols)
|
||||
: std::accumulate(dims.begin(), dims.end(), static_cast<std::size_t>(1), std::multiplies<size_t>());
|
||||
}
|
||||
|
||||
/** @overload
|
||||
@param roi Extracted submatrix specified as a rectangle.
|
||||
*/
|
||||
Mat operator()( const Rect& roi ) const
|
||||
{
|
||||
return Mat{*this, roi};
|
||||
}
|
||||
|
||||
|
||||
/** @brief Returns a pointer to the specified matrix row.
|
||||
|
||||
The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in
|
||||
Mat::isContinuous to know how to use these methods.
|
||||
@param row Index along the dimension 0
|
||||
@param col Index along the dimension 1
|
||||
*/
|
||||
uchar* ptr(int row, int col = 0)
|
||||
{
|
||||
return const_cast<uchar*>(const_cast<const Mat*>(this)->ptr(row,col));
|
||||
}
|
||||
/** @overload */
|
||||
const uchar* ptr(int row, int col = 0) const
|
||||
{
|
||||
return data + step * row + CV_ELEM_SIZE(type()) * col;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
//actual memory allocated for storage, or nullptr if object is non owning view to over memory
|
||||
std::shared_ptr<uchar> memory;
|
||||
};
|
||||
|
||||
} //namespace own
|
||||
} //namespace gapi
|
||||
} //namespace cv
|
||||
|
||||
#endif /* OPENCV_GAPI_OWN_MAT_HPP */
|
||||
83
3rdparty/opencv/inc/opencv2/gapi/own/saturate.hpp
vendored
Normal file
83
3rdparty/opencv/inc/opencv2/gapi/own/saturate.hpp
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
// 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) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_OWN_SATURATE_HPP
|
||||
#define OPENCV_GAPI_OWN_SATURATE_HPP
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
#include <opencv2/gapi/util/type_traits.hpp>
|
||||
|
||||
namespace cv { namespace gapi { namespace own {
|
||||
//-----------------------------
|
||||
//
|
||||
// Numeric cast with saturation
|
||||
//
|
||||
//-----------------------------
|
||||
|
||||
template<typename DST, typename SRC,
|
||||
typename = cv::util::enable_if_t<!std::is_same<DST, SRC>::value &&
|
||||
std::is_integral<DST>::value &&
|
||||
std::is_integral<SRC>::value> >
|
||||
static CV_ALWAYS_INLINE DST saturate(SRC x)
|
||||
{
|
||||
if (sizeof(DST) > sizeof(SRC))
|
||||
return static_cast<DST>(x);
|
||||
|
||||
// compiler must recognize this saturation,
|
||||
// so compile saturate<s16>(a + b) with adds
|
||||
// instruction (e.g.: _mm_adds_epi16 if x86)
|
||||
return x < std::numeric_limits<DST>::min()?
|
||||
std::numeric_limits<DST>::min():
|
||||
x > std::numeric_limits<DST>::max()?
|
||||
std::numeric_limits<DST>::max():
|
||||
static_cast<DST>(x);
|
||||
}
|
||||
template<typename T>
|
||||
static CV_ALWAYS_INLINE T saturate(T x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
template<typename DST, typename SRC, typename R,
|
||||
cv::util::enable_if_t<std::is_floating_point<DST>::value, bool> = true >
|
||||
static CV_ALWAYS_INLINE DST saturate(SRC x, R)
|
||||
{
|
||||
return static_cast<DST>(x);
|
||||
}
|
||||
template<typename DST, typename SRC, typename R,
|
||||
cv::util::enable_if_t<std::is_integral<DST>::value &&
|
||||
std::is_integral<SRC>::value , bool> = true >
|
||||
static CV_ALWAYS_INLINE DST saturate(SRC x, R)
|
||||
{
|
||||
return saturate<DST>(x);
|
||||
}
|
||||
// Note, that OpenCV rounds differently:
|
||||
// - like std::round() for add, subtract
|
||||
// - like std::rint() for multiply, divide
|
||||
template<typename DST, typename SRC, typename R,
|
||||
cv::util::enable_if_t<std::is_integral<DST>::value &&
|
||||
std::is_floating_point<SRC>::value, bool> = true >
|
||||
static CV_ALWAYS_INLINE DST saturate(SRC x, R round)
|
||||
{
|
||||
int ix = static_cast<int>(round(x));
|
||||
return saturate<DST>(ix);
|
||||
}
|
||||
|
||||
// explicit suffix 'd' for double type
|
||||
inline double ceild(double x) { return ceil(x); }
|
||||
inline double floord(double x) { return floor(x); }
|
||||
inline double roundd(double x) { return round(x); }
|
||||
inline double rintd(double x) { return rint(x); }
|
||||
|
||||
} //namespace own
|
||||
} //namespace gapi
|
||||
} //namespace cv
|
||||
#endif /* OPENCV_GAPI_OWN_SATURATE_HPP */
|
||||
47
3rdparty/opencv/inc/opencv2/gapi/own/scalar.hpp
vendored
Normal file
47
3rdparty/opencv/inc/opencv2/gapi/own/scalar.hpp
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// 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) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_GAPI_OWN_SCALAR_HPP
|
||||
#define OPENCV_GAPI_GAPI_OWN_SCALAR_HPP
|
||||
|
||||
#include <opencv2/gapi/own/exports.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace gapi
|
||||
{
|
||||
namespace own
|
||||
{
|
||||
|
||||
class GAPI_EXPORTS Scalar
|
||||
{
|
||||
public:
|
||||
Scalar() = default;
|
||||
explicit Scalar(double v0) { val[0] = v0; };
|
||||
Scalar(double v0, double v1, double v2 = 0, double v3 = 0)
|
||||
: val{v0, v1, v2, v3}
|
||||
{
|
||||
}
|
||||
|
||||
const double& operator[](int i) const { return val[i]; }
|
||||
double& operator[](int i) { return val[i]; }
|
||||
|
||||
static Scalar all(double v0) { return Scalar(v0, v0, v0, v0); }
|
||||
|
||||
double val[4] = {0};
|
||||
};
|
||||
|
||||
inline bool operator==(const Scalar& lhs, const Scalar& rhs)
|
||||
{
|
||||
return std::equal(std::begin(lhs.val), std::end(lhs.val), std::begin(rhs.val));
|
||||
}
|
||||
|
||||
} // namespace own
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_GAPI_OWN_SCALAR_HPP
|
||||
151
3rdparty/opencv/inc/opencv2/gapi/own/types.hpp
vendored
Normal file
151
3rdparty/opencv/inc/opencv2/gapi/own/types.hpp
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
// 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) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_TYPES_HPP
|
||||
#define OPENCV_GAPI_TYPES_HPP
|
||||
|
||||
#include <algorithm> // std::max, std::min
|
||||
#include <ostream>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace gapi
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief This namespace contains G-API own data structures used in
|
||||
* its standalone mode build.
|
||||
*/
|
||||
namespace own
|
||||
{
|
||||
|
||||
class Point
|
||||
{
|
||||
public:
|
||||
Point() = default;
|
||||
Point(int _x, int _y) : x(_x), y(_y) {}
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
};
|
||||
|
||||
class Point2f
|
||||
{
|
||||
public:
|
||||
Point2f() = default;
|
||||
Point2f(float _x, float _y) : x(_x), y(_y) {}
|
||||
|
||||
float x = 0.f;
|
||||
float y = 0.f;
|
||||
};
|
||||
|
||||
class Rect
|
||||
{
|
||||
public:
|
||||
Rect() = default;
|
||||
Rect(int _x, int _y, int _width, int _height) : x(_x), y(_y), width(_width), height(_height) {}
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
Rect(const cv::Rect& other) : x(other.x), y(other.y), width(other.width), height(other.height) {}
|
||||
inline Rect& operator=(const cv::Rect& other)
|
||||
{
|
||||
x = other.x;
|
||||
y = other.x;
|
||||
width = other.width;
|
||||
height = other.height;
|
||||
return *this;
|
||||
}
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
int x = 0; //!< x coordinate of the top-left corner
|
||||
int y = 0; //!< y coordinate of the top-left corner
|
||||
int width = 0; //!< width of the rectangle
|
||||
int height = 0; //!< height of the rectangle
|
||||
};
|
||||
|
||||
inline bool operator==(const Rect& lhs, const Rect& rhs)
|
||||
{
|
||||
return lhs.x == rhs.x && lhs.y == rhs.y && lhs.width == rhs.width && lhs.height == rhs.height;
|
||||
}
|
||||
|
||||
inline bool operator!=(const Rect& lhs, const Rect& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
inline Rect& operator&=(Rect& lhs, const Rect& rhs)
|
||||
{
|
||||
int x1 = std::max(lhs.x, rhs.x);
|
||||
int y1 = std::max(lhs.y, rhs.y);
|
||||
lhs.width = std::min(lhs.x + lhs.width, rhs.x + rhs.width) - x1;
|
||||
lhs.height = std::min(lhs.y + lhs.height, rhs.y + rhs.height) - y1;
|
||||
lhs.x = x1;
|
||||
lhs.y = y1;
|
||||
if( lhs.width <= 0 || lhs.height <= 0 )
|
||||
lhs = Rect();
|
||||
return lhs;
|
||||
}
|
||||
|
||||
inline const Rect operator&(const Rect& lhs, const Rect& rhs)
|
||||
{
|
||||
Rect result = lhs;
|
||||
return result &= rhs;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& o, const Rect& rect)
|
||||
{
|
||||
return o << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]";
|
||||
}
|
||||
|
||||
class Size
|
||||
{
|
||||
public:
|
||||
Size() = default;
|
||||
Size(int _width, int _height) : width(_width), height(_height) {}
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
Size(const cv::Size& other) : width(other.width), height(other.height) {}
|
||||
inline Size& operator=(const cv::Size& rhs)
|
||||
{
|
||||
width = rhs.width;
|
||||
height = rhs.height;
|
||||
return *this;
|
||||
}
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
};
|
||||
|
||||
inline Size& operator+=(Size& lhs, const Size& rhs)
|
||||
{
|
||||
lhs.width += rhs.width;
|
||||
lhs.height += rhs.height;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
inline bool operator==(const Size& lhs, const Size& rhs)
|
||||
{
|
||||
return lhs.width == rhs.width && lhs.height == rhs.height;
|
||||
}
|
||||
|
||||
inline bool operator!=(const Size& lhs, const Size& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& o, const Size& s)
|
||||
{
|
||||
o << "[" << s.width << " x " << s.height << "]";
|
||||
return o;
|
||||
}
|
||||
|
||||
struct VoidType {};
|
||||
} // namespace own
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_TYPES_HPP
|
||||
Reference in New Issue
Block a user