Move C++ basic structures to separate header and inverse dependency from C API
cv::Complex, cv::Point_ and cv::Point3_ are moved.
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "opencv2/core/cvstd.hpp"
|
||||
#include "opencv2/core/types.hpp"
|
||||
|
||||
#ifndef SKIP_INCLUDES
|
||||
#include <limits.h>
|
||||
@@ -523,125 +524,6 @@ typedef Vec<double, 4> Vec4d;
|
||||
typedef Vec<double, 6> Vec6d;
|
||||
|
||||
|
||||
//////////////////////////////// Complex //////////////////////////////
|
||||
|
||||
/*!
|
||||
A complex number class.
|
||||
|
||||
The template class is similar and compatible with std::complex, however it provides slightly
|
||||
more convenient access to the real and imaginary parts using through the simple field access, as opposite
|
||||
to std::complex::real() and std::complex::imag().
|
||||
*/
|
||||
template<typename _Tp> class CV_EXPORTS Complex
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructors
|
||||
Complex();
|
||||
Complex( _Tp _re, _Tp _im=0 );
|
||||
Complex( const std::complex<_Tp>& c );
|
||||
|
||||
//! conversion to another data type
|
||||
template<typename T2> operator Complex<T2>() const;
|
||||
//! conjugation
|
||||
Complex conj() const;
|
||||
//! conversion to std::complex
|
||||
operator std::complex<_Tp>() const;
|
||||
|
||||
_Tp re, im; //< the real and the imaginary parts
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
\typedef
|
||||
*/
|
||||
typedef Complex<float> Complexf;
|
||||
typedef Complex<double> Complexd;
|
||||
|
||||
|
||||
//////////////////////////////// Point_ ////////////////////////////////
|
||||
|
||||
/*!
|
||||
template 2D point class.
|
||||
|
||||
The class defines a point in 2D space. Data type of the point coordinates is specified
|
||||
as a template parameter. There are a few shorter aliases available for user convenience.
|
||||
See cv::Point, cv::Point2i, cv::Point2f and cv::Point2d.
|
||||
*/
|
||||
template<typename _Tp> class CV_EXPORTS Point_
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
|
||||
// various constructors
|
||||
Point_();
|
||||
Point_(_Tp _x, _Tp _y);
|
||||
Point_(const Point_& pt);
|
||||
Point_(const CvPoint& pt);
|
||||
Point_(const CvPoint2D32f& pt);
|
||||
Point_(const Size_<_Tp>& sz);
|
||||
Point_(const Vec<_Tp, 2>& v);
|
||||
|
||||
Point_& operator = (const Point_& pt);
|
||||
//! conversion to another data type
|
||||
template<typename _Tp2> operator Point_<_Tp2>() const;
|
||||
|
||||
//! conversion to the old-style C structures
|
||||
operator CvPoint() const;
|
||||
operator CvPoint2D32f() const;
|
||||
operator Vec<_Tp, 2>() const;
|
||||
|
||||
//! dot product
|
||||
_Tp dot(const Point_& pt) const;
|
||||
//! dot product computed in double-precision arithmetics
|
||||
double ddot(const Point_& pt) const;
|
||||
//! cross-product
|
||||
double cross(const Point_& pt) const;
|
||||
//! checks whether the point is inside the specified rectangle
|
||||
bool inside(const Rect_<_Tp>& r) const;
|
||||
|
||||
_Tp x, y; //< the point coordinates
|
||||
};
|
||||
|
||||
/*!
|
||||
template 3D point class.
|
||||
|
||||
The class defines a point in 3D space. Data type of the point coordinates is specified
|
||||
as a template parameter.
|
||||
|
||||
\see cv::Point3i, cv::Point3f and cv::Point3d
|
||||
*/
|
||||
template<typename _Tp> class CV_EXPORTS Point3_
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
|
||||
// various constructors
|
||||
Point3_();
|
||||
Point3_(_Tp _x, _Tp _y, _Tp _z);
|
||||
Point3_(const Point3_& pt);
|
||||
explicit Point3_(const Point_<_Tp>& pt);
|
||||
Point3_(const CvPoint3D32f& pt);
|
||||
Point3_(const Vec<_Tp, 3>& v);
|
||||
|
||||
Point3_& operator = (const Point3_& pt);
|
||||
//! conversion to another data type
|
||||
template<typename _Tp2> operator Point3_<_Tp2>() const;
|
||||
//! conversion to the old-style CvPoint...
|
||||
operator CvPoint3D32f() const;
|
||||
//! conversion to cv::Vec<>
|
||||
operator Vec<_Tp, 3>() const;
|
||||
|
||||
//! dot product
|
||||
_Tp dot(const Point3_& pt) const;
|
||||
//! dot product computed in double-precision arithmetics
|
||||
double ddot(const Point3_& pt) const;
|
||||
//! cross product of the 2 3D points
|
||||
Point3_ cross(const Point3_& pt) const;
|
||||
|
||||
_Tp x, y, z; //< the point coordinates
|
||||
};
|
||||
|
||||
//////////////////////////////// Size_ ////////////////////////////////
|
||||
|
||||
/*!
|
||||
@@ -726,17 +608,10 @@ public:
|
||||
|
||||
shorter aliases for the most popular cv::Point_<>, cv::Size_<> and cv::Rect_<> specializations
|
||||
*/
|
||||
typedef Point_<int> Point2i;
|
||||
typedef Point2i Point;
|
||||
typedef Size_<int> Size2i;
|
||||
typedef Size2i Size;
|
||||
typedef Rect_<int> Rect;
|
||||
typedef Point_<float> Point2f;
|
||||
typedef Point_<double> Point2d;
|
||||
typedef Size_<float> Size2f;
|
||||
typedef Point3_<int> Point3i;
|
||||
typedef Point3_<float> Point3f;
|
||||
typedef Point3_<double> Point3d;
|
||||
|
||||
|
||||
/*!
|
||||
|
@@ -98,85 +98,6 @@
|
||||
namespace cv
|
||||
{
|
||||
|
||||
/////////////// saturate_cast (used in image & signal processing) ///////////////////
|
||||
|
||||
template<typename _Tp> static inline _Tp saturate_cast(uchar v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(schar v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(ushort v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(short v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(unsigned v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(int v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(float v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(double v) { return _Tp(v); }
|
||||
|
||||
template<> inline uchar saturate_cast<uchar>(schar v)
|
||||
{ return (uchar)std::max((int)v, 0); }
|
||||
template<> inline uchar saturate_cast<uchar>(ushort v)
|
||||
{ return (uchar)std::min((unsigned)v, (unsigned)UCHAR_MAX); }
|
||||
template<> inline uchar saturate_cast<uchar>(int v)
|
||||
{ return (uchar)((unsigned)v <= UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0); }
|
||||
template<> inline uchar saturate_cast<uchar>(short v)
|
||||
{ return saturate_cast<uchar>((int)v); }
|
||||
template<> inline uchar saturate_cast<uchar>(unsigned v)
|
||||
{ return (uchar)std::min(v, (unsigned)UCHAR_MAX); }
|
||||
template<> inline uchar saturate_cast<uchar>(float v)
|
||||
{ int iv = cvRound(v); return saturate_cast<uchar>(iv); }
|
||||
template<> inline uchar saturate_cast<uchar>(double v)
|
||||
{ int iv = cvRound(v); return saturate_cast<uchar>(iv); }
|
||||
|
||||
template<> inline schar saturate_cast<schar>(uchar v)
|
||||
{ return (schar)std::min((int)v, SCHAR_MAX); }
|
||||
template<> inline schar saturate_cast<schar>(ushort v)
|
||||
{ return (schar)std::min((unsigned)v, (unsigned)SCHAR_MAX); }
|
||||
template<> inline schar saturate_cast<schar>(int v)
|
||||
{
|
||||
return (schar)((unsigned)(v-SCHAR_MIN) <= (unsigned)UCHAR_MAX ?
|
||||
v : v > 0 ? SCHAR_MAX : SCHAR_MIN);
|
||||
}
|
||||
template<> inline schar saturate_cast<schar>(short v)
|
||||
{ return saturate_cast<schar>((int)v); }
|
||||
template<> inline schar saturate_cast<schar>(unsigned v)
|
||||
{ return (schar)std::min(v, (unsigned)SCHAR_MAX); }
|
||||
|
||||
template<> inline schar saturate_cast<schar>(float v)
|
||||
{ int iv = cvRound(v); return saturate_cast<schar>(iv); }
|
||||
template<> inline schar saturate_cast<schar>(double v)
|
||||
{ int iv = cvRound(v); return saturate_cast<schar>(iv); }
|
||||
|
||||
template<> inline ushort saturate_cast<ushort>(schar v)
|
||||
{ return (ushort)std::max((int)v, 0); }
|
||||
template<> inline ushort saturate_cast<ushort>(short v)
|
||||
{ return (ushort)std::max((int)v, 0); }
|
||||
template<> inline ushort saturate_cast<ushort>(int v)
|
||||
{ return (ushort)((unsigned)v <= (unsigned)USHRT_MAX ? v : v > 0 ? USHRT_MAX : 0); }
|
||||
template<> inline ushort saturate_cast<ushort>(unsigned v)
|
||||
{ return (ushort)std::min(v, (unsigned)USHRT_MAX); }
|
||||
template<> inline ushort saturate_cast<ushort>(float v)
|
||||
{ int iv = cvRound(v); return saturate_cast<ushort>(iv); }
|
||||
template<> inline ushort saturate_cast<ushort>(double v)
|
||||
{ int iv = cvRound(v); return saturate_cast<ushort>(iv); }
|
||||
|
||||
template<> inline short saturate_cast<short>(ushort v)
|
||||
{ return (short)std::min((int)v, SHRT_MAX); }
|
||||
template<> inline short saturate_cast<short>(int v)
|
||||
{
|
||||
return (short)((unsigned)(v - SHRT_MIN) <= (unsigned)USHRT_MAX ?
|
||||
v : v > 0 ? SHRT_MAX : SHRT_MIN);
|
||||
}
|
||||
template<> inline short saturate_cast<short>(unsigned v)
|
||||
{ return (short)std::min(v, (unsigned)SHRT_MAX); }
|
||||
template<> inline short saturate_cast<short>(float v)
|
||||
{ int iv = cvRound(v); return saturate_cast<short>(iv); }
|
||||
template<> inline short saturate_cast<short>(double v)
|
||||
{ int iv = cvRound(v); return saturate_cast<short>(iv); }
|
||||
|
||||
template<> inline int saturate_cast<int>(float v) { return cvRound(v); }
|
||||
template<> inline int saturate_cast<int>(double v) { return cvRound(v); }
|
||||
|
||||
// we intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.
|
||||
template<> inline unsigned saturate_cast<unsigned>(float v){ return cvRound(v); }
|
||||
template<> inline unsigned saturate_cast<unsigned>(double v) { return cvRound(v); }
|
||||
|
||||
inline int fast_abs(uchar v) { return v; }
|
||||
inline int fast_abs(schar v) { return std::abs((int)v); }
|
||||
inline int fast_abs(ushort v) { return v; }
|
||||
@@ -1605,9 +1526,6 @@ Complex<_Tp> operator /= (const Complex<_Tp>& a, _Tp b)
|
||||
template<typename _Tp> inline Point_<_Tp>::Point_() : x(0), y(0) {}
|
||||
template<typename _Tp> inline Point_<_Tp>::Point_(_Tp _x, _Tp _y) : x(_x), y(_y) {}
|
||||
template<typename _Tp> inline Point_<_Tp>::Point_(const Point_& pt) : x(pt.x), y(pt.y) {}
|
||||
template<typename _Tp> inline Point_<_Tp>::Point_(const CvPoint& pt) : x((_Tp)pt.x), y((_Tp)pt.y) {}
|
||||
template<typename _Tp> inline Point_<_Tp>::Point_(const CvPoint2D32f& pt)
|
||||
: x(saturate_cast<_Tp>(pt.x)), y(saturate_cast<_Tp>(pt.y)) {}
|
||||
template<typename _Tp> inline Point_<_Tp>::Point_(const Size_<_Tp>& sz) : x(sz.width), y(sz.height) {}
|
||||
template<typename _Tp> inline Point_<_Tp>::Point_(const Vec<_Tp,2>& v) : x(v[0]), y(v[1]) {}
|
||||
template<typename _Tp> inline Point_<_Tp>& Point_<_Tp>::operator = (const Point_& pt)
|
||||
@@ -1615,10 +1533,6 @@ template<typename _Tp> inline Point_<_Tp>& Point_<_Tp>::operator = (const Point_
|
||||
|
||||
template<typename _Tp> template<typename _Tp2> inline Point_<_Tp>::operator Point_<_Tp2>() const
|
||||
{ return Point_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y)); }
|
||||
template<typename _Tp> inline Point_<_Tp>::operator CvPoint() const
|
||||
{ return cvPoint(saturate_cast<int>(x), saturate_cast<int>(y)); }
|
||||
template<typename _Tp> inline Point_<_Tp>::operator CvPoint2D32f() const
|
||||
{ return cvPoint2D32f((float)x, (float)y); }
|
||||
template<typename _Tp> inline Point_<_Tp>::operator Vec<_Tp, 2>() const
|
||||
{ return Vec<_Tp, 2>(x, y); }
|
||||
|
||||
@@ -1712,16 +1626,11 @@ template<typename _Tp> inline Point3_<_Tp>::Point3_() : x(0), y(0), z(0) {}
|
||||
template<typename _Tp> inline Point3_<_Tp>::Point3_(_Tp _x, _Tp _y, _Tp _z) : x(_x), y(_y), z(_z) {}
|
||||
template<typename _Tp> inline Point3_<_Tp>::Point3_(const Point3_& pt) : x(pt.x), y(pt.y), z(pt.z) {}
|
||||
template<typename _Tp> inline Point3_<_Tp>::Point3_(const Point_<_Tp>& pt) : x(pt.x), y(pt.y), z(_Tp()) {}
|
||||
template<typename _Tp> inline Point3_<_Tp>::Point3_(const CvPoint3D32f& pt) :
|
||||
x(saturate_cast<_Tp>(pt.x)), y(saturate_cast<_Tp>(pt.y)), z(saturate_cast<_Tp>(pt.z)) {}
|
||||
template<typename _Tp> inline Point3_<_Tp>::Point3_(const Vec<_Tp, 3>& v) : x(v[0]), y(v[1]), z(v[2]) {}
|
||||
|
||||
template<typename _Tp> template<typename _Tp2> inline Point3_<_Tp>::operator Point3_<_Tp2>() const
|
||||
{ return Point3_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(z)); }
|
||||
|
||||
template<typename _Tp> inline Point3_<_Tp>::operator CvPoint3D32f() const
|
||||
{ return cvPoint3D32f((float)x, (float)y, (float)z); }
|
||||
|
||||
template<typename _Tp> inline Point3_<_Tp>::operator Vec<_Tp, 3>() const
|
||||
{ return Vec<_Tp, 3>(x, y, z); }
|
||||
|
||||
|
251
modules/core/include/opencv2/core/types.hpp
Normal file
251
modules/core/include/opencv2/core/types.hpp
Normal file
@@ -0,0 +1,251 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_TYPES_HPP__
|
||||
#define __OPENCV_CORE_TYPES_HPP__
|
||||
|
||||
#include <climits>
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
# include <complex>
|
||||
#endif
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "opencv2/core/cvstd.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
template<typename _Tp> class CV_EXPORTS Size_;
|
||||
template<typename _Tp> class CV_EXPORTS Point_;
|
||||
template<typename _Tp> class CV_EXPORTS Rect_;
|
||||
|
||||
template<typename _Tp, int cn> class CV_EXPORTS Vec;
|
||||
//template<typename _Tp, int m, int n> class CV_EXPORTS Matx;
|
||||
|
||||
|
||||
|
||||
/////////////// saturate_cast (used in image & signal processing) ///////////////////
|
||||
|
||||
template<typename _Tp> static inline _Tp saturate_cast(uchar v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(schar v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(ushort v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(short v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(unsigned v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(int v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(float v) { return _Tp(v); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(double v) { return _Tp(v); }
|
||||
|
||||
template<> inline uchar saturate_cast<uchar>(schar v) { return (uchar)std::max((int)v, 0); }
|
||||
template<> inline uchar saturate_cast<uchar>(ushort v) { return (uchar)std::min((unsigned)v, (unsigned)UCHAR_MAX); }
|
||||
template<> inline uchar saturate_cast<uchar>(int v) { return (uchar)((unsigned)v <= UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0); }
|
||||
template<> inline uchar saturate_cast<uchar>(short v) { return saturate_cast<uchar>((int)v); }
|
||||
template<> inline uchar saturate_cast<uchar>(unsigned v) { return (uchar)std::min(v, (unsigned)UCHAR_MAX); }
|
||||
template<> inline uchar saturate_cast<uchar>(float v) { int iv = cvRound(v); return saturate_cast<uchar>(iv); }
|
||||
template<> inline uchar saturate_cast<uchar>(double v) { int iv = cvRound(v); return saturate_cast<uchar>(iv); }
|
||||
|
||||
template<> inline schar saturate_cast<schar>(uchar v) { return (schar)std::min((int)v, SCHAR_MAX); }
|
||||
template<> inline schar saturate_cast<schar>(ushort v) { return (schar)std::min((unsigned)v, (unsigned)SCHAR_MAX); }
|
||||
template<> inline schar saturate_cast<schar>(int v) { return (schar)((unsigned)(v-SCHAR_MIN) <= (unsigned)UCHAR_MAX ? v : v > 0 ? SCHAR_MAX : SCHAR_MIN); }
|
||||
template<> inline schar saturate_cast<schar>(short v) { return saturate_cast<schar>((int)v); }
|
||||
template<> inline schar saturate_cast<schar>(unsigned v) { return (schar)std::min(v, (unsigned)SCHAR_MAX); }
|
||||
template<> inline schar saturate_cast<schar>(float v) { int iv = cvRound(v); return saturate_cast<schar>(iv); }
|
||||
template<> inline schar saturate_cast<schar>(double v) { int iv = cvRound(v); return saturate_cast<schar>(iv); }
|
||||
|
||||
template<> inline ushort saturate_cast<ushort>(schar v) { return (ushort)std::max((int)v, 0); }
|
||||
template<> inline ushort saturate_cast<ushort>(short v) { return (ushort)std::max((int)v, 0); }
|
||||
template<> inline ushort saturate_cast<ushort>(int v) { return (ushort)((unsigned)v <= (unsigned)USHRT_MAX ? v : v > 0 ? USHRT_MAX : 0); }
|
||||
template<> inline ushort saturate_cast<ushort>(unsigned v) { return (ushort)std::min(v, (unsigned)USHRT_MAX); }
|
||||
template<> inline ushort saturate_cast<ushort>(float v) { int iv = cvRound(v); return saturate_cast<ushort>(iv); }
|
||||
template<> inline ushort saturate_cast<ushort>(double v) { int iv = cvRound(v); return saturate_cast<ushort>(iv); }
|
||||
|
||||
template<> inline short saturate_cast<short>(ushort v) { return (short)std::min((int)v, SHRT_MAX); }
|
||||
template<> inline short saturate_cast<short>(int v) { return (short)((unsigned)(v - SHRT_MIN) <= (unsigned)USHRT_MAX ? v : v > 0 ? SHRT_MAX : SHRT_MIN); }
|
||||
template<> inline short saturate_cast<short>(unsigned v) { return (short)std::min(v, (unsigned)SHRT_MAX); }
|
||||
template<> inline short saturate_cast<short>(float v) { int iv = cvRound(v); return saturate_cast<short>(iv); }
|
||||
template<> inline short saturate_cast<short>(double v) { int iv = cvRound(v); return saturate_cast<short>(iv); }
|
||||
|
||||
template<> inline int saturate_cast<int>(float v) { return cvRound(v); }
|
||||
template<> inline int saturate_cast<int>(double v) { return cvRound(v); }
|
||||
|
||||
// we intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.
|
||||
template<> inline unsigned saturate_cast<unsigned>(float v) { return cvRound(v); }
|
||||
template<> inline unsigned saturate_cast<unsigned>(double v) { return cvRound(v); }
|
||||
|
||||
|
||||
|
||||
//////////////////////////////// Complex //////////////////////////////
|
||||
|
||||
/*!
|
||||
A complex number class.
|
||||
|
||||
The template class is similar and compatible with std::complex, however it provides slightly
|
||||
more convenient access to the real and imaginary parts using through the simple field access, as opposite
|
||||
to std::complex::real() and std::complex::imag().
|
||||
*/
|
||||
template<typename _Tp> class CV_EXPORTS Complex
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructors
|
||||
Complex();
|
||||
Complex( _Tp _re, _Tp _im=0 );
|
||||
|
||||
//! conversion to another data type
|
||||
template<typename T2> operator Complex<T2>() const;
|
||||
//! conjugation
|
||||
Complex conj() const;
|
||||
|
||||
_Tp re, im; //< the real and the imaginary parts
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
Complex( const std::complex<_Tp>& c );
|
||||
operator std::complex<_Tp>() const;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*!
|
||||
\typedef
|
||||
*/
|
||||
typedef Complex<float> Complexf;
|
||||
typedef Complex<double> Complexd;
|
||||
|
||||
|
||||
|
||||
//////////////////////////////// Point_ ////////////////////////////////
|
||||
|
||||
/*!
|
||||
template 2D point class.
|
||||
|
||||
The class defines a point in 2D space. Data type of the point coordinates is specified
|
||||
as a template parameter. There are a few shorter aliases available for user convenience.
|
||||
See cv::Point, cv::Point2i, cv::Point2f and cv::Point2d.
|
||||
*/
|
||||
template<typename _Tp> class CV_EXPORTS Point_
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
|
||||
// various constructors
|
||||
Point_();
|
||||
Point_(_Tp _x, _Tp _y);
|
||||
Point_(const Point_& pt);
|
||||
Point_(const Size_<_Tp>& sz);
|
||||
Point_(const Vec<_Tp, 2>& v);
|
||||
|
||||
Point_& operator = (const Point_& pt);
|
||||
//! conversion to another data type
|
||||
template<typename _Tp2> operator Point_<_Tp2>() const;
|
||||
|
||||
//! conversion to the old-style C structures
|
||||
operator Vec<_Tp, 2>() const;
|
||||
|
||||
//! dot product
|
||||
_Tp dot(const Point_& pt) const;
|
||||
//! dot product computed in double-precision arithmetics
|
||||
double ddot(const Point_& pt) const;
|
||||
//! cross-product
|
||||
double cross(const Point_& pt) const;
|
||||
//! checks whether the point is inside the specified rectangle
|
||||
bool inside(const Rect_<_Tp>& r) const;
|
||||
|
||||
_Tp x, y; //< the point coordinates
|
||||
};
|
||||
|
||||
/*!
|
||||
\typedef
|
||||
*/
|
||||
typedef Point_<int> Point2i;
|
||||
typedef Point_<float> Point2f;
|
||||
typedef Point_<double> Point2d;
|
||||
typedef Point2i Point;
|
||||
|
||||
|
||||
|
||||
//////////////////////////////// Point3_ ////////////////////////////////
|
||||
|
||||
/*!
|
||||
template 3D point class.
|
||||
|
||||
The class defines a point in 3D space. Data type of the point coordinates is specified
|
||||
as a template parameter.
|
||||
|
||||
\see cv::Point3i, cv::Point3f and cv::Point3d
|
||||
*/
|
||||
template<typename _Tp> class CV_EXPORTS Point3_
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
|
||||
// various constructors
|
||||
Point3_();
|
||||
Point3_(_Tp _x, _Tp _y, _Tp _z);
|
||||
Point3_(const Point3_& pt);
|
||||
explicit Point3_(const Point_<_Tp>& pt);
|
||||
Point3_(const Vec<_Tp, 3>& v);
|
||||
|
||||
Point3_& operator = (const Point3_& pt);
|
||||
//! conversion to another data type
|
||||
template<typename _Tp2> operator Point3_<_Tp2>() const;
|
||||
//! conversion to cv::Vec<>
|
||||
operator Vec<_Tp, 3>() const;
|
||||
|
||||
//! dot product
|
||||
_Tp dot(const Point3_& pt) const;
|
||||
//! dot product computed in double-precision arithmetics
|
||||
double ddot(const Point3_& pt) const;
|
||||
//! cross product of the 2 3D points
|
||||
Point3_ cross(const Point3_& pt) const;
|
||||
|
||||
_Tp x, y, z; //< the point coordinates
|
||||
};
|
||||
|
||||
/*!
|
||||
\typedef
|
||||
*/
|
||||
typedef Point3_<int> Point3i;
|
||||
typedef Point3_<float> Point3f;
|
||||
typedef Point3_<double> Point3d;
|
||||
|
||||
} // cv
|
||||
|
||||
#endif //__OPENCV_CORE_TYPES_HPP__
|
@@ -92,6 +92,10 @@
|
||||
# define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
# include "opencv2/core/types.hpp"
|
||||
#endif
|
||||
|
||||
/* CvArr* is used to pass arbitrary
|
||||
* array-like data structures
|
||||
* into functions where the particular
|
||||
@@ -749,6 +753,14 @@ typedef struct CvPoint
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
#ifdef __cplusplus
|
||||
CvPoint(int _x = 0, int _y = 0): x(_x), y(_y) {}
|
||||
template<typename _Tp>
|
||||
CvPoint(const cv::Point_<_Tp>& pt): x((int)pt.x), y((int)pt.y) {}
|
||||
template<typename _Tp>
|
||||
operator cv::Point_<_Tp>() const { return cv::Point_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y)); }
|
||||
#endif
|
||||
}
|
||||
CvPoint;
|
||||
|
||||
@@ -768,6 +780,14 @@ typedef struct CvPoint2D32f
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
|
||||
#ifdef __cplusplus
|
||||
CvPoint2D32f(float _x = 0, float _y = 0): x(_x), y(_y) {}
|
||||
template<typename _Tp>
|
||||
CvPoint2D32f(const cv::Point_<_Tp>& pt): x((float)pt.x), y((float)pt.y) {}
|
||||
template<typename _Tp>
|
||||
operator cv::Point_<_Tp>() const { return cv::Point_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y)); }
|
||||
#endif
|
||||
}
|
||||
CvPoint2D32f;
|
||||
|
||||
@@ -804,6 +824,14 @@ typedef struct CvPoint3D32f
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
|
||||
#ifdef __cplusplus
|
||||
CvPoint3D32f(float _x = 0, float _y = 0, float _z = 0): x(_x), y(_y), z(_z) {}
|
||||
template<typename _Tp>
|
||||
CvPoint3D32f(const cv::Point3_<_Tp>& pt): x((float)pt.x), y((float)pt.y), z((float)pt.z) {}
|
||||
template<typename _Tp>
|
||||
operator cv::Point3_<_Tp>() const { return cv::Point3_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y), cv::saturate_cast<_Tp>(z)); }
|
||||
#endif
|
||||
}
|
||||
CvPoint3D32f;
|
||||
|
||||
|
Reference in New Issue
Block a user