parent
4569e51b3e
commit
63436373d2
|
@ -143,7 +143,6 @@ env = Environment(
|
|||
"#phonelibs/openmax/include",
|
||||
"#phonelibs/json11",
|
||||
"#phonelibs/curl/include",
|
||||
#"#phonelibs/opencv/include", # use opencv4 instead
|
||||
"#phonelibs/libgralloc/include",
|
||||
"#phonelibs/android_frameworks_native/include",
|
||||
"#phonelibs/android_hardware_libhardware/include",
|
||||
|
|
|
@ -1,515 +0,0 @@
|
|||
/*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_AFFINE3_HPP__
|
||||
#define __OPENCV_CORE_AFFINE3_HPP__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
/*! @file */
|
||||
|
||||
namespace cv
|
||||
{
|
||||
template<typename T>
|
||||
class Affine3
|
||||
{
|
||||
public:
|
||||
typedef T float_type;
|
||||
typedef Matx<float_type, 3, 3> Mat3;
|
||||
typedef Matx<float_type, 4, 4> Mat4;
|
||||
typedef Vec<float_type, 3> Vec3;
|
||||
|
||||
Affine3();
|
||||
|
||||
//Augmented affine matrix
|
||||
Affine3(const Mat4& affine);
|
||||
|
||||
//Rotation matrix
|
||||
Affine3(const Mat3& R, const Vec3& t = Vec3::all(0));
|
||||
|
||||
//Rodrigues vector
|
||||
Affine3(const Vec3& rvec, const Vec3& t = Vec3::all(0));
|
||||
|
||||
//Combines all contructors above. Supports 4x4, 4x3, 3x3, 1x3, 3x1 sizes of data matrix
|
||||
explicit Affine3(const Mat& data, const Vec3& t = Vec3::all(0));
|
||||
|
||||
//From 16th element array
|
||||
explicit Affine3(const float_type* vals);
|
||||
|
||||
static Affine3 Identity();
|
||||
|
||||
//Rotation matrix
|
||||
void rotation(const Mat3& R);
|
||||
|
||||
//Rodrigues vector
|
||||
void rotation(const Vec3& rvec);
|
||||
|
||||
//Combines rotation methods above. Suports 3x3, 1x3, 3x1 sizes of data matrix;
|
||||
void rotation(const Mat& data);
|
||||
|
||||
void linear(const Mat3& L);
|
||||
void translation(const Vec3& t);
|
||||
|
||||
Mat3 rotation() const;
|
||||
Mat3 linear() const;
|
||||
Vec3 translation() const;
|
||||
|
||||
//Rodrigues vector
|
||||
Vec3 rvec() const;
|
||||
|
||||
Affine3 inv(int method = cv::DECOMP_SVD) const;
|
||||
|
||||
// a.rotate(R) is equivalent to Affine(R, 0) * a;
|
||||
Affine3 rotate(const Mat3& R) const;
|
||||
|
||||
// a.rotate(R) is equivalent to Affine(rvec, 0) * a;
|
||||
Affine3 rotate(const Vec3& rvec) const;
|
||||
|
||||
// a.translate(t) is equivalent to Affine(E, t) * a;
|
||||
Affine3 translate(const Vec3& t) const;
|
||||
|
||||
// a.concatenate(affine) is equivalent to affine * a;
|
||||
Affine3 concatenate(const Affine3& affine) const;
|
||||
|
||||
template <typename Y> operator Affine3<Y>() const;
|
||||
|
||||
template <typename Y> Affine3<Y> cast() const;
|
||||
|
||||
Mat4 matrix;
|
||||
|
||||
#if defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H
|
||||
Affine3(const Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>& affine);
|
||||
Affine3(const Eigen::Transform<T, 3, Eigen::Affine>& affine);
|
||||
operator Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>() const;
|
||||
operator Eigen::Transform<T, 3, Eigen::Affine>() const;
|
||||
#endif
|
||||
};
|
||||
|
||||
template<typename T> static
|
||||
Affine3<T> operator*(const Affine3<T>& affine1, const Affine3<T>& affine2);
|
||||
|
||||
template<typename T, typename V> static
|
||||
V operator*(const Affine3<T>& affine, const V& vector);
|
||||
|
||||
typedef Affine3<float> Affine3f;
|
||||
typedef Affine3<double> Affine3d;
|
||||
|
||||
static Vec3f operator*(const Affine3f& affine, const Vec3f& vector);
|
||||
static Vec3d operator*(const Affine3d& affine, const Vec3d& vector);
|
||||
|
||||
template<typename _Tp> class DataType< Affine3<_Tp> >
|
||||
{
|
||||
public:
|
||||
typedef Affine3<_Tp> value_type;
|
||||
typedef Affine3<typename DataType<_Tp>::work_type> work_type;
|
||||
typedef _Tp channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = 16,
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// Implementaiton
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3()
|
||||
: matrix(Mat4::eye())
|
||||
{}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Mat4& affine)
|
||||
: matrix(affine)
|
||||
{}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Mat3& R, const Vec3& t)
|
||||
{
|
||||
rotation(R);
|
||||
translation(t);
|
||||
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
|
||||
matrix.val[15] = 1;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Vec3& _rvec, const Vec3& t)
|
||||
{
|
||||
rotation(_rvec);
|
||||
translation(t);
|
||||
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
|
||||
matrix.val[15] = 1;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const cv::Mat& data, const Vec3& t)
|
||||
{
|
||||
CV_Assert(data.type() == cv::DataType<T>::type);
|
||||
|
||||
if (data.cols == 4 && data.rows == 4)
|
||||
{
|
||||
data.copyTo(matrix);
|
||||
return;
|
||||
}
|
||||
else if (data.cols == 4 && data.rows == 3)
|
||||
{
|
||||
rotation(data(Rect(0, 0, 3, 3)));
|
||||
translation(data(Rect(3, 0, 1, 3)));
|
||||
}
|
||||
else
|
||||
{
|
||||
rotation(data);
|
||||
translation(t);
|
||||
}
|
||||
|
||||
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
|
||||
matrix.val[15] = 1;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const float_type* vals) : matrix(vals)
|
||||
{}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::Identity()
|
||||
{
|
||||
return Affine3<T>(cv::Affine3<T>::Mat4::eye());
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::rotation(const Mat3& R)
|
||||
{
|
||||
linear(R);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::rotation(const Vec3& _rvec)
|
||||
{
|
||||
double rx = _rvec[0], ry = _rvec[1], rz = _rvec[2];
|
||||
double theta = std::sqrt(rx*rx + ry*ry + rz*rz);
|
||||
|
||||
if (theta < DBL_EPSILON)
|
||||
rotation(Mat3::eye());
|
||||
else
|
||||
{
|
||||
const double I[] = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
|
||||
|
||||
double c = std::cos(theta);
|
||||
double s = std::sin(theta);
|
||||
double c1 = 1. - c;
|
||||
double itheta = (theta != 0) ? 1./theta : 0.;
|
||||
|
||||
rx *= itheta; ry *= itheta; rz *= itheta;
|
||||
|
||||
double rrt[] = { rx*rx, rx*ry, rx*rz, rx*ry, ry*ry, ry*rz, rx*rz, ry*rz, rz*rz };
|
||||
double _r_x_[] = { 0, -rz, ry, rz, 0, -rx, -ry, rx, 0 };
|
||||
Mat3 R;
|
||||
|
||||
// R = cos(theta)*I + (1 - cos(theta))*r*rT + sin(theta)*[r_x]
|
||||
// where [r_x] is [0 -rz ry; rz 0 -rx; -ry rx 0]
|
||||
for(int k = 0; k < 9; ++k)
|
||||
R.val[k] = static_cast<float_type>(c*I[k] + c1*rrt[k] + s*_r_x_[k]);
|
||||
|
||||
rotation(R);
|
||||
}
|
||||
}
|
||||
|
||||
//Combines rotation methods above. Suports 3x3, 1x3, 3x1 sizes of data matrix;
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::rotation(const cv::Mat& data)
|
||||
{
|
||||
CV_Assert(data.type() == cv::DataType<T>::type);
|
||||
|
||||
if (data.cols == 3 && data.rows == 3)
|
||||
{
|
||||
Mat3 R;
|
||||
data.copyTo(R);
|
||||
rotation(R);
|
||||
}
|
||||
else if ((data.cols == 3 && data.rows == 1) || (data.cols == 1 && data.rows == 3))
|
||||
{
|
||||
Vec3 _rvec;
|
||||
data.reshape(1, 3).copyTo(_rvec);
|
||||
rotation(_rvec);
|
||||
}
|
||||
else
|
||||
CV_Assert(!"Input marix can be 3x3, 1x3 or 3x1");
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::linear(const Mat3& L)
|
||||
{
|
||||
matrix.val[0] = L.val[0]; matrix.val[1] = L.val[1]; matrix.val[ 2] = L.val[2];
|
||||
matrix.val[4] = L.val[3]; matrix.val[5] = L.val[4]; matrix.val[ 6] = L.val[5];
|
||||
matrix.val[8] = L.val[6]; matrix.val[9] = L.val[7]; matrix.val[10] = L.val[8];
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::translation(const Vec3& t)
|
||||
{
|
||||
matrix.val[3] = t[0]; matrix.val[7] = t[1]; matrix.val[11] = t[2];
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
typename cv::Affine3<T>::Mat3 cv::Affine3<T>::rotation() const
|
||||
{
|
||||
return linear();
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
typename cv::Affine3<T>::Mat3 cv::Affine3<T>::linear() const
|
||||
{
|
||||
typename cv::Affine3<T>::Mat3 R;
|
||||
R.val[0] = matrix.val[0]; R.val[1] = matrix.val[1]; R.val[2] = matrix.val[ 2];
|
||||
R.val[3] = matrix.val[4]; R.val[4] = matrix.val[5]; R.val[5] = matrix.val[ 6];
|
||||
R.val[6] = matrix.val[8]; R.val[7] = matrix.val[9]; R.val[8] = matrix.val[10];
|
||||
return R;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
typename cv::Affine3<T>::Vec3 cv::Affine3<T>::translation() const
|
||||
{
|
||||
return Vec3(matrix.val[3], matrix.val[7], matrix.val[11]);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
typename cv::Affine3<T>::Vec3 cv::Affine3<T>::rvec() const
|
||||
{
|
||||
cv::Vec3d w;
|
||||
cv::Matx33d u, vt, R = rotation();
|
||||
cv::SVD::compute(R, w, u, vt, cv::SVD::FULL_UV + cv::SVD::MODIFY_A);
|
||||
R = u * vt;
|
||||
|
||||
double rx = R.val[7] - R.val[5];
|
||||
double ry = R.val[2] - R.val[6];
|
||||
double rz = R.val[3] - R.val[1];
|
||||
|
||||
double s = std::sqrt((rx*rx + ry*ry + rz*rz)*0.25);
|
||||
double c = (R.val[0] + R.val[4] + R.val[8] - 1) * 0.5;
|
||||
c = c > 1.0 ? 1.0 : c < -1.0 ? -1.0 : c;
|
||||
double theta = acos(c);
|
||||
|
||||
if( s < 1e-5 )
|
||||
{
|
||||
if( c > 0 )
|
||||
rx = ry = rz = 0;
|
||||
else
|
||||
{
|
||||
double t;
|
||||
t = (R.val[0] + 1) * 0.5;
|
||||
rx = std::sqrt(std::max(t, 0.0));
|
||||
t = (R.val[4] + 1) * 0.5;
|
||||
ry = std::sqrt(std::max(t, 0.0)) * (R.val[1] < 0 ? -1.0 : 1.0);
|
||||
t = (R.val[8] + 1) * 0.5;
|
||||
rz = std::sqrt(std::max(t, 0.0)) * (R.val[2] < 0 ? -1.0 : 1.0);
|
||||
|
||||
if( fabs(rx) < fabs(ry) && fabs(rx) < fabs(rz) && (R.val[5] > 0) != (ry*rz > 0) )
|
||||
rz = -rz;
|
||||
theta /= std::sqrt(rx*rx + ry*ry + rz*rz);
|
||||
rx *= theta;
|
||||
ry *= theta;
|
||||
rz *= theta;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double vth = 1/(2*s);
|
||||
vth *= theta;
|
||||
rx *= vth; ry *= vth; rz *= vth;
|
||||
}
|
||||
|
||||
return cv::Vec3d(rx, ry, rz);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::inv(int method) const
|
||||
{
|
||||
return matrix.inv(method);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::rotate(const Mat3& R) const
|
||||
{
|
||||
Mat3 Lc = linear();
|
||||
Vec3 tc = translation();
|
||||
Mat4 result;
|
||||
result.val[12] = result.val[13] = result.val[14] = 0;
|
||||
result.val[15] = 1;
|
||||
|
||||
for(int j = 0; j < 3; ++j)
|
||||
{
|
||||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
float_type value = 0;
|
||||
for(int k = 0; k < 3; ++k)
|
||||
value += R(j, k) * Lc(k, i);
|
||||
result(j, i) = value;
|
||||
}
|
||||
|
||||
result(j, 3) = R.row(j).dot(tc.t());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::rotate(const Vec3& _rvec) const
|
||||
{
|
||||
return rotate(Affine3f(_rvec).rotation());
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::translate(const Vec3& t) const
|
||||
{
|
||||
Mat4 m = matrix;
|
||||
m.val[ 3] += t[0];
|
||||
m.val[ 7] += t[1];
|
||||
m.val[11] += t[2];
|
||||
return m;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::concatenate(const Affine3<T>& affine) const
|
||||
{
|
||||
return (*this).rotate(affine.rotation()).translate(affine.translation());
|
||||
}
|
||||
|
||||
template<typename T> template <typename Y> inline
|
||||
cv::Affine3<T>::operator Affine3<Y>() const
|
||||
{
|
||||
return Affine3<Y>(matrix);
|
||||
}
|
||||
|
||||
template<typename T> template <typename Y> inline
|
||||
cv::Affine3<Y> cv::Affine3<T>::cast() const
|
||||
{
|
||||
return Affine3<Y>(matrix);
|
||||
}
|
||||
|
||||
/** @cond IGNORED */
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::operator*(const cv::Affine3<T>& affine1, const cv::Affine3<T>& affine2)
|
||||
{
|
||||
return affine2.concatenate(affine1);
|
||||
}
|
||||
|
||||
template<typename T, typename V> inline
|
||||
V cv::operator*(const cv::Affine3<T>& affine, const V& v)
|
||||
{
|
||||
const typename Affine3<T>::Mat4& m = affine.matrix;
|
||||
|
||||
V r;
|
||||
r.x = m.val[0] * v.x + m.val[1] * v.y + m.val[ 2] * v.z + m.val[ 3];
|
||||
r.y = m.val[4] * v.x + m.val[5] * v.y + m.val[ 6] * v.z + m.val[ 7];
|
||||
r.z = m.val[8] * v.x + m.val[9] * v.y + m.val[10] * v.z + m.val[11];
|
||||
return r;
|
||||
}
|
||||
/** @endcond */
|
||||
|
||||
static inline
|
||||
cv::Vec3f cv::operator*(const cv::Affine3f& affine, const cv::Vec3f& v)
|
||||
{
|
||||
const cv::Matx44f& m = affine.matrix;
|
||||
cv::Vec3f r;
|
||||
r.val[0] = m.val[0] * v[0] + m.val[1] * v[1] + m.val[ 2] * v[2] + m.val[ 3];
|
||||
r.val[1] = m.val[4] * v[0] + m.val[5] * v[1] + m.val[ 6] * v[2] + m.val[ 7];
|
||||
r.val[2] = m.val[8] * v[0] + m.val[9] * v[1] + m.val[10] * v[2] + m.val[11];
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline
|
||||
cv::Vec3d cv::operator*(const cv::Affine3d& affine, const cv::Vec3d& v)
|
||||
{
|
||||
const cv::Matx44d& m = affine.matrix;
|
||||
cv::Vec3d r;
|
||||
r.val[0] = m.val[0] * v[0] + m.val[1] * v[1] + m.val[ 2] * v[2] + m.val[ 3];
|
||||
r.val[1] = m.val[4] * v[0] + m.val[5] * v[1] + m.val[ 6] * v[2] + m.val[ 7];
|
||||
r.val[2] = m.val[8] * v[0] + m.val[9] * v[1] + m.val[10] * v[2] + m.val[11];
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>& affine)
|
||||
{
|
||||
cv::Mat(4, 4, cv::DataType<T>::type, affine.matrix().data()).copyTo(matrix);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Eigen::Transform<T, 3, Eigen::Affine>& affine)
|
||||
{
|
||||
Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)> a = affine;
|
||||
cv::Mat(4, 4, cv::DataType<T>::type, a.matrix().data()).copyTo(matrix);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::operator Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>() const
|
||||
{
|
||||
Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)> r;
|
||||
cv::Mat hdr(4, 4, cv::DataType<T>::type, r.matrix().data());
|
||||
cv::Mat(matrix, false).copyTo(hdr);
|
||||
return r;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::operator Eigen::Transform<T, 3, Eigen::Affine>() const
|
||||
{
|
||||
return this->operator Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>();
|
||||
}
|
||||
|
||||
#endif /* defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H */
|
||||
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __OPENCV_CORE_AFFINE3_HPP__ */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,194 +0,0 @@
|
|||
/*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.
|
||||
// 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_DEVPTRS_HPP__
|
||||
#define __OPENCV_CORE_DEVPTRS_HPP__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#ifdef __CUDACC__
|
||||
#define __CV_GPU_HOST_DEVICE__ __host__ __device__ __forceinline__
|
||||
#else
|
||||
#define __CV_GPU_HOST_DEVICE__
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace gpu
|
||||
{
|
||||
// Simple lightweight structures that encapsulates information about an image on device.
|
||||
// It is intended to pass to nvcc-compiled code. GpuMat depends on headers that nvcc can't compile
|
||||
|
||||
template <bool expr> struct StaticAssert;
|
||||
template <> struct StaticAssert<true> {static __CV_GPU_HOST_DEVICE__ void check(){}};
|
||||
|
||||
template<typename T> struct DevPtr
|
||||
{
|
||||
typedef T elem_type;
|
||||
typedef int index_type;
|
||||
|
||||
enum { elem_size = sizeof(elem_type) };
|
||||
|
||||
T* data;
|
||||
|
||||
__CV_GPU_HOST_DEVICE__ DevPtr() : data(0) {}
|
||||
__CV_GPU_HOST_DEVICE__ DevPtr(T* data_) : data(data_) {}
|
||||
|
||||
__CV_GPU_HOST_DEVICE__ size_t elemSize() const { return elem_size; }
|
||||
__CV_GPU_HOST_DEVICE__ operator T*() { return data; }
|
||||
__CV_GPU_HOST_DEVICE__ operator const T*() const { return data; }
|
||||
};
|
||||
|
||||
template<typename T> struct PtrSz : public DevPtr<T>
|
||||
{
|
||||
__CV_GPU_HOST_DEVICE__ PtrSz() : size(0) {}
|
||||
__CV_GPU_HOST_DEVICE__ PtrSz(T* data_, size_t size_) : DevPtr<T>(data_), size(size_) {}
|
||||
|
||||
size_t size;
|
||||
};
|
||||
|
||||
template<typename T> struct PtrStep : public DevPtr<T>
|
||||
{
|
||||
__CV_GPU_HOST_DEVICE__ PtrStep() : step(0) {}
|
||||
__CV_GPU_HOST_DEVICE__ PtrStep(T* data_, size_t step_) : DevPtr<T>(data_), step(step_) {}
|
||||
|
||||
/** \brief stride between two consecutive rows in bytes. Step is stored always and everywhere in bytes!!! */
|
||||
size_t step;
|
||||
|
||||
__CV_GPU_HOST_DEVICE__ T* ptr(int y = 0) { return ( T*)( ( char*)DevPtr<T>::data + y * step); }
|
||||
__CV_GPU_HOST_DEVICE__ const T* ptr(int y = 0) const { return (const T*)( (const char*)DevPtr<T>::data + y * step); }
|
||||
|
||||
__CV_GPU_HOST_DEVICE__ T& operator ()(int y, int x) { return ptr(y)[x]; }
|
||||
__CV_GPU_HOST_DEVICE__ const T& operator ()(int y, int x) const { return ptr(y)[x]; }
|
||||
};
|
||||
|
||||
template <typename T> struct PtrStepSz : public PtrStep<T>
|
||||
{
|
||||
__CV_GPU_HOST_DEVICE__ PtrStepSz() : cols(0), rows(0) {}
|
||||
__CV_GPU_HOST_DEVICE__ PtrStepSz(int rows_, int cols_, T* data_, size_t step_)
|
||||
: PtrStep<T>(data_, step_), cols(cols_), rows(rows_) {}
|
||||
|
||||
template <typename U>
|
||||
explicit PtrStepSz(const PtrStepSz<U>& d) : PtrStep<T>((T*)d.data, d.step), cols(d.cols), rows(d.rows){}
|
||||
|
||||
int cols;
|
||||
int rows;
|
||||
};
|
||||
|
||||
typedef PtrStepSz<unsigned char> PtrStepSzb;
|
||||
typedef PtrStepSz<float> PtrStepSzf;
|
||||
typedef PtrStepSz<int> PtrStepSzi;
|
||||
|
||||
typedef PtrStep<unsigned char> PtrStepb;
|
||||
typedef PtrStep<float> PtrStepf;
|
||||
typedef PtrStep<int> PtrStepi;
|
||||
|
||||
#if defined __GNUC__
|
||||
#define CV_GPU_DEPRECATED __attribute__ ((deprecated))
|
||||
#elif defined(__MSVC__) //|| defined(__CUDACC__)
|
||||
#pragma deprecated(DevMem2D_)
|
||||
#define CV_GPU_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
#define CV_GPU_DEPRECATED
|
||||
#endif
|
||||
|
||||
template <typename T> struct DevMem2D_ : public PtrStepSz<T>
|
||||
{
|
||||
CV_GPU_DEPRECATED DevMem2D_() {}
|
||||
CV_GPU_DEPRECATED DevMem2D_(int rows_, int cols_, T* data_, size_t step_) : PtrStepSz<T>(rows_, cols_, data_, step_) {}
|
||||
|
||||
template <typename U>
|
||||
explicit CV_GPU_DEPRECATED DevMem2D_(const DevMem2D_<U>& d) : PtrStepSz<T>(d.rows, d.cols, (T*)d.data, d.step) {}
|
||||
};
|
||||
|
||||
typedef DevMem2D_<unsigned char> DevMem2Db;
|
||||
typedef DevMem2Db DevMem2D;
|
||||
typedef DevMem2D_<float> DevMem2Df;
|
||||
typedef DevMem2D_<int> DevMem2Di;
|
||||
|
||||
template<typename T> struct PtrElemStep_ : public PtrStep<T>
|
||||
{
|
||||
PtrElemStep_(const DevMem2D_<T>& mem) : PtrStep<T>(mem.data, mem.step)
|
||||
{
|
||||
StaticAssert<256 % sizeof(T) == 0>::check();
|
||||
|
||||
PtrStep<T>::step /= PtrStep<T>::elem_size;
|
||||
}
|
||||
__CV_GPU_HOST_DEVICE__ T* ptr(int y = 0) { return PtrStep<T>::data + y * PtrStep<T>::step; }
|
||||
__CV_GPU_HOST_DEVICE__ const T* ptr(int y = 0) const { return PtrStep<T>::data + y * PtrStep<T>::step; }
|
||||
|
||||
__CV_GPU_HOST_DEVICE__ T& operator ()(int y, int x) { return ptr(y)[x]; }
|
||||
__CV_GPU_HOST_DEVICE__ const T& operator ()(int y, int x) const { return ptr(y)[x]; }
|
||||
};
|
||||
|
||||
template<typename T> struct PtrStep_ : public PtrStep<T>
|
||||
{
|
||||
PtrStep_() {}
|
||||
PtrStep_(const DevMem2D_<T>& mem) : PtrStep<T>(mem.data, mem.step) {}
|
||||
};
|
||||
|
||||
typedef PtrElemStep_<unsigned char> PtrElemStep;
|
||||
typedef PtrElemStep_<float> PtrElemStepf;
|
||||
typedef PtrElemStep_<int> PtrElemStepi;
|
||||
|
||||
//#undef CV_GPU_DEPRECATED
|
||||
|
||||
namespace device
|
||||
{
|
||||
using cv::gpu::PtrSz;
|
||||
using cv::gpu::PtrStep;
|
||||
using cv::gpu::PtrStepSz;
|
||||
|
||||
using cv::gpu::PtrStepSzb;
|
||||
using cv::gpu::PtrStepSzf;
|
||||
using cv::gpu::PtrStepSzi;
|
||||
|
||||
using cv::gpu::PtrStepb;
|
||||
using cv::gpu::PtrStepf;
|
||||
using cv::gpu::PtrStepi;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif /* __OPENCV_CORE_DEVPTRS_HPP__ */
|
|
@ -1,43 +0,0 @@
|
|||
/*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.
|
||||
// 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*/
|
||||
|
||||
#include "opencv2/core/cuda_devptrs.hpp"
|
|
@ -1,280 +0,0 @@
|
|||
/*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.
|
||||
// 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_EIGEN_HPP__
|
||||
#define __OPENCV_CORE_EIGEN_HPP__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/core/core.hpp"
|
||||
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( disable: 4714 ) //__forceinline is not inlined
|
||||
#pragma warning( disable: 4127 ) //conditional expression is constant
|
||||
#pragma warning( disable: 4244 ) //conversion from '__int64' to 'int', possible loss of data
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols>
|
||||
void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, Mat& dst )
|
||||
{
|
||||
if( !(src.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
Mat _src(src.cols(), src.rows(), DataType<_Tp>::type,
|
||||
(void*)src.data(), src.stride()*sizeof(_Tp));
|
||||
transpose(_src, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat _src(src.rows(), src.cols(), DataType<_Tp>::type,
|
||||
(void*)src.data(), src.stride()*sizeof(_Tp));
|
||||
_src.copyTo(dst);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols>
|
||||
void cv2eigen( const Mat& src,
|
||||
Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst )
|
||||
{
|
||||
CV_DbgAssert(src.rows == _rows && src.cols == _cols);
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
Mat _dst(src.cols, src.rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
if( src.type() == _dst.type() )
|
||||
transpose(src, _dst);
|
||||
else if( src.cols == src.rows )
|
||||
{
|
||||
src.convertTo(_dst, _dst.type());
|
||||
transpose(_dst, _dst);
|
||||
}
|
||||
else
|
||||
Mat(src.t()).convertTo(_dst, _dst.type());
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat _dst(src.rows, src.cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
src.convertTo(_dst, _dst.type());
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
}
|
||||
|
||||
// Matx case
|
||||
template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols>
|
||||
void cv2eigen( const Matx<_Tp, _rows, _cols>& src,
|
||||
Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst )
|
||||
{
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
Mat _dst(_cols, _rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
transpose(src, _dst);
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat _dst(_rows, _cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
Mat(src).copyTo(_dst);
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
void cv2eigen( const Mat& src,
|
||||
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
|
||||
{
|
||||
dst.resize(src.rows, src.cols);
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
Mat _dst(src.cols, src.rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
if( src.type() == _dst.type() )
|
||||
transpose(src, _dst);
|
||||
else if( src.cols == src.rows )
|
||||
{
|
||||
src.convertTo(_dst, _dst.type());
|
||||
transpose(_dst, _dst);
|
||||
}
|
||||
else
|
||||
Mat(src.t()).convertTo(_dst, _dst.type());
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat _dst(src.rows, src.cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
src.convertTo(_dst, _dst.type());
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
}
|
||||
|
||||
// Matx case
|
||||
template<typename _Tp, int _rows, int _cols>
|
||||
void cv2eigen( const Matx<_Tp, _rows, _cols>& src,
|
||||
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
|
||||
{
|
||||
dst.resize(_rows, _cols);
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
Mat _dst(_cols, _rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
transpose(src, _dst);
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat _dst(_rows, _cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
Mat(src).copyTo(_dst);
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
void cv2eigen( const Mat& src,
|
||||
Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst )
|
||||
{
|
||||
CV_Assert(src.cols == 1);
|
||||
dst.resize(src.rows);
|
||||
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
Mat _dst(src.cols, src.rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
if( src.type() == _dst.type() )
|
||||
transpose(src, _dst);
|
||||
else
|
||||
Mat(src.t()).convertTo(_dst, _dst.type());
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat _dst(src.rows, src.cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
src.convertTo(_dst, _dst.type());
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
}
|
||||
|
||||
// Matx case
|
||||
template<typename _Tp, int _rows>
|
||||
void cv2eigen( const Matx<_Tp, _rows, 1>& src,
|
||||
Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst )
|
||||
{
|
||||
dst.resize(_rows);
|
||||
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
Mat _dst(1, _rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
transpose(src, _dst);
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat _dst(_rows, 1, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
src.copyTo(_dst);
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename _Tp>
|
||||
void cv2eigen( const Mat& src,
|
||||
Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst )
|
||||
{
|
||||
CV_Assert(src.rows == 1);
|
||||
dst.resize(src.cols);
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
Mat _dst(src.cols, src.rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
if( src.type() == _dst.type() )
|
||||
transpose(src, _dst);
|
||||
else
|
||||
Mat(src.t()).convertTo(_dst, _dst.type());
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat _dst(src.rows, src.cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
src.convertTo(_dst, _dst.type());
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
}
|
||||
|
||||
//Matx
|
||||
template<typename _Tp, int _cols>
|
||||
void cv2eigen( const Matx<_Tp, 1, _cols>& src,
|
||||
Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst )
|
||||
{
|
||||
dst.resize(_cols);
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
Mat _dst(_cols, 1, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
transpose(src, _dst);
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat _dst(1, _cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
Mat(src).copyTo(_dst);
|
||||
CV_DbgAssert(_dst.data == (uchar*)dst.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,563 +0,0 @@
|
|||
/*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.
|
||||
// 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_GPUMAT_HPP__
|
||||
#define __OPENCV_GPUMAT_HPP__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/cuda_devptrs.hpp"
|
||||
|
||||
namespace cv { namespace gpu
|
||||
{
|
||||
//////////////////////////////// Initialization & Info ////////////////////////
|
||||
|
||||
//! This is the only function that do not throw exceptions if the library is compiled without Cuda.
|
||||
CV_EXPORTS int getCudaEnabledDeviceCount();
|
||||
|
||||
//! Functions below throw cv::Expception if the library is compiled without Cuda.
|
||||
|
||||
CV_EXPORTS void setDevice(int device);
|
||||
CV_EXPORTS int getDevice();
|
||||
|
||||
//! Explicitly destroys and cleans up all resources associated with the current device in the current process.
|
||||
//! Any subsequent API call to this device will reinitialize the device.
|
||||
CV_EXPORTS void resetDevice();
|
||||
|
||||
enum FeatureSet
|
||||
{
|
||||
FEATURE_SET_COMPUTE_10 = 10,
|
||||
FEATURE_SET_COMPUTE_11 = 11,
|
||||
FEATURE_SET_COMPUTE_12 = 12,
|
||||
FEATURE_SET_COMPUTE_13 = 13,
|
||||
FEATURE_SET_COMPUTE_20 = 20,
|
||||
FEATURE_SET_COMPUTE_21 = 21,
|
||||
FEATURE_SET_COMPUTE_30 = 30,
|
||||
FEATURE_SET_COMPUTE_35 = 35,
|
||||
|
||||
GLOBAL_ATOMICS = FEATURE_SET_COMPUTE_11,
|
||||
SHARED_ATOMICS = FEATURE_SET_COMPUTE_12,
|
||||
NATIVE_DOUBLE = FEATURE_SET_COMPUTE_13,
|
||||
WARP_SHUFFLE_FUNCTIONS = FEATURE_SET_COMPUTE_30,
|
||||
DYNAMIC_PARALLELISM = FEATURE_SET_COMPUTE_35
|
||||
};
|
||||
|
||||
// Checks whether current device supports the given feature
|
||||
CV_EXPORTS bool deviceSupports(FeatureSet feature_set);
|
||||
|
||||
// Gives information about what GPU archs this OpenCV GPU module was
|
||||
// compiled for
|
||||
class CV_EXPORTS TargetArchs
|
||||
{
|
||||
public:
|
||||
static bool builtWith(FeatureSet feature_set);
|
||||
static bool has(int major, int minor);
|
||||
static bool hasPtx(int major, int minor);
|
||||
static bool hasBin(int major, int minor);
|
||||
static bool hasEqualOrLessPtx(int major, int minor);
|
||||
static bool hasEqualOrGreater(int major, int minor);
|
||||
static bool hasEqualOrGreaterPtx(int major, int minor);
|
||||
static bool hasEqualOrGreaterBin(int major, int minor);
|
||||
private:
|
||||
TargetArchs();
|
||||
};
|
||||
|
||||
// Gives information about the given GPU
|
||||
class CV_EXPORTS DeviceInfo
|
||||
{
|
||||
public:
|
||||
// Creates DeviceInfo object for the current GPU
|
||||
DeviceInfo() : device_id_(getDevice()) { query(); }
|
||||
|
||||
// Creates DeviceInfo object for the given GPU
|
||||
DeviceInfo(int device_id) : device_id_(device_id) { query(); }
|
||||
|
||||
std::string name() const { return name_; }
|
||||
|
||||
// Return compute capability versions
|
||||
int majorVersion() const { return majorVersion_; }
|
||||
int minorVersion() const { return minorVersion_; }
|
||||
|
||||
int multiProcessorCount() const { return multi_processor_count_; }
|
||||
|
||||
size_t sharedMemPerBlock() const;
|
||||
|
||||
void queryMemory(size_t& totalMemory, size_t& freeMemory) const;
|
||||
size_t freeMemory() const;
|
||||
size_t totalMemory() const;
|
||||
|
||||
// Checks whether device supports the given feature
|
||||
bool supports(FeatureSet feature_set) const;
|
||||
|
||||
// Checks whether the GPU module can be run on the given device
|
||||
bool isCompatible() const;
|
||||
|
||||
int deviceID() const { return device_id_; }
|
||||
|
||||
private:
|
||||
void query();
|
||||
|
||||
int device_id_;
|
||||
|
||||
std::string name_;
|
||||
int multi_processor_count_;
|
||||
int majorVersion_;
|
||||
int minorVersion_;
|
||||
};
|
||||
|
||||
CV_EXPORTS void printCudaDeviceInfo(int device);
|
||||
CV_EXPORTS void printShortCudaDeviceInfo(int device);
|
||||
|
||||
//////////////////////////////// GpuMat ///////////////////////////////
|
||||
|
||||
//! Smart pointer for GPU memory with reference counting. Its interface is mostly similar with cv::Mat.
|
||||
class CV_EXPORTS GpuMat
|
||||
{
|
||||
public:
|
||||
//! default constructor
|
||||
GpuMat();
|
||||
|
||||
//! constructs GpuMatrix of the specified size and type (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.)
|
||||
GpuMat(int rows, int cols, int type);
|
||||
GpuMat(Size size, int type);
|
||||
|
||||
//! constucts GpuMatrix and fills it with the specified value _s.
|
||||
GpuMat(int rows, int cols, int type, Scalar s);
|
||||
GpuMat(Size size, int type, Scalar s);
|
||||
|
||||
//! copy constructor
|
||||
GpuMat(const GpuMat& m);
|
||||
|
||||
//! constructor for GpuMatrix headers pointing to user-allocated data
|
||||
GpuMat(int rows, int cols, int type, void* data, size_t step = Mat::AUTO_STEP);
|
||||
GpuMat(Size size, int type, void* data, size_t step = Mat::AUTO_STEP);
|
||||
|
||||
//! creates a matrix header for a part of the bigger matrix
|
||||
GpuMat(const GpuMat& m, Range rowRange, Range colRange);
|
||||
GpuMat(const GpuMat& m, Rect roi);
|
||||
|
||||
//! builds GpuMat from Mat. Perfom blocking upload to device.
|
||||
explicit GpuMat(const Mat& m);
|
||||
|
||||
//! destructor - calls release()
|
||||
~GpuMat();
|
||||
|
||||
//! assignment operators
|
||||
GpuMat& operator = (const GpuMat& m);
|
||||
|
||||
//! pefroms blocking upload data to GpuMat.
|
||||
void upload(const Mat& m);
|
||||
|
||||
//! downloads data from device to host memory. Blocking calls.
|
||||
void download(Mat& m) const;
|
||||
|
||||
//! returns a new GpuMatrix header for the specified row
|
||||
GpuMat row(int y) const;
|
||||
//! returns a new GpuMatrix header for the specified column
|
||||
GpuMat col(int x) const;
|
||||
//! ... for the specified row span
|
||||
GpuMat rowRange(int startrow, int endrow) const;
|
||||
GpuMat rowRange(Range r) const;
|
||||
//! ... for the specified column span
|
||||
GpuMat colRange(int startcol, int endcol) const;
|
||||
GpuMat colRange(Range r) const;
|
||||
|
||||
//! returns deep copy of the GpuMatrix, i.e. the data is copied
|
||||
GpuMat clone() const;
|
||||
//! copies the GpuMatrix content to "m".
|
||||
// It calls m.create(this->size(), this->type()).
|
||||
void copyTo(GpuMat& m) const;
|
||||
//! copies those GpuMatrix elements to "m" that are marked with non-zero mask elements.
|
||||
void copyTo(GpuMat& m, const GpuMat& mask) const;
|
||||
//! converts GpuMatrix to another datatype with optional scalng. See cvConvertScale.
|
||||
void convertTo(GpuMat& m, int rtype, double alpha = 1, double beta = 0) const;
|
||||
|
||||
void assignTo(GpuMat& m, int type=-1) const;
|
||||
|
||||
//! sets every GpuMatrix element to s
|
||||
GpuMat& operator = (Scalar s);
|
||||
//! sets some of the GpuMatrix elements to s, according to the mask
|
||||
GpuMat& setTo(Scalar s, const GpuMat& mask = GpuMat());
|
||||
//! creates alternative GpuMatrix header for the same data, with different
|
||||
// number of channels and/or different number of rows. see cvReshape.
|
||||
GpuMat reshape(int cn, int rows = 0) const;
|
||||
|
||||
//! allocates new GpuMatrix data unless the GpuMatrix already has specified size and type.
|
||||
// previous data is unreferenced if needed.
|
||||
void create(int rows, int cols, int type);
|
||||
void create(Size size, int type);
|
||||
//! decreases reference counter;
|
||||
// deallocate the data when reference counter reaches 0.
|
||||
void release();
|
||||
|
||||
//! swaps with other smart pointer
|
||||
void swap(GpuMat& mat);
|
||||
|
||||
//! locates GpuMatrix header within a parent GpuMatrix. See below
|
||||
void locateROI(Size& wholeSize, Point& ofs) const;
|
||||
//! moves/resizes the current GpuMatrix ROI inside the parent GpuMatrix.
|
||||
GpuMat& adjustROI(int dtop, int dbottom, int dleft, int dright);
|
||||
//! extracts a rectangular sub-GpuMatrix
|
||||
// (this is a generalized form of row, rowRange etc.)
|
||||
GpuMat operator()(Range rowRange, Range colRange) const;
|
||||
GpuMat operator()(Rect roi) const;
|
||||
|
||||
//! returns true iff the GpuMatrix data is continuous
|
||||
// (i.e. when there are no gaps between successive rows).
|
||||
// similar to CV_IS_GpuMat_CONT(cvGpuMat->type)
|
||||
bool isContinuous() const;
|
||||
//! returns element size in bytes,
|
||||
// similar to CV_ELEM_SIZE(cvMat->type)
|
||||
size_t elemSize() const;
|
||||
//! returns the size of element channel in bytes.
|
||||
size_t elemSize1() const;
|
||||
//! returns element type, similar to CV_MAT_TYPE(cvMat->type)
|
||||
int type() const;
|
||||
//! returns element type, similar to CV_MAT_DEPTH(cvMat->type)
|
||||
int depth() const;
|
||||
//! returns element type, similar to CV_MAT_CN(cvMat->type)
|
||||
int channels() const;
|
||||
//! returns step/elemSize1()
|
||||
size_t step1() const;
|
||||
//! returns GpuMatrix size:
|
||||
// width == number of columns, height == number of rows
|
||||
Size size() const;
|
||||
//! returns true if GpuMatrix data is NULL
|
||||
bool empty() const;
|
||||
|
||||
//! returns pointer to y-th row
|
||||
uchar* ptr(int y = 0);
|
||||
const uchar* ptr(int y = 0) const;
|
||||
|
||||
//! template version of the above method
|
||||
template<typename _Tp> _Tp* ptr(int y = 0);
|
||||
template<typename _Tp> const _Tp* ptr(int y = 0) const;
|
||||
|
||||
template <typename _Tp> operator PtrStepSz<_Tp>() const;
|
||||
template <typename _Tp> operator PtrStep<_Tp>() const;
|
||||
|
||||
// Deprecated function
|
||||
template <typename _Tp> CV_GPU_DEPRECATED operator DevMem2D_<_Tp>() const;
|
||||
template <typename _Tp> CV_GPU_DEPRECATED operator PtrStep_<_Tp>() const;
|
||||
#undef CV_GPU_DEPRECATED
|
||||
|
||||
/*! includes several bit-fields:
|
||||
- the magic signature
|
||||
- continuity flag
|
||||
- depth
|
||||
- number of channels
|
||||
*/
|
||||
int flags;
|
||||
|
||||
//! the number of rows and columns
|
||||
int rows, cols;
|
||||
|
||||
//! a distance between successive rows in bytes; includes the gap if any
|
||||
size_t step;
|
||||
|
||||
//! pointer to the data
|
||||
uchar* data;
|
||||
|
||||
//! pointer to the reference counter;
|
||||
// when GpuMatrix points to user-allocated data, the pointer is NULL
|
||||
int* refcount;
|
||||
|
||||
//! helper fields used in locateROI and adjustROI
|
||||
uchar* datastart;
|
||||
uchar* dataend;
|
||||
};
|
||||
|
||||
//! Creates continuous GPU matrix
|
||||
CV_EXPORTS void createContinuous(int rows, int cols, int type, GpuMat& m);
|
||||
CV_EXPORTS GpuMat createContinuous(int rows, int cols, int type);
|
||||
CV_EXPORTS void createContinuous(Size size, int type, GpuMat& m);
|
||||
CV_EXPORTS GpuMat createContinuous(Size size, int type);
|
||||
|
||||
//! Ensures that size of the given matrix is not less than (rows, cols) size
|
||||
//! and matrix type is match specified one too
|
||||
CV_EXPORTS void ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m);
|
||||
CV_EXPORTS void ensureSizeIsEnough(Size size, int type, GpuMat& m);
|
||||
|
||||
CV_EXPORTS GpuMat allocMatFromBuf(int rows, int cols, int type, GpuMat &mat);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Error handling
|
||||
|
||||
CV_EXPORTS void error(const char* error_string, const char* file, const int line, const char* func = "");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline GpuMat::GpuMat()
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline GpuMat::GpuMat(int rows_, int cols_, int type_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0)
|
||||
{
|
||||
if (rows_ > 0 && cols_ > 0)
|
||||
create(rows_, cols_, type_);
|
||||
}
|
||||
|
||||
inline GpuMat::GpuMat(Size size_, int type_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0)
|
||||
{
|
||||
if (size_.height > 0 && size_.width > 0)
|
||||
create(size_.height, size_.width, type_);
|
||||
}
|
||||
|
||||
inline GpuMat::GpuMat(int rows_, int cols_, int type_, Scalar s_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0)
|
||||
{
|
||||
if (rows_ > 0 && cols_ > 0)
|
||||
{
|
||||
create(rows_, cols_, type_);
|
||||
setTo(s_);
|
||||
}
|
||||
}
|
||||
|
||||
inline GpuMat::GpuMat(Size size_, int type_, Scalar s_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0)
|
||||
{
|
||||
if (size_.height > 0 && size_.width > 0)
|
||||
{
|
||||
create(size_.height, size_.width, type_);
|
||||
setTo(s_);
|
||||
}
|
||||
}
|
||||
|
||||
inline GpuMat::~GpuMat()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
inline GpuMat GpuMat::clone() const
|
||||
{
|
||||
GpuMat m;
|
||||
copyTo(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline void GpuMat::assignTo(GpuMat& m, int _type) const
|
||||
{
|
||||
if (_type < 0)
|
||||
m = *this;
|
||||
else
|
||||
convertTo(m, _type);
|
||||
}
|
||||
|
||||
inline size_t GpuMat::step1() const
|
||||
{
|
||||
return step / elemSize1();
|
||||
}
|
||||
|
||||
inline bool GpuMat::empty() const
|
||||
{
|
||||
return data == 0;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline _Tp* GpuMat::ptr(int y)
|
||||
{
|
||||
return (_Tp*)ptr(y);
|
||||
}
|
||||
|
||||
template<typename _Tp> inline const _Tp* GpuMat::ptr(int y) const
|
||||
{
|
||||
return (const _Tp*)ptr(y);
|
||||
}
|
||||
|
||||
inline void swap(GpuMat& a, GpuMat& b)
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
inline GpuMat GpuMat::row(int y) const
|
||||
{
|
||||
return GpuMat(*this, Range(y, y+1), Range::all());
|
||||
}
|
||||
|
||||
inline GpuMat GpuMat::col(int x) const
|
||||
{
|
||||
return GpuMat(*this, Range::all(), Range(x, x+1));
|
||||
}
|
||||
|
||||
inline GpuMat GpuMat::rowRange(int startrow, int endrow) const
|
||||
{
|
||||
return GpuMat(*this, Range(startrow, endrow), Range::all());
|
||||
}
|
||||
|
||||
inline GpuMat GpuMat::rowRange(Range r) const
|
||||
{
|
||||
return GpuMat(*this, r, Range::all());
|
||||
}
|
||||
|
||||
inline GpuMat GpuMat::colRange(int startcol, int endcol) const
|
||||
{
|
||||
return GpuMat(*this, Range::all(), Range(startcol, endcol));
|
||||
}
|
||||
|
||||
inline GpuMat GpuMat::colRange(Range r) const
|
||||
{
|
||||
return GpuMat(*this, Range::all(), r);
|
||||
}
|
||||
|
||||
inline void GpuMat::create(Size size_, int type_)
|
||||
{
|
||||
create(size_.height, size_.width, type_);
|
||||
}
|
||||
|
||||
inline GpuMat GpuMat::operator()(Range _rowRange, Range _colRange) const
|
||||
{
|
||||
return GpuMat(*this, _rowRange, _colRange);
|
||||
}
|
||||
|
||||
inline GpuMat GpuMat::operator()(Rect roi) const
|
||||
{
|
||||
return GpuMat(*this, roi);
|
||||
}
|
||||
|
||||
inline bool GpuMat::isContinuous() const
|
||||
{
|
||||
return (flags & Mat::CONTINUOUS_FLAG) != 0;
|
||||
}
|
||||
|
||||
inline size_t GpuMat::elemSize() const
|
||||
{
|
||||
return CV_ELEM_SIZE(flags);
|
||||
}
|
||||
|
||||
inline size_t GpuMat::elemSize1() const
|
||||
{
|
||||
return CV_ELEM_SIZE1(flags);
|
||||
}
|
||||
|
||||
inline int GpuMat::type() const
|
||||
{
|
||||
return CV_MAT_TYPE(flags);
|
||||
}
|
||||
|
||||
inline int GpuMat::depth() const
|
||||
{
|
||||
return CV_MAT_DEPTH(flags);
|
||||
}
|
||||
|
||||
inline int GpuMat::channels() const
|
||||
{
|
||||
return CV_MAT_CN(flags);
|
||||
}
|
||||
|
||||
inline Size GpuMat::size() const
|
||||
{
|
||||
return Size(cols, rows);
|
||||
}
|
||||
|
||||
inline uchar* GpuMat::ptr(int y)
|
||||
{
|
||||
CV_DbgAssert((unsigned)y < (unsigned)rows);
|
||||
return data + step * y;
|
||||
}
|
||||
|
||||
inline const uchar* GpuMat::ptr(int y) const
|
||||
{
|
||||
CV_DbgAssert((unsigned)y < (unsigned)rows);
|
||||
return data + step * y;
|
||||
}
|
||||
|
||||
inline GpuMat& GpuMat::operator = (Scalar s)
|
||||
{
|
||||
setTo(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @cond IGNORED */
|
||||
template <class T> inline GpuMat::operator PtrStepSz<T>() const
|
||||
{
|
||||
return PtrStepSz<T>(rows, cols, (T*)data, step);
|
||||
}
|
||||
|
||||
template <class T> inline GpuMat::operator PtrStep<T>() const
|
||||
{
|
||||
return PtrStep<T>((T*)data, step);
|
||||
}
|
||||
|
||||
template <class T> inline GpuMat::operator DevMem2D_<T>() const
|
||||
{
|
||||
return DevMem2D_<T>(rows, cols, (T*)data, step);
|
||||
}
|
||||
|
||||
template <class T> inline GpuMat::operator PtrStep_<T>() const
|
||||
{
|
||||
return PtrStep_<T>(static_cast< DevMem2D_<T> >(*this));
|
||||
}
|
||||
/** @endcond */
|
||||
|
||||
inline GpuMat createContinuous(int rows, int cols, int type)
|
||||
{
|
||||
GpuMat m;
|
||||
createContinuous(rows, cols, type, m);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline void createContinuous(Size size, int type, GpuMat& m)
|
||||
{
|
||||
createContinuous(size.height, size.width, type, m);
|
||||
}
|
||||
|
||||
inline GpuMat createContinuous(Size size, int type)
|
||||
{
|
||||
GpuMat m;
|
||||
createContinuous(size, type, m);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline void ensureSizeIsEnough(Size size, int type, GpuMat& m)
|
||||
{
|
||||
ensureSizeIsEnough(size.height, size.width, type, m);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __OPENCV_GPUMAT_HPP__
|
|
@ -1,799 +0,0 @@
|
|||
/*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.
|
||||
// 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*/
|
||||
|
||||
/* The header is for internal use and it is likely to change.
|
||||
It contains some macro definitions that are used in cxcore, cv, cvaux
|
||||
and, probably, other libraries. If you need some of this functionality,
|
||||
the safe way is to copy it into your code and rename the macros.
|
||||
*/
|
||||
#ifndef __OPENCV_CORE_INTERNAL_HPP__
|
||||
#define __OPENCV_CORE_INTERNAL_HPP__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/types_c.h"
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
# ifndef _WIN32
|
||||
# define _WIN32
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined WIN32 && !defined WINCE
|
||||
# include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
# ifndef _WIN32
|
||||
# define _WIN32
|
||||
# endif
|
||||
# define CV_DLL
|
||||
# undef _CV_ALWAYS_PROFILE_
|
||||
# define _CV_ALWAYS_NO_PROFILE_
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
#endif
|
||||
|
||||
#define __BEGIN__ __CV_BEGIN__
|
||||
#define __END__ __CV_END__
|
||||
#define EXIT __CV_EXIT__
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
# include "ipp.h"
|
||||
|
||||
CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
{
|
||||
IppiSize size = { width, height };
|
||||
return size;
|
||||
}
|
||||
|
||||
CV_INLINE IppiSize ippiSize(const cv::Size & _size)
|
||||
{
|
||||
IppiSize size = { _size.width, _size.height };
|
||||
return size;
|
||||
}
|
||||
|
||||
#if IPP_VERSION_MAJOR >= 9 // IPP 9+ is not supported
|
||||
#undef HAVE_IPP
|
||||
#undef IPP_VERSION_MAJOR
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef IPPI_CALL
|
||||
# define IPPI_CALL(func) CV_Assert((func) >= 0)
|
||||
#endif
|
||||
|
||||
#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
|
||||
# include "emmintrin.h"
|
||||
# define CV_SSE 1
|
||||
# define CV_SSE2 1
|
||||
# if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include "pmmintrin.h"
|
||||
# define CV_SSE3 1
|
||||
# endif
|
||||
# if defined __SSSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include "tmmintrin.h"
|
||||
# define CV_SSSE3 1
|
||||
# endif
|
||||
# if defined __SSE4_1__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include <smmintrin.h>
|
||||
# define CV_SSE4_1 1
|
||||
# endif
|
||||
# if defined __SSE4_2__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include <nmmintrin.h>
|
||||
# define CV_SSE4_2 1
|
||||
# endif
|
||||
# if defined __AVX__ || (defined _MSC_FULL_VER && _MSC_FULL_VER >= 160040219)
|
||||
// MS Visual Studio 2010 (2012?) has no macro pre-defined to identify the use of /arch:AVX
|
||||
// See: http://connect.microsoft.com/VisualStudio/feedback/details/605858/arch-avx-should-define-a-predefined-macro-in-x64-and-set-a-unique-value-for-m-ix86-fp-in-win32
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX 1
|
||||
# if defined(_XCR_XFEATURE_ENABLED_MASK)
|
||||
# define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK)
|
||||
# else
|
||||
# define __xgetbv() 0
|
||||
# endif
|
||||
# endif
|
||||
# if defined __AVX2__
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX2 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if (defined WIN32 || defined _WIN32) && defined(_M_ARM)
|
||||
# include <Intrin.h>
|
||||
# include "arm_neon.h"
|
||||
# define CV_NEON 1
|
||||
# define CPU_HAS_NEON_FEATURE (true)
|
||||
#elif defined(__ARM_NEON__) || defined(__ARM_NEON)
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
# define CPU_HAS_NEON_FEATURE (true)
|
||||
#endif
|
||||
|
||||
#ifndef CV_SSE
|
||||
# define CV_SSE 0
|
||||
#endif
|
||||
#ifndef CV_SSE2
|
||||
# define CV_SSE2 0
|
||||
#endif
|
||||
#ifndef CV_SSE3
|
||||
# define CV_SSE3 0
|
||||
#endif
|
||||
#ifndef CV_SSSE3
|
||||
# define CV_SSSE3 0
|
||||
#endif
|
||||
#ifndef CV_SSE4_1
|
||||
# define CV_SSE4_1 0
|
||||
#endif
|
||||
#ifndef CV_SSE4_2
|
||||
# define CV_SSE4_2 0
|
||||
#endif
|
||||
#ifndef CV_AVX
|
||||
# define CV_AVX 0
|
||||
#endif
|
||||
#ifndef CV_AVX2
|
||||
# define CV_AVX2 0
|
||||
#endif
|
||||
#ifndef CV_NEON
|
||||
# define CV_NEON 0
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TBB
|
||||
# include "tbb/tbb_stddef.h"
|
||||
# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
|
||||
# include "tbb/tbb.h"
|
||||
# include "tbb/task.h"
|
||||
# undef min
|
||||
# undef max
|
||||
# else
|
||||
# undef HAVE_TBB
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_EIGEN
|
||||
# if defined __GNUC__ && defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wshadow"
|
||||
# endif
|
||||
# include <Eigen/Core>
|
||||
# include "opencv2/core/eigen.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace cv
|
||||
{
|
||||
#ifdef HAVE_TBB
|
||||
|
||||
typedef tbb::blocked_range<int> BlockedRange;
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_for( const BlockedRange& range, const Body& body )
|
||||
{
|
||||
tbb::parallel_for(range, body);
|
||||
}
|
||||
|
||||
template<typename Iterator, typename Body> static inline
|
||||
void parallel_do( Iterator first, Iterator last, const Body& body )
|
||||
{
|
||||
tbb::parallel_do(first, last, body);
|
||||
}
|
||||
|
||||
typedef tbb::split Split;
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_reduce( const BlockedRange& range, Body& body )
|
||||
{
|
||||
tbb::parallel_reduce(range, body);
|
||||
}
|
||||
|
||||
typedef tbb::concurrent_vector<Rect> ConcurrentRectVector;
|
||||
typedef tbb::concurrent_vector<double> ConcurrentDoubleVector;
|
||||
#else
|
||||
class BlockedRange
|
||||
{
|
||||
public:
|
||||
BlockedRange() : _begin(0), _end(0), _grainsize(0) {}
|
||||
BlockedRange(int b, int e, int g=1) : _begin(b), _end(e), _grainsize(g) {}
|
||||
int begin() const { return _begin; }
|
||||
int end() const { return _end; }
|
||||
int grainsize() const { return _grainsize; }
|
||||
|
||||
protected:
|
||||
int _begin, _end, _grainsize;
|
||||
};
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_for( const BlockedRange& range, const Body& body )
|
||||
{
|
||||
body(range);
|
||||
}
|
||||
typedef std::vector<Rect> ConcurrentRectVector;
|
||||
typedef std::vector<double> ConcurrentDoubleVector;
|
||||
|
||||
template<typename Iterator, typename Body> static inline
|
||||
void parallel_do( Iterator first, Iterator last, const Body& body )
|
||||
{
|
||||
for( ; first != last; ++first )
|
||||
body(*first);
|
||||
}
|
||||
|
||||
class Split {};
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_reduce( const BlockedRange& range, Body& body )
|
||||
{
|
||||
body(range);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Returns a static string if there is a parallel framework,
|
||||
// NULL otherwise.
|
||||
CV_EXPORTS const char* currentParallelFramework();
|
||||
} //namespace cv
|
||||
|
||||
#define CV_INIT_ALGORITHM(classname, algname, memberinit) \
|
||||
static ::cv::Algorithm* create##classname() \
|
||||
{ \
|
||||
return new classname; \
|
||||
} \
|
||||
\
|
||||
static ::cv::AlgorithmInfo& classname##_info() \
|
||||
{ \
|
||||
static ::cv::AlgorithmInfo classname##_info_var(algname, create##classname); \
|
||||
return classname##_info_var; \
|
||||
} \
|
||||
\
|
||||
CV_ATTR_USED static ::cv::AlgorithmInfo& classname##_info_auto = classname##_info(); \
|
||||
\
|
||||
::cv::AlgorithmInfo* classname::info() const \
|
||||
{ \
|
||||
static volatile bool initialized = false; \
|
||||
\
|
||||
if( !initialized ) \
|
||||
{ \
|
||||
initialized = true; \
|
||||
classname obj; \
|
||||
memberinit; \
|
||||
} \
|
||||
return &classname##_info(); \
|
||||
}
|
||||
|
||||
#endif //__cplusplus
|
||||
|
||||
/* maximal size of vector to run matrix operations on it inline (i.e. w/o ipp calls) */
|
||||
#define CV_MAX_INLINE_MAT_OP_SIZE 10
|
||||
|
||||
/* maximal linear size of matrix to allocate it on stack. */
|
||||
#define CV_MAX_LOCAL_MAT_SIZE 32
|
||||
|
||||
/* maximal size of local memory storage */
|
||||
#define CV_MAX_LOCAL_SIZE \
|
||||
(CV_MAX_LOCAL_MAT_SIZE*CV_MAX_LOCAL_MAT_SIZE*(int)sizeof(double))
|
||||
|
||||
/* default image row align (in bytes) */
|
||||
#define CV_DEFAULT_IMAGE_ROW_ALIGN 4
|
||||
|
||||
/* matrices are continuous by default */
|
||||
#define CV_DEFAULT_MAT_ROW_ALIGN 1
|
||||
|
||||
/* maximum size of dynamic memory buffer.
|
||||
cvAlloc reports an error if a larger block is requested. */
|
||||
#define CV_MAX_ALLOC_SIZE (((size_t)1 << (sizeof(size_t)*8-2)))
|
||||
|
||||
/* the alignment of all the allocated buffers */
|
||||
#define CV_MALLOC_ALIGN 16
|
||||
|
||||
/* default alignment for dynamic data strucutures, resided in storages. */
|
||||
#define CV_STRUCT_ALIGN ((int)sizeof(double))
|
||||
|
||||
/* default storage block size */
|
||||
#define CV_STORAGE_BLOCK_SIZE ((1<<16) - 128)
|
||||
|
||||
/* default memory block for sparse array elements */
|
||||
#define CV_SPARSE_MAT_BLOCK (1<<12)
|
||||
|
||||
/* initial hash table size */
|
||||
#define CV_SPARSE_HASH_SIZE0 (1<<10)
|
||||
|
||||
/* maximal average node_count/hash_size ratio beyond which hash table is resized */
|
||||
#define CV_SPARSE_HASH_RATIO 3
|
||||
|
||||
/* max length of strings */
|
||||
#define CV_MAX_STRLEN 1024
|
||||
|
||||
#if 0 /*def CV_CHECK_FOR_NANS*/
|
||||
# define CV_CHECK_NANS( arr ) cvCheckArray((arr))
|
||||
#else
|
||||
# define CV_CHECK_NANS( arr )
|
||||
#endif
|
||||
|
||||
/****************************************************************************************\
|
||||
* Common declarations *
|
||||
\****************************************************************************************/
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x)))
|
||||
#elif defined _MSC_VER
|
||||
# define CV_DECL_ALIGNED(x) __declspec(align(x))
|
||||
#else
|
||||
# define CV_DECL_ALIGNED(x)
|
||||
#endif
|
||||
|
||||
#ifndef CV_IMPL
|
||||
# define CV_IMPL CV_EXTERN_C
|
||||
#endif
|
||||
|
||||
#define CV_DBG_BREAK() { volatile int* crashMe = 0; *crashMe = 0; }
|
||||
|
||||
/* default step, set in case of continuous data
|
||||
to work around checks for valid step in some ipp functions */
|
||||
#define CV_STUB_STEP (1 << 30)
|
||||
|
||||
#define CV_SIZEOF_FLOAT ((int)sizeof(float))
|
||||
#define CV_SIZEOF_SHORT ((int)sizeof(short))
|
||||
|
||||
#define CV_ORIGIN_TL 0
|
||||
#define CV_ORIGIN_BL 1
|
||||
|
||||
/* IEEE754 constants and macros */
|
||||
#define CV_POS_INF 0x7f800000
|
||||
#define CV_NEG_INF 0x807fffff /* CV_TOGGLE_FLT(0xff800000) */
|
||||
#define CV_1F 0x3f800000
|
||||
#define CV_TOGGLE_FLT(x) ((x)^((int)(x) < 0 ? 0x7fffffff : 0))
|
||||
#define CV_TOGGLE_DBL(x) \
|
||||
((x)^((int64)(x) < 0 ? CV_BIG_INT(0x7fffffffffffffff) : 0))
|
||||
|
||||
#define CV_NOP(a) (a)
|
||||
#define CV_ADD(a, b) ((a) + (b))
|
||||
#define CV_SUB(a, b) ((a) - (b))
|
||||
#define CV_MUL(a, b) ((a) * (b))
|
||||
#define CV_AND(a, b) ((a) & (b))
|
||||
#define CV_OR(a, b) ((a) | (b))
|
||||
#define CV_XOR(a, b) ((a) ^ (b))
|
||||
#define CV_ANDN(a, b) (~(a) & (b))
|
||||
#define CV_ORN(a, b) (~(a) | (b))
|
||||
#define CV_SQR(a) ((a) * (a))
|
||||
|
||||
#define CV_LT(a, b) ((a) < (b))
|
||||
#define CV_LE(a, b) ((a) <= (b))
|
||||
#define CV_EQ(a, b) ((a) == (b))
|
||||
#define CV_NE(a, b) ((a) != (b))
|
||||
#define CV_GT(a, b) ((a) > (b))
|
||||
#define CV_GE(a, b) ((a) >= (b))
|
||||
|
||||
#define CV_NONZERO(a) ((a) != 0)
|
||||
#define CV_NONZERO_FLT(a) (((a)+(a)) != 0)
|
||||
|
||||
/* general-purpose saturation macros */
|
||||
#define CV_CAST_8U(t) (uchar)(!((t) & ~255) ? (t) : (t) > 0 ? 255 : 0)
|
||||
#define CV_CAST_8S(t) (schar)(!(((t)+128) & ~255) ? (t) : (t) > 0 ? 127 : -128)
|
||||
#define CV_CAST_16U(t) (ushort)(!((t) & ~65535) ? (t) : (t) > 0 ? 65535 : 0)
|
||||
#define CV_CAST_16S(t) (short)(!(((t)+32768) & ~65535) ? (t) : (t) > 0 ? 32767 : -32768)
|
||||
#define CV_CAST_32S(t) (int)(t)
|
||||
#define CV_CAST_64S(t) (int64)(t)
|
||||
#define CV_CAST_32F(t) (float)(t)
|
||||
#define CV_CAST_64F(t) (double)(t)
|
||||
|
||||
#define CV_PASTE2(a,b) a##b
|
||||
#define CV_PASTE(a,b) CV_PASTE2(a,b)
|
||||
|
||||
#define CV_EMPTY
|
||||
#define CV_MAKE_STR(a) #a
|
||||
|
||||
#define CV_ZERO_OBJ(x) memset((x), 0, sizeof(*(x)))
|
||||
|
||||
#define CV_DIM(static_array) ((int)(sizeof(static_array)/sizeof((static_array)[0])))
|
||||
|
||||
#define cvUnsupportedFormat "Unsupported format"
|
||||
|
||||
CV_INLINE void* cvAlignPtr( const void* ptr, int align CV_DEFAULT(32) )
|
||||
{
|
||||
assert( (align & (align-1)) == 0 );
|
||||
return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) );
|
||||
}
|
||||
|
||||
CV_INLINE int cvAlign( int size, int align )
|
||||
{
|
||||
assert( (align & (align-1)) == 0 && size < INT_MAX );
|
||||
return (size + align - 1) & -align;
|
||||
}
|
||||
|
||||
CV_INLINE CvSize cvGetMatSize( const CvMat* mat )
|
||||
{
|
||||
CvSize size;
|
||||
size.width = mat->cols;
|
||||
size.height = mat->rows;
|
||||
return size;
|
||||
}
|
||||
|
||||
#define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n))
|
||||
#define CV_FLT_TO_FIX(x,n) cvRound((x)*(1<<(n)))
|
||||
|
||||
/****************************************************************************************\
|
||||
|
||||
Generic implementation of QuickSort algorithm.
|
||||
----------------------------------------------
|
||||
Using this macro user can declare customized sort function that can be much faster
|
||||
than built-in qsort function because of lower overhead on elements
|
||||
comparison and exchange. The macro takes less_than (or LT) argument - a macro or function
|
||||
that takes 2 arguments returns non-zero if the first argument should be before the second
|
||||
one in the sorted sequence and zero otherwise.
|
||||
|
||||
Example:
|
||||
|
||||
Suppose that the task is to sort points by ascending of y coordinates and if
|
||||
y's are equal x's should ascend.
|
||||
|
||||
The code is:
|
||||
------------------------------------------------------------------------------
|
||||
#define cmp_pts( pt1, pt2 ) \
|
||||
((pt1).y < (pt2).y || ((pt1).y < (pt2).y && (pt1).x < (pt2).x))
|
||||
|
||||
[static] CV_IMPLEMENT_QSORT( icvSortPoints, CvPoint, cmp_pts )
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
After that the function "void icvSortPoints( CvPoint* array, size_t total, int aux );"
|
||||
is available to user.
|
||||
|
||||
aux is an additional parameter, which can be used when comparing elements.
|
||||
The current implementation was derived from *BSD system qsort():
|
||||
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
|
||||
\****************************************************************************************/
|
||||
|
||||
#define CV_IMPLEMENT_QSORT_EX( func_name, T, LT, user_data_type ) \
|
||||
void func_name( T *array, size_t total, user_data_type aux ) \
|
||||
{ \
|
||||
int isort_thresh = 7; \
|
||||
T t; \
|
||||
int sp = 0; \
|
||||
\
|
||||
struct \
|
||||
{ \
|
||||
T *lb; \
|
||||
T *ub; \
|
||||
} \
|
||||
stack[48]; \
|
||||
\
|
||||
(void)aux; \
|
||||
\
|
||||
if( total <= 1 ) \
|
||||
return; \
|
||||
\
|
||||
stack[0].lb = array; \
|
||||
stack[0].ub = array + (total - 1); \
|
||||
\
|
||||
while( sp >= 0 ) \
|
||||
{ \
|
||||
T* left = stack[sp].lb; \
|
||||
T* right = stack[sp--].ub; \
|
||||
\
|
||||
for(;;) \
|
||||
{ \
|
||||
int i, n = (int)(right - left) + 1, m; \
|
||||
T* ptr; \
|
||||
T* ptr2; \
|
||||
\
|
||||
if( n <= isort_thresh ) \
|
||||
{ \
|
||||
insert_sort: \
|
||||
for( ptr = left + 1; ptr <= right; ptr++ ) \
|
||||
{ \
|
||||
for( ptr2 = ptr; ptr2 > left && LT(ptr2[0],ptr2[-1]); ptr2--) \
|
||||
CV_SWAP( ptr2[0], ptr2[-1], t ); \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
T* left0; \
|
||||
T* left1; \
|
||||
T* right0; \
|
||||
T* right1; \
|
||||
T* pivot; \
|
||||
T* a; \
|
||||
T* b; \
|
||||
T* c; \
|
||||
int swap_cnt = 0; \
|
||||
\
|
||||
left0 = left; \
|
||||
right0 = right; \
|
||||
pivot = left + (n/2); \
|
||||
\
|
||||
if( n > 40 ) \
|
||||
{ \
|
||||
int d = n / 8; \
|
||||
a = left, b = left + d, c = left + 2*d; \
|
||||
left = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \
|
||||
: (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \
|
||||
\
|
||||
a = pivot - d, b = pivot, c = pivot + d; \
|
||||
pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \
|
||||
: (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \
|
||||
\
|
||||
a = right - 2*d, b = right - d, c = right; \
|
||||
right = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \
|
||||
: (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \
|
||||
} \
|
||||
\
|
||||
a = left, b = pivot, c = right; \
|
||||
pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \
|
||||
: (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \
|
||||
if( pivot != left0 ) \
|
||||
{ \
|
||||
CV_SWAP( *pivot, *left0, t ); \
|
||||
pivot = left0; \
|
||||
} \
|
||||
left = left1 = left0 + 1; \
|
||||
right = right1 = right0; \
|
||||
\
|
||||
for(;;) \
|
||||
{ \
|
||||
while( left <= right && !LT(*pivot, *left) ) \
|
||||
{ \
|
||||
if( !LT(*left, *pivot) ) \
|
||||
{ \
|
||||
if( left > left1 ) \
|
||||
CV_SWAP( *left1, *left, t ); \
|
||||
swap_cnt = 1; \
|
||||
left1++; \
|
||||
} \
|
||||
left++; \
|
||||
} \
|
||||
\
|
||||
while( left <= right && !LT(*right, *pivot) ) \
|
||||
{ \
|
||||
if( !LT(*pivot, *right) ) \
|
||||
{ \
|
||||
if( right < right1 ) \
|
||||
CV_SWAP( *right1, *right, t ); \
|
||||
swap_cnt = 1; \
|
||||
right1--; \
|
||||
} \
|
||||
right--; \
|
||||
} \
|
||||
\
|
||||
if( left > right ) \
|
||||
break; \
|
||||
CV_SWAP( *left, *right, t ); \
|
||||
swap_cnt = 1; \
|
||||
left++; \
|
||||
right--; \
|
||||
} \
|
||||
\
|
||||
if( swap_cnt == 0 ) \
|
||||
{ \
|
||||
left = left0, right = right0; \
|
||||
goto insert_sort; \
|
||||
} \
|
||||
\
|
||||
n = MIN( (int)(left1 - left0), (int)(left - left1) ); \
|
||||
for( i = 0; i < n; i++ ) \
|
||||
CV_SWAP( left0[i], left[i-n], t ); \
|
||||
\
|
||||
n = MIN( (int)(right0 - right1), (int)(right1 - right) ); \
|
||||
for( i = 0; i < n; i++ ) \
|
||||
CV_SWAP( left[i], right0[i-n+1], t ); \
|
||||
n = (int)(left - left1); \
|
||||
m = (int)(right1 - right); \
|
||||
if( n > 1 ) \
|
||||
{ \
|
||||
if( m > 1 ) \
|
||||
{ \
|
||||
if( n > m ) \
|
||||
{ \
|
||||
stack[++sp].lb = left0; \
|
||||
stack[sp].ub = left0 + n - 1; \
|
||||
left = right0 - m + 1, right = right0; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
stack[++sp].lb = right0 - m + 1; \
|
||||
stack[sp].ub = right0; \
|
||||
left = left0, right = left0 + n - 1; \
|
||||
} \
|
||||
} \
|
||||
else \
|
||||
left = left0, right = left0 + n - 1; \
|
||||
} \
|
||||
else if( m > 1 ) \
|
||||
left = right0 - m + 1, right = right0; \
|
||||
else \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define CV_IMPLEMENT_QSORT( func_name, T, cmp ) \
|
||||
CV_IMPLEMENT_QSORT_EX( func_name, T, cmp, int )
|
||||
|
||||
/****************************************************************************************\
|
||||
* Structures and macros for integration with IPP *
|
||||
\****************************************************************************************/
|
||||
|
||||
/* IPP-compatible return codes */
|
||||
typedef enum CvStatus
|
||||
{
|
||||
CV_BADMEMBLOCK_ERR = -113,
|
||||
CV_INPLACE_NOT_SUPPORTED_ERR= -112,
|
||||
CV_UNMATCHED_ROI_ERR = -111,
|
||||
CV_NOTFOUND_ERR = -110,
|
||||
CV_BADCONVERGENCE_ERR = -109,
|
||||
|
||||
CV_BADDEPTH_ERR = -107,
|
||||
CV_BADROI_ERR = -106,
|
||||
CV_BADHEADER_ERR = -105,
|
||||
CV_UNMATCHED_FORMATS_ERR = -104,
|
||||
CV_UNSUPPORTED_COI_ERR = -103,
|
||||
CV_UNSUPPORTED_CHANNELS_ERR = -102,
|
||||
CV_UNSUPPORTED_DEPTH_ERR = -101,
|
||||
CV_UNSUPPORTED_FORMAT_ERR = -100,
|
||||
|
||||
CV_BADARG_ERR = -49, //ipp comp
|
||||
CV_NOTDEFINED_ERR = -48, //ipp comp
|
||||
|
||||
CV_BADCHANNELS_ERR = -47, //ipp comp
|
||||
CV_BADRANGE_ERR = -44, //ipp comp
|
||||
CV_BADSTEP_ERR = -29, //ipp comp
|
||||
|
||||
CV_BADFLAG_ERR = -12,
|
||||
CV_DIV_BY_ZERO_ERR = -11, //ipp comp
|
||||
CV_BADCOEF_ERR = -10,
|
||||
|
||||
CV_BADFACTOR_ERR = -7,
|
||||
CV_BADPOINT_ERR = -6,
|
||||
CV_BADSCALE_ERR = -4,
|
||||
CV_OUTOFMEM_ERR = -3,
|
||||
CV_NULLPTR_ERR = -2,
|
||||
CV_BADSIZE_ERR = -1,
|
||||
CV_NO_ERR = 0,
|
||||
CV_OK = CV_NO_ERR
|
||||
}
|
||||
CvStatus;
|
||||
|
||||
#define CV_NOTHROW throw()
|
||||
|
||||
typedef struct CvFuncTable
|
||||
{
|
||||
void* fn_2d[CV_DEPTH_MAX];
|
||||
}
|
||||
CvFuncTable;
|
||||
|
||||
typedef struct CvBigFuncTable
|
||||
{
|
||||
void* fn_2d[CV_DEPTH_MAX*4];
|
||||
} CvBigFuncTable;
|
||||
|
||||
#define CV_INIT_FUNC_TAB( tab, FUNCNAME, FLAG ) \
|
||||
(tab).fn_2d[CV_8U] = (void*)FUNCNAME##_8u##FLAG; \
|
||||
(tab).fn_2d[CV_8S] = 0; \
|
||||
(tab).fn_2d[CV_16U] = (void*)FUNCNAME##_16u##FLAG; \
|
||||
(tab).fn_2d[CV_16S] = (void*)FUNCNAME##_16s##FLAG; \
|
||||
(tab).fn_2d[CV_32S] = (void*)FUNCNAME##_32s##FLAG; \
|
||||
(tab).fn_2d[CV_32F] = (void*)FUNCNAME##_32f##FLAG; \
|
||||
(tab).fn_2d[CV_64F] = (void*)FUNCNAME##_64f##FLAG
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
// < Deprecated
|
||||
|
||||
class CV_EXPORTS CvOpenGlFuncTab
|
||||
{
|
||||
public:
|
||||
virtual ~CvOpenGlFuncTab();
|
||||
|
||||
virtual void genBuffers(int n, unsigned int* buffers) const = 0;
|
||||
virtual void deleteBuffers(int n, const unsigned int* buffers) const = 0;
|
||||
|
||||
virtual void bufferData(unsigned int target, ptrdiff_t size, const void* data, unsigned int usage) const = 0;
|
||||
virtual void bufferSubData(unsigned int target, ptrdiff_t offset, ptrdiff_t size, const void* data) const = 0;
|
||||
|
||||
virtual void bindBuffer(unsigned int target, unsigned int buffer) const = 0;
|
||||
|
||||
virtual void* mapBuffer(unsigned int target, unsigned int access) const = 0;
|
||||
virtual void unmapBuffer(unsigned int target) const = 0;
|
||||
|
||||
virtual void generateBitmapFont(const std::string& family, int height, int weight, bool italic, bool underline, int start, int count, int base) const = 0;
|
||||
|
||||
virtual bool isGlContextInitialized() const = 0;
|
||||
};
|
||||
|
||||
CV_EXPORTS void icvSetOpenGlFuncTab(const CvOpenGlFuncTab* tab);
|
||||
|
||||
CV_EXPORTS bool icvCheckGlError(const char* file, const int line, const char* func = "");
|
||||
|
||||
// >
|
||||
|
||||
namespace cv { namespace ogl {
|
||||
CV_EXPORTS bool checkError(const char* file, const int line, const char* func = "");
|
||||
}}
|
||||
|
||||
#define CV_CheckGlError() CV_DbgAssert( (cv::ogl::checkError(__FILE__, __LINE__, CV_Func)) )
|
||||
|
||||
#endif //__cplusplus
|
||||
|
||||
#endif // __OPENCV_CORE_INTERNAL_HPP__
|
File diff suppressed because it is too large
Load Diff
|
@ -1,284 +0,0 @@
|
|||
/*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.
|
||||
// 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_OPENGL_INTEROP_HPP__
|
||||
#define __OPENCV_OPENGL_INTEROP_HPP__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/opengl_interop_deprecated.hpp"
|
||||
|
||||
namespace cv { namespace ogl {
|
||||
|
||||
/////////////////// OpenGL Objects ///////////////////
|
||||
|
||||
//! Smart pointer for OpenGL buffer memory with reference counting.
|
||||
class CV_EXPORTS Buffer
|
||||
{
|
||||
public:
|
||||
enum Target
|
||||
{
|
||||
ARRAY_BUFFER = 0x8892, //!< The buffer will be used as a source for vertex data
|
||||
ELEMENT_ARRAY_BUFFER = 0x8893, //!< The buffer will be used for indices (in glDrawElements, for example)
|
||||
PIXEL_PACK_BUFFER = 0x88EB, //!< The buffer will be used for reading from OpenGL textures
|
||||
PIXEL_UNPACK_BUFFER = 0x88EC //!< The buffer will be used for writing to OpenGL textures
|
||||
};
|
||||
|
||||
enum Access
|
||||
{
|
||||
READ_ONLY = 0x88B8,
|
||||
WRITE_ONLY = 0x88B9,
|
||||
READ_WRITE = 0x88BA
|
||||
};
|
||||
|
||||
//! create empty buffer
|
||||
Buffer();
|
||||
|
||||
//! create buffer from existed buffer id
|
||||
Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false);
|
||||
Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false);
|
||||
|
||||
//! create buffer
|
||||
Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
|
||||
//! copy from host/device memory
|
||||
explicit Buffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
|
||||
//! create buffer
|
||||
void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
void create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false) { create(asize.height, asize.width, atype, target, autoRelease); }
|
||||
|
||||
//! release memory and delete buffer object
|
||||
void release();
|
||||
|
||||
//! set auto release mode (if true, release will be called in object's destructor)
|
||||
void setAutoRelease(bool flag);
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
|
||||
//! copy to host/device memory
|
||||
void copyTo(OutputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false) const;
|
||||
|
||||
//! create copy of current buffer
|
||||
Buffer clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const;
|
||||
|
||||
//! bind buffer for specified target
|
||||
void bind(Target target) const;
|
||||
|
||||
//! unbind any buffers from specified target
|
||||
static void unbind(Target target);
|
||||
|
||||
//! map to host memory
|
||||
Mat mapHost(Access access);
|
||||
void unmapHost();
|
||||
|
||||
//! map to device memory
|
||||
gpu::GpuMat mapDevice();
|
||||
void unmapDevice();
|
||||
|
||||
int rows() const { return rows_; }
|
||||
int cols() const { return cols_; }
|
||||
Size size() const { return Size(cols_, rows_); }
|
||||
bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
|
||||
int type() const { return type_; }
|
||||
int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
int channels() const { return CV_MAT_CN(type_); }
|
||||
int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
|
||||
unsigned int bufId() const;
|
||||
|
||||
class Impl;
|
||||
|
||||
private:
|
||||
Ptr<Impl> impl_;
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
};
|
||||
|
||||
//! Smart pointer for OpenGL 2D texture memory with reference counting.
|
||||
class CV_EXPORTS Texture2D
|
||||
{
|
||||
public:
|
||||
enum Format
|
||||
{
|
||||
NONE = 0,
|
||||
DEPTH_COMPONENT = 0x1902, //!< Depth
|
||||
RGB = 0x1907, //!< Red, Green, Blue
|
||||
RGBA = 0x1908 //!< Red, Green, Blue, Alpha
|
||||
};
|
||||
|
||||
//! create empty texture
|
||||
Texture2D();
|
||||
|
||||
//! create texture from existed texture id
|
||||
Texture2D(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false);
|
||||
Texture2D(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false);
|
||||
|
||||
//! create texture
|
||||
Texture2D(int arows, int acols, Format aformat, bool autoRelease = false);
|
||||
Texture2D(Size asize, Format aformat, bool autoRelease = false);
|
||||
|
||||
//! copy from host/device memory
|
||||
explicit Texture2D(InputArray arr, bool autoRelease = false);
|
||||
|
||||
//! create texture
|
||||
void create(int arows, int acols, Format aformat, bool autoRelease = false);
|
||||
void create(Size asize, Format aformat, bool autoRelease = false) { create(asize.height, asize.width, aformat, autoRelease); }
|
||||
|
||||
//! release memory and delete texture object
|
||||
void release();
|
||||
|
||||
//! set auto release mode (if true, release will be called in object's destructor)
|
||||
void setAutoRelease(bool flag);
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray arr, bool autoRelease = false);
|
||||
|
||||
//! copy to host/device memory
|
||||
void copyTo(OutputArray arr, int ddepth = CV_32F, bool autoRelease = false) const;
|
||||
|
||||
//! bind texture to current active texture unit for GL_TEXTURE_2D target
|
||||
void bind() const;
|
||||
|
||||
int rows() const { return rows_; }
|
||||
int cols() const { return cols_; }
|
||||
Size size() const { return Size(cols_, rows_); }
|
||||
bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
|
||||
Format format() const { return format_; }
|
||||
|
||||
unsigned int texId() const;
|
||||
|
||||
class Impl;
|
||||
|
||||
private:
|
||||
Ptr<Impl> impl_;
|
||||
int rows_;
|
||||
int cols_;
|
||||
Format format_;
|
||||
};
|
||||
|
||||
//! OpenGL Arrays
|
||||
class CV_EXPORTS Arrays
|
||||
{
|
||||
public:
|
||||
Arrays();
|
||||
|
||||
void setVertexArray(InputArray vertex);
|
||||
void resetVertexArray();
|
||||
|
||||
void setColorArray(InputArray color);
|
||||
void resetColorArray();
|
||||
|
||||
void setNormalArray(InputArray normal);
|
||||
void resetNormalArray();
|
||||
|
||||
void setTexCoordArray(InputArray texCoord);
|
||||
void resetTexCoordArray();
|
||||
|
||||
void release();
|
||||
|
||||
void setAutoRelease(bool flag);
|
||||
|
||||
void bind() const;
|
||||
|
||||
int size() const { return size_; }
|
||||
bool empty() const { return size_ == 0; }
|
||||
|
||||
private:
|
||||
int size_;
|
||||
Buffer vertex_;
|
||||
Buffer color_;
|
||||
Buffer normal_;
|
||||
Buffer texCoord_;
|
||||
};
|
||||
|
||||
/////////////////// Render Functions ///////////////////
|
||||
|
||||
//! render texture rectangle in window
|
||||
CV_EXPORTS void render(const Texture2D& tex,
|
||||
Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
|
||||
Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
|
||||
|
||||
//! render mode
|
||||
enum {
|
||||
POINTS = 0x0000,
|
||||
LINES = 0x0001,
|
||||
LINE_LOOP = 0x0002,
|
||||
LINE_STRIP = 0x0003,
|
||||
TRIANGLES = 0x0004,
|
||||
TRIANGLE_STRIP = 0x0005,
|
||||
TRIANGLE_FAN = 0x0006,
|
||||
QUADS = 0x0007,
|
||||
QUAD_STRIP = 0x0008,
|
||||
POLYGON = 0x0009
|
||||
};
|
||||
|
||||
//! render OpenGL arrays
|
||||
CV_EXPORTS void render(const Arrays& arr, int mode = POINTS, Scalar color = Scalar::all(255));
|
||||
CV_EXPORTS void render(const Arrays& arr, InputArray indices, int mode = POINTS, Scalar color = Scalar::all(255));
|
||||
|
||||
}} // namespace cv::gl
|
||||
|
||||
namespace cv { namespace gpu {
|
||||
|
||||
//! set a CUDA device to use OpenGL interoperability
|
||||
CV_EXPORTS void setGlDevice(int device = 0);
|
||||
|
||||
}}
|
||||
|
||||
namespace cv {
|
||||
|
||||
template <> CV_EXPORTS void Ptr<cv::ogl::Buffer::Impl>::delete_obj();
|
||||
template <> CV_EXPORTS void Ptr<cv::ogl::Texture2D::Impl>::delete_obj();
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __OPENCV_OPENGL_INTEROP_HPP__
|
|
@ -1,300 +0,0 @@
|
|||
/*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.
|
||||
// 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_OPENGL_INTEROP_DEPRECATED_HPP__
|
||||
#define __OPENCV_OPENGL_INTEROP_DEPRECATED_HPP__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
//! Smart pointer for OpenGL buffer memory with reference counting.
|
||||
class CV_EXPORTS GlBuffer
|
||||
{
|
||||
public:
|
||||
enum Usage
|
||||
{
|
||||
ARRAY_BUFFER = 0x8892, // buffer will use for OpenGL arrays (vertices, colors, normals, etc)
|
||||
TEXTURE_BUFFER = 0x88EC // buffer will ise for OpenGL textures
|
||||
};
|
||||
|
||||
//! create empty buffer
|
||||
explicit GlBuffer(Usage usage);
|
||||
|
||||
//! create buffer
|
||||
GlBuffer(int rows, int cols, int type, Usage usage);
|
||||
GlBuffer(Size size, int type, Usage usage);
|
||||
|
||||
//! copy from host/device memory
|
||||
GlBuffer(InputArray mat, Usage usage);
|
||||
|
||||
void create(int rows, int cols, int type, Usage usage);
|
||||
void create(Size size, int type, Usage usage);
|
||||
void create(int rows, int cols, int type);
|
||||
void create(Size size, int type);
|
||||
|
||||
void release();
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray mat);
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
//! map to host memory
|
||||
Mat mapHost();
|
||||
void unmapHost();
|
||||
|
||||
//! map to device memory
|
||||
gpu::GpuMat mapDevice();
|
||||
void unmapDevice();
|
||||
|
||||
inline int rows() const { return rows_; }
|
||||
inline int cols() const { return cols_; }
|
||||
inline Size size() const { return Size(cols_, rows_); }
|
||||
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
|
||||
inline int type() const { return type_; }
|
||||
inline int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
inline int channels() const { return CV_MAT_CN(type_); }
|
||||
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
|
||||
inline Usage usage() const { return usage_; }
|
||||
|
||||
class Impl;
|
||||
private:
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
Usage usage_;
|
||||
|
||||
Ptr<Impl> impl_;
|
||||
};
|
||||
|
||||
template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj();
|
||||
|
||||
//! Smart pointer for OpenGL 2d texture memory with reference counting.
|
||||
class CV_EXPORTS GlTexture
|
||||
{
|
||||
public:
|
||||
//! create empty texture
|
||||
GlTexture();
|
||||
|
||||
//! create texture
|
||||
GlTexture(int rows, int cols, int type);
|
||||
GlTexture(Size size, int type);
|
||||
|
||||
//! copy from host/device memory
|
||||
explicit GlTexture(InputArray mat, bool bgra = true);
|
||||
|
||||
void create(int rows, int cols, int type);
|
||||
void create(Size size, int type);
|
||||
void release();
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray mat, bool bgra = true);
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
inline int rows() const { return rows_; }
|
||||
inline int cols() const { return cols_; }
|
||||
inline Size size() const { return Size(cols_, rows_); }
|
||||
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
|
||||
inline int type() const { return type_; }
|
||||
inline int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
inline int channels() const { return CV_MAT_CN(type_); }
|
||||
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
|
||||
class Impl;
|
||||
private:
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
|
||||
Ptr<Impl> impl_;
|
||||
GlBuffer buf_;
|
||||
};
|
||||
|
||||
template <> CV_EXPORTS void Ptr<GlTexture::Impl>::delete_obj();
|
||||
|
||||
//! OpenGL Arrays
|
||||
class CV_EXPORTS GlArrays
|
||||
{
|
||||
public:
|
||||
inline GlArrays()
|
||||
: vertex_(GlBuffer::ARRAY_BUFFER), color_(GlBuffer::ARRAY_BUFFER), normal_(GlBuffer::ARRAY_BUFFER), texCoord_(GlBuffer::ARRAY_BUFFER)
|
||||
{
|
||||
}
|
||||
|
||||
void setVertexArray(InputArray vertex);
|
||||
inline void resetVertexArray() { vertex_.release(); }
|
||||
|
||||
void setColorArray(InputArray color, bool bgra = true);
|
||||
inline void resetColorArray() { color_.release(); }
|
||||
|
||||
void setNormalArray(InputArray normal);
|
||||
inline void resetNormalArray() { normal_.release(); }
|
||||
|
||||
void setTexCoordArray(InputArray texCoord);
|
||||
inline void resetTexCoordArray() { texCoord_.release(); }
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
inline int rows() const { return vertex_.rows(); }
|
||||
inline int cols() const { return vertex_.cols(); }
|
||||
inline Size size() const { return vertex_.size(); }
|
||||
inline bool empty() const { return vertex_.empty(); }
|
||||
|
||||
private:
|
||||
GlBuffer vertex_;
|
||||
GlBuffer color_;
|
||||
GlBuffer normal_;
|
||||
GlBuffer texCoord_;
|
||||
};
|
||||
|
||||
//! OpenGL Font
|
||||
class CV_EXPORTS GlFont
|
||||
{
|
||||
public:
|
||||
enum Weight
|
||||
{
|
||||
WEIGHT_LIGHT = 300,
|
||||
WEIGHT_NORMAL = 400,
|
||||
WEIGHT_SEMIBOLD = 600,
|
||||
WEIGHT_BOLD = 700,
|
||||
WEIGHT_BLACK = 900
|
||||
};
|
||||
|
||||
enum Style
|
||||
{
|
||||
STYLE_NORMAL = 0,
|
||||
STYLE_ITALIC = 1,
|
||||
STYLE_UNDERLINE = 2
|
||||
};
|
||||
|
||||
static Ptr<GlFont> get(const std::string& family, int height = 12, Weight weight = WEIGHT_NORMAL, Style style = STYLE_NORMAL);
|
||||
|
||||
void draw(const char* str, int len) const;
|
||||
|
||||
inline const std::string& family() const { return family_; }
|
||||
inline int height() const { return height_; }
|
||||
inline Weight weight() const { return weight_; }
|
||||
inline Style style() const { return style_; }
|
||||
|
||||
private:
|
||||
GlFont(const std::string& family, int height, Weight weight, Style style);
|
||||
|
||||
std::string family_;
|
||||
int height_;
|
||||
Weight weight_;
|
||||
Style style_;
|
||||
|
||||
unsigned int base_;
|
||||
|
||||
GlFont(const GlFont&);
|
||||
GlFont& operator =(const GlFont&);
|
||||
};
|
||||
|
||||
//! render functions
|
||||
|
||||
//! render texture rectangle in window
|
||||
CV_EXPORTS void render(const GlTexture& tex,
|
||||
Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
|
||||
Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
|
||||
|
||||
//! render mode
|
||||
namespace RenderMode {
|
||||
enum {
|
||||
POINTS = 0x0000,
|
||||
LINES = 0x0001,
|
||||
LINE_LOOP = 0x0002,
|
||||
LINE_STRIP = 0x0003,
|
||||
TRIANGLES = 0x0004,
|
||||
TRIANGLE_STRIP = 0x0005,
|
||||
TRIANGLE_FAN = 0x0006,
|
||||
QUADS = 0x0007,
|
||||
QUAD_STRIP = 0x0008,
|
||||
POLYGON = 0x0009
|
||||
};
|
||||
}
|
||||
|
||||
//! render OpenGL arrays
|
||||
CV_EXPORTS void render(const GlArrays& arr, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
|
||||
|
||||
CV_EXPORTS void render(const std::string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos);
|
||||
|
||||
//! OpenGL camera
|
||||
class CV_EXPORTS GlCamera
|
||||
{
|
||||
public:
|
||||
GlCamera();
|
||||
|
||||
void lookAt(Point3d eye, Point3d center, Point3d up);
|
||||
void setCameraPos(Point3d pos, double yaw, double pitch, double roll);
|
||||
|
||||
void setScale(Point3d scale);
|
||||
|
||||
void setProjectionMatrix(const Mat& projectionMatrix, bool transpose = true);
|
||||
void setPerspectiveProjection(double fov, double aspect, double zNear, double zFar);
|
||||
void setOrthoProjection(double left, double right, double bottom, double top, double zNear, double zFar);
|
||||
|
||||
void setupProjectionMatrix() const;
|
||||
void setupModelViewMatrix() const;
|
||||
};
|
||||
|
||||
inline void GlBuffer::create(Size _size, int _type, Usage _usage) { create(_size.height, _size.width, _type, _usage); }
|
||||
inline void GlBuffer::create(int _rows, int _cols, int _type) { create(_rows, _cols, _type, usage()); }
|
||||
inline void GlBuffer::create(Size _size, int _type) { create(_size.height, _size.width, _type, usage()); }
|
||||
inline void GlTexture::create(Size _size, int _type) { create(_size.height, _size.width, _type); }
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __OPENCV_OPENGL_INTEROP_DEPRECATED_HPP__
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,72 +0,0 @@
|
|||
/*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.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright( C) 2000, Intel Corporation, 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 Intel Corporation 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*/
|
||||
|
||||
/*
|
||||
definition of the current version of OpenCV
|
||||
Usefull to test in user programs
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_VERSION_HPP__
|
||||
#define __OPENCV_VERSION_HPP__
|
||||
|
||||
#define CV_VERSION_EPOCH 2
|
||||
#define CV_VERSION_MAJOR 4
|
||||
#define CV_VERSION_MINOR 13
|
||||
#define CV_VERSION_REVISION 6
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
||||
|
||||
#define CVAUX_STRW_EXP(__A) L ## #__A
|
||||
#define CVAUX_STRW(__A) CVAUX_STRW_EXP(__A)
|
||||
|
||||
#if CV_VERSION_REVISION
|
||||
# define CV_VERSION CVAUX_STR(CV_VERSION_EPOCH) "." CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(CV_VERSION_REVISION)
|
||||
#else
|
||||
# define CV_VERSION CVAUX_STR(CV_VERSION_EPOCH) "." CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR)
|
||||
#endif
|
||||
|
||||
/* old style version constants*/
|
||||
#define CV_MAJOR_VERSION CV_VERSION_EPOCH
|
||||
#define CV_MINOR_VERSION CV_VERSION_MAJOR
|
||||
#define CV_SUBMINOR_VERSION CV_VERSION_MINOR
|
||||
|
||||
#endif
|
|
@ -1,621 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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) 2008, Google, 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 Intel Corporation or contributors 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.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Image class which provides a thin layer around an IplImage. The goals
|
||||
// of the class design are:
|
||||
// 1. All the data has explicit ownership to avoid memory leaks
|
||||
// 2. No hidden allocations or copies for performance.
|
||||
// 3. Easy access to OpenCV methods (which will access IPP if available)
|
||||
// 4. Can easily treat external data as an image
|
||||
// 5. Easy to create images which are subsets of other images
|
||||
// 6. Fast pixel access which can take advantage of number of channels
|
||||
// if known at compile time.
|
||||
//
|
||||
// The WImage class is the image class which provides the data accessors.
|
||||
// The 'W' comes from the fact that it is also a wrapper around the popular
|
||||
// but inconvenient IplImage class. A WImage can be constructed either using a
|
||||
// WImageBuffer class which allocates and frees the data,
|
||||
// or using a WImageView class which constructs a subimage or a view into
|
||||
// external data. The view class does no memory management. Each class
|
||||
// actually has two versions, one when the number of channels is known at
|
||||
// compile time and one when it isn't. Using the one with the number of
|
||||
// channels specified can provide some compile time optimizations by using the
|
||||
// fact that the number of channels is a constant.
|
||||
//
|
||||
// We use the convention (c,r) to refer to column c and row r with (0,0) being
|
||||
// the upper left corner. This is similar to standard Euclidean coordinates
|
||||
// with the first coordinate varying in the horizontal direction and the second
|
||||
// coordinate varying in the vertical direction.
|
||||
// Thus (c,r) is usually in the domain [0, width) X [0, height)
|
||||
//
|
||||
// Example usage:
|
||||
// WImageBuffer3_b im(5,7); // Make a 5X7 3 channel image of type uchar
|
||||
// WImageView3_b sub_im(im, 2,2, 3,3); // 3X3 submatrix
|
||||
// vector<float> vec(10, 3.0f);
|
||||
// WImageView1_f user_im(&vec[0], 2, 5); // 2X5 image w/ supplied data
|
||||
//
|
||||
// im.SetZero(); // same as cvSetZero(im.Ipl())
|
||||
// *im(2, 3) = 15; // Modify the element at column 2, row 3
|
||||
// MySetRand(&sub_im);
|
||||
//
|
||||
// // Copy the second row into the first. This can be done with no memory
|
||||
// // allocation and will use SSE if IPP is available.
|
||||
// int w = im.Width();
|
||||
// im.View(0,0, w,1).CopyFrom(im.View(0,1, w,1));
|
||||
//
|
||||
// // Doesn't care about source of data since using WImage
|
||||
// void MySetRand(WImage_b* im) { // Works with any number of channels
|
||||
// for (int r = 0; r < im->Height(); ++r) {
|
||||
// float* row = im->Row(r);
|
||||
// for (int c = 0; c < im->Width(); ++c) {
|
||||
// for (int ch = 0; ch < im->Channels(); ++ch, ++row) {
|
||||
// *row = uchar(rand() & 255);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Functions that are not part of the basic image allocation, viewing, and
|
||||
// access should come from OpenCV, except some useful functions that are not
|
||||
// part of OpenCV can be found in wimage_util.h
|
||||
#ifndef __OPENCV_CORE_WIMAGE_HPP__
|
||||
#define __OPENCV_CORE_WIMAGE_HPP__
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace cv {
|
||||
|
||||
template <typename T> class WImage;
|
||||
template <typename T> class WImageBuffer;
|
||||
template <typename T> class WImageView;
|
||||
|
||||
template<typename T, int C> class WImageC;
|
||||
template<typename T, int C> class WImageBufferC;
|
||||
template<typename T, int C> class WImageViewC;
|
||||
|
||||
// Commonly used typedefs.
|
||||
typedef WImage<uchar> WImage_b;
|
||||
typedef WImageView<uchar> WImageView_b;
|
||||
typedef WImageBuffer<uchar> WImageBuffer_b;
|
||||
|
||||
typedef WImageC<uchar, 1> WImage1_b;
|
||||
typedef WImageViewC<uchar, 1> WImageView1_b;
|
||||
typedef WImageBufferC<uchar, 1> WImageBuffer1_b;
|
||||
|
||||
typedef WImageC<uchar, 3> WImage3_b;
|
||||
typedef WImageViewC<uchar, 3> WImageView3_b;
|
||||
typedef WImageBufferC<uchar, 3> WImageBuffer3_b;
|
||||
|
||||
typedef WImage<float> WImage_f;
|
||||
typedef WImageView<float> WImageView_f;
|
||||
typedef WImageBuffer<float> WImageBuffer_f;
|
||||
|
||||
typedef WImageC<float, 1> WImage1_f;
|
||||
typedef WImageViewC<float, 1> WImageView1_f;
|
||||
typedef WImageBufferC<float, 1> WImageBuffer1_f;
|
||||
|
||||
typedef WImageC<float, 3> WImage3_f;
|
||||
typedef WImageViewC<float, 3> WImageView3_f;
|
||||
typedef WImageBufferC<float, 3> WImageBuffer3_f;
|
||||
|
||||
// There isn't a standard for signed and unsigned short so be more
|
||||
// explicit in the typename for these cases.
|
||||
typedef WImage<short> WImage_16s;
|
||||
typedef WImageView<short> WImageView_16s;
|
||||
typedef WImageBuffer<short> WImageBuffer_16s;
|
||||
|
||||
typedef WImageC<short, 1> WImage1_16s;
|
||||
typedef WImageViewC<short, 1> WImageView1_16s;
|
||||
typedef WImageBufferC<short, 1> WImageBuffer1_16s;
|
||||
|
||||
typedef WImageC<short, 3> WImage3_16s;
|
||||
typedef WImageViewC<short, 3> WImageView3_16s;
|
||||
typedef WImageBufferC<short, 3> WImageBuffer3_16s;
|
||||
|
||||
typedef WImage<ushort> WImage_16u;
|
||||
typedef WImageView<ushort> WImageView_16u;
|
||||
typedef WImageBuffer<ushort> WImageBuffer_16u;
|
||||
|
||||
typedef WImageC<ushort, 1> WImage1_16u;
|
||||
typedef WImageViewC<ushort, 1> WImageView1_16u;
|
||||
typedef WImageBufferC<ushort, 1> WImageBuffer1_16u;
|
||||
|
||||
typedef WImageC<ushort, 3> WImage3_16u;
|
||||
typedef WImageViewC<ushort, 3> WImageView3_16u;
|
||||
typedef WImageBufferC<ushort, 3> WImageBuffer3_16u;
|
||||
|
||||
//
|
||||
// WImage definitions
|
||||
//
|
||||
// This WImage class gives access to the data it refers to. It can be
|
||||
// constructed either by allocating the data with a WImageBuffer class or
|
||||
// using the WImageView class to refer to a subimage or outside data.
|
||||
template<typename T>
|
||||
class WImage
|
||||
{
|
||||
public:
|
||||
typedef T BaseType;
|
||||
|
||||
// WImage is an abstract class with no other virtual methods so make the
|
||||
// destructor virtual.
|
||||
virtual ~WImage() = 0;
|
||||
|
||||
// Accessors
|
||||
IplImage* Ipl() {return image_; }
|
||||
const IplImage* Ipl() const {return image_; }
|
||||
T* ImageData() { return reinterpret_cast<T*>(image_->imageData); }
|
||||
const T* ImageData() const {
|
||||
return reinterpret_cast<const T*>(image_->imageData);
|
||||
}
|
||||
|
||||
int Width() const {return image_->width; }
|
||||
int Height() const {return image_->height; }
|
||||
|
||||
// WidthStep is the number of bytes to go to the pixel with the next y coord
|
||||
int WidthStep() const {return image_->widthStep; }
|
||||
|
||||
int Channels() const {return image_->nChannels; }
|
||||
int ChannelSize() const {return sizeof(T); } // number of bytes per channel
|
||||
|
||||
// Number of bytes per pixel
|
||||
int PixelSize() const {return Channels() * ChannelSize(); }
|
||||
|
||||
// Return depth type (e.g. IPL_DEPTH_8U, IPL_DEPTH_32F) which is the number
|
||||
// of bits per channel and with the signed bit set.
|
||||
// This is known at compile time using specializations.
|
||||
int Depth() const;
|
||||
|
||||
inline const T* Row(int r) const {
|
||||
return reinterpret_cast<T*>(image_->imageData + r*image_->widthStep);
|
||||
}
|
||||
|
||||
inline T* Row(int r) {
|
||||
return reinterpret_cast<T*>(image_->imageData + r*image_->widthStep);
|
||||
}
|
||||
|
||||
// Pixel accessors which returns a pointer to the start of the channel
|
||||
inline T* operator() (int c, int r) {
|
||||
return reinterpret_cast<T*>(image_->imageData + r*image_->widthStep) +
|
||||
c*Channels();
|
||||
}
|
||||
|
||||
inline const T* operator() (int c, int r) const {
|
||||
return reinterpret_cast<T*>(image_->imageData + r*image_->widthStep) +
|
||||
c*Channels();
|
||||
}
|
||||
|
||||
// Copy the contents from another image which is just a convenience to cvCopy
|
||||
void CopyFrom(const WImage<T>& src) { cvCopy(src.Ipl(), image_); }
|
||||
|
||||
// Set contents to zero which is just a convenient to cvSetZero
|
||||
void SetZero() { cvSetZero(image_); }
|
||||
|
||||
// Construct a view into a region of this image
|
||||
WImageView<T> View(int c, int r, int width, int height);
|
||||
|
||||
protected:
|
||||
// Disallow copy and assignment
|
||||
WImage(const WImage&);
|
||||
void operator=(const WImage&);
|
||||
|
||||
explicit WImage(IplImage* img) : image_(img) {
|
||||
assert(!img || img->depth == Depth());
|
||||
}
|
||||
|
||||
void SetIpl(IplImage* image) {
|
||||
assert(!image || image->depth == Depth());
|
||||
image_ = image;
|
||||
}
|
||||
|
||||
IplImage* image_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Image class when both the pixel type and number of channels
|
||||
// are known at compile time. This wrapper will speed up some of the operations
|
||||
// like accessing individual pixels using the () operator.
|
||||
template<typename T, int C>
|
||||
class WImageC : public WImage<T>
|
||||
{
|
||||
public:
|
||||
typedef typename WImage<T>::BaseType BaseType;
|
||||
enum { kChannels = C };
|
||||
|
||||
explicit WImageC(IplImage* img) : WImage<T>(img) {
|
||||
assert(!img || img->nChannels == Channels());
|
||||
}
|
||||
|
||||
// Construct a view into a region of this image
|
||||
WImageViewC<T, C> View(int c, int r, int width, int height);
|
||||
|
||||
// Copy the contents from another image which is just a convenience to cvCopy
|
||||
void CopyFrom(const WImageC<T, C>& src) {
|
||||
cvCopy(src.Ipl(), WImage<T>::image_);
|
||||
}
|
||||
|
||||
// WImageC is an abstract class with no other virtual methods so make the
|
||||
// destructor virtual.
|
||||
virtual ~WImageC() = 0;
|
||||
|
||||
int Channels() const {return C; }
|
||||
|
||||
protected:
|
||||
// Disallow copy and assignment
|
||||
WImageC(const WImageC&);
|
||||
void operator=(const WImageC&);
|
||||
|
||||
void SetIpl(IplImage* image) {
|
||||
assert(!image || image->depth == WImage<T>::Depth());
|
||||
WImage<T>::SetIpl(image);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// WImageBuffer definitions
|
||||
//
|
||||
// Image class which owns the data, so it can be allocated and is always
|
||||
// freed. It cannot be copied but can be explicity cloned.
|
||||
//
|
||||
template<typename T>
|
||||
class WImageBuffer : public WImage<T>
|
||||
{
|
||||
public:
|
||||
typedef typename WImage<T>::BaseType BaseType;
|
||||
|
||||
// Default constructor which creates an object that can be
|
||||
WImageBuffer() : WImage<T>(0) {}
|
||||
|
||||
WImageBuffer(int width, int height, int nchannels) : WImage<T>(0) {
|
||||
Allocate(width, height, nchannels);
|
||||
}
|
||||
|
||||
// Constructor which takes ownership of a given IplImage so releases
|
||||
// the image on destruction.
|
||||
explicit WImageBuffer(IplImage* img) : WImage<T>(img) {}
|
||||
|
||||
// Allocate an image. Does nothing if current size is the same as
|
||||
// the new size.
|
||||
void Allocate(int width, int height, int nchannels);
|
||||
|
||||
// Set the data to point to an image, releasing the old data
|
||||
void SetIpl(IplImage* img) {
|
||||
ReleaseImage();
|
||||
WImage<T>::SetIpl(img);
|
||||
}
|
||||
|
||||
// Clone an image which reallocates the image if of a different dimension.
|
||||
void CloneFrom(const WImage<T>& src) {
|
||||
Allocate(src.Width(), src.Height(), src.Channels());
|
||||
CopyFrom(src);
|
||||
}
|
||||
|
||||
~WImageBuffer() {
|
||||
ReleaseImage();
|
||||
}
|
||||
|
||||
// Release the image if it isn't null.
|
||||
void ReleaseImage() {
|
||||
if (WImage<T>::image_) {
|
||||
IplImage* image = WImage<T>::image_;
|
||||
cvReleaseImage(&image);
|
||||
WImage<T>::SetIpl(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsNull() const {return WImage<T>::image_ == NULL; }
|
||||
|
||||
private:
|
||||
// Disallow copy and assignment
|
||||
WImageBuffer(const WImageBuffer&);
|
||||
void operator=(const WImageBuffer&);
|
||||
};
|
||||
|
||||
// Like a WImageBuffer class but when the number of channels is known
|
||||
// at compile time.
|
||||
template<typename T, int C>
|
||||
class WImageBufferC : public WImageC<T, C>
|
||||
{
|
||||
public:
|
||||
typedef typename WImage<T>::BaseType BaseType;
|
||||
enum { kChannels = C };
|
||||
|
||||
// Default constructor which creates an object that can be
|
||||
WImageBufferC() : WImageC<T, C>(0) {}
|
||||
|
||||
WImageBufferC(int width, int height) : WImageC<T, C>(0) {
|
||||
Allocate(width, height);
|
||||
}
|
||||
|
||||
// Constructor which takes ownership of a given IplImage so releases
|
||||
// the image on destruction.
|
||||
explicit WImageBufferC(IplImage* img) : WImageC<T, C>(img) {}
|
||||
|
||||
// Allocate an image. Does nothing if current size is the same as
|
||||
// the new size.
|
||||
void Allocate(int width, int height);
|
||||
|
||||
// Set the data to point to an image, releasing the old data
|
||||
void SetIpl(IplImage* img) {
|
||||
ReleaseImage();
|
||||
WImageC<T, C>::SetIpl(img);
|
||||
}
|
||||
|
||||
// Clone an image which reallocates the image if of a different dimension.
|
||||
void CloneFrom(const WImageC<T, C>& src) {
|
||||
Allocate(src.Width(), src.Height());
|
||||
CopyFrom(src);
|
||||
}
|
||||
|
||||
~WImageBufferC() {
|
||||
ReleaseImage();
|
||||
}
|
||||
|
||||
// Release the image if it isn't null.
|
||||
void ReleaseImage() {
|
||||
if (WImage<T>::image_) {
|
||||
IplImage* image = WImage<T>::image_;
|
||||
cvReleaseImage(&image);
|
||||
WImageC<T, C>::SetIpl(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsNull() const {return WImage<T>::image_ == NULL; }
|
||||
|
||||
private:
|
||||
// Disallow copy and assignment
|
||||
WImageBufferC(const WImageBufferC&);
|
||||
void operator=(const WImageBufferC&);
|
||||
};
|
||||
|
||||
//
|
||||
// WImageView definitions
|
||||
//
|
||||
// View into an image class which allows treating a subimage as an image
|
||||
// or treating external data as an image
|
||||
//
|
||||
template<typename T>
|
||||
class WImageView : public WImage<T>
|
||||
{
|
||||
public:
|
||||
typedef typename WImage<T>::BaseType BaseType;
|
||||
|
||||
// Construct a subimage. No checks are done that the subimage lies
|
||||
// completely inside the original image.
|
||||
WImageView(WImage<T>* img, int c, int r, int width, int height);
|
||||
|
||||
// Refer to external data.
|
||||
// If not given width_step assumed to be same as width.
|
||||
WImageView(T* data, int width, int height, int channels, int width_step = -1);
|
||||
|
||||
// Refer to external data. This does NOT take ownership
|
||||
// of the supplied IplImage.
|
||||
WImageView(IplImage* img) : WImage<T>(img) {}
|
||||
|
||||
// Copy constructor
|
||||
WImageView(const WImage<T>& img) : WImage<T>(0) {
|
||||
header_ = *(img.Ipl());
|
||||
WImage<T>::SetIpl(&header_);
|
||||
}
|
||||
|
||||
WImageView& operator=(const WImage<T>& img) {
|
||||
header_ = *(img.Ipl());
|
||||
WImage<T>::SetIpl(&header_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
IplImage header_;
|
||||
};
|
||||
|
||||
|
||||
template<typename T, int C>
|
||||
class WImageViewC : public WImageC<T, C>
|
||||
{
|
||||
public:
|
||||
typedef typename WImage<T>::BaseType BaseType;
|
||||
enum { kChannels = C };
|
||||
|
||||
// Default constructor needed for vectors of views.
|
||||
WImageViewC();
|
||||
|
||||
virtual ~WImageViewC() {}
|
||||
|
||||
// Construct a subimage. No checks are done that the subimage lies
|
||||
// completely inside the original image.
|
||||
WImageViewC(WImageC<T, C>* img,
|
||||
int c, int r, int width, int height);
|
||||
|
||||
// Refer to external data
|
||||
WImageViewC(T* data, int width, int height, int width_step = -1);
|
||||
|
||||
// Refer to external data. This does NOT take ownership
|
||||
// of the supplied IplImage.
|
||||
WImageViewC(IplImage* img) : WImageC<T, C>(img) {}
|
||||
|
||||
// Copy constructor which does a shallow copy to allow multiple views
|
||||
// of same data. gcc-4.1.1 gets confused if both versions of
|
||||
// the constructor and assignment operator are not provided.
|
||||
WImageViewC(const WImageC<T, C>& img) : WImageC<T, C>(0) {
|
||||
header_ = *(img.Ipl());
|
||||
WImageC<T, C>::SetIpl(&header_);
|
||||
}
|
||||
WImageViewC(const WImageViewC<T, C>& img) : WImageC<T, C>(0) {
|
||||
header_ = *(img.Ipl());
|
||||
WImageC<T, C>::SetIpl(&header_);
|
||||
}
|
||||
|
||||
WImageViewC& operator=(const WImageC<T, C>& img) {
|
||||
header_ = *(img.Ipl());
|
||||
WImageC<T, C>::SetIpl(&header_);
|
||||
return *this;
|
||||
}
|
||||
WImageViewC& operator=(const WImageViewC<T, C>& img) {
|
||||
header_ = *(img.Ipl());
|
||||
WImageC<T, C>::SetIpl(&header_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
IplImage header_;
|
||||
};
|
||||
|
||||
|
||||
// Specializations for depth
|
||||
template<>
|
||||
inline int WImage<uchar>::Depth() const {return IPL_DEPTH_8U; }
|
||||
template<>
|
||||
inline int WImage<signed char>::Depth() const {return IPL_DEPTH_8S; }
|
||||
template<>
|
||||
inline int WImage<short>::Depth() const {return IPL_DEPTH_16S; }
|
||||
template<>
|
||||
inline int WImage<ushort>::Depth() const {return IPL_DEPTH_16U; }
|
||||
template<>
|
||||
inline int WImage<int>::Depth() const {return IPL_DEPTH_32S; }
|
||||
template<>
|
||||
inline int WImage<float>::Depth() const {return IPL_DEPTH_32F; }
|
||||
template<>
|
||||
inline int WImage<double>::Depth() const {return IPL_DEPTH_64F; }
|
||||
|
||||
//
|
||||
// Pure virtual destructors still need to be defined.
|
||||
//
|
||||
template<typename T> inline WImage<T>::~WImage() {}
|
||||
template<typename T, int C> inline WImageC<T, C>::~WImageC() {}
|
||||
|
||||
//
|
||||
// Allocate ImageData
|
||||
//
|
||||
template<typename T>
|
||||
inline void WImageBuffer<T>::Allocate(int width, int height, int nchannels)
|
||||
{
|
||||
if (IsNull() || WImage<T>::Width() != width ||
|
||||
WImage<T>::Height() != height || WImage<T>::Channels() != nchannels) {
|
||||
ReleaseImage();
|
||||
WImage<T>::image_ = cvCreateImage(cvSize(width, height),
|
||||
WImage<T>::Depth(), nchannels);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, int C>
|
||||
inline void WImageBufferC<T, C>::Allocate(int width, int height)
|
||||
{
|
||||
if (IsNull() || WImage<T>::Width() != width || WImage<T>::Height() != height) {
|
||||
ReleaseImage();
|
||||
WImageC<T, C>::SetIpl(cvCreateImage(cvSize(width, height),WImage<T>::Depth(), C));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// ImageView methods
|
||||
//
|
||||
template<typename T>
|
||||
WImageView<T>::WImageView(WImage<T>* img, int c, int r, int width, int height)
|
||||
: WImage<T>(0)
|
||||
{
|
||||
header_ = *(img->Ipl());
|
||||
header_.imageData = reinterpret_cast<char*>((*img)(c, r));
|
||||
header_.width = width;
|
||||
header_.height = height;
|
||||
WImage<T>::SetIpl(&header_);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WImageView<T>::WImageView(T* data, int width, int height, int nchannels, int width_step)
|
||||
: WImage<T>(0)
|
||||
{
|
||||
cvInitImageHeader(&header_, cvSize(width, height), WImage<T>::Depth(), nchannels);
|
||||
header_.imageData = reinterpret_cast<char*>(data);
|
||||
if (width_step > 0) {
|
||||
header_.widthStep = width_step;
|
||||
}
|
||||
WImage<T>::SetIpl(&header_);
|
||||
}
|
||||
|
||||
template<typename T, int C>
|
||||
WImageViewC<T, C>::WImageViewC(WImageC<T, C>* img, int c, int r, int width, int height)
|
||||
: WImageC<T, C>(0)
|
||||
{
|
||||
header_ = *(img->Ipl());
|
||||
header_.imageData = reinterpret_cast<char*>((*img)(c, r));
|
||||
header_.width = width;
|
||||
header_.height = height;
|
||||
WImageC<T, C>::SetIpl(&header_);
|
||||
}
|
||||
|
||||
template<typename T, int C>
|
||||
WImageViewC<T, C>::WImageViewC() : WImageC<T, C>(0) {
|
||||
cvInitImageHeader(&header_, cvSize(0, 0), WImage<T>::Depth(), C);
|
||||
header_.imageData = reinterpret_cast<char*>(0);
|
||||
WImageC<T, C>::SetIpl(&header_);
|
||||
}
|
||||
|
||||
template<typename T, int C>
|
||||
WImageViewC<T, C>::WImageViewC(T* data, int width, int height, int width_step)
|
||||
: WImageC<T, C>(0)
|
||||
{
|
||||
cvInitImageHeader(&header_, cvSize(width, height), WImage<T>::Depth(), C);
|
||||
header_.imageData = reinterpret_cast<char*>(data);
|
||||
if (width_step > 0) {
|
||||
header_.widthStep = width_step;
|
||||
}
|
||||
WImageC<T, C>::SetIpl(&header_);
|
||||
}
|
||||
|
||||
// Construct a view into a region of an image
|
||||
template<typename T>
|
||||
WImageView<T> WImage<T>::View(int c, int r, int width, int height) {
|
||||
return WImageView<T>(this, c, r, width, height);
|
||||
}
|
||||
|
||||
template<typename T, int C>
|
||||
WImageViewC<T, C> WImageC<T, C>::View(int c, int r, int width, int height) {
|
||||
return WImageViewC<T, C>(this, c, r, width, height);
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -1,171 +0,0 @@
|
|||
/* For iOS video I/O
|
||||
* by Eduard Feicho on 29/07/12
|
||||
* Copyright 2012. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 AUTHOR 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Accelerate/Accelerate.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <ImageIO/ImageIO.h>
|
||||
#include "opencv2/core/core.hpp"
|
||||
|
||||
/////////////////////////////////////// CvAbstractCamera /////////////////////////////////////
|
||||
|
||||
@class CvAbstractCamera;
|
||||
|
||||
@interface CvAbstractCamera : NSObject
|
||||
{
|
||||
AVCaptureSession* captureSession;
|
||||
AVCaptureConnection* videoCaptureConnection;
|
||||
AVCaptureVideoPreviewLayer *captureVideoPreviewLayer;
|
||||
|
||||
UIDeviceOrientation currentDeviceOrientation;
|
||||
|
||||
BOOL cameraAvailable;
|
||||
BOOL captureSessionLoaded;
|
||||
BOOL running;
|
||||
BOOL useAVCaptureVideoPreviewLayer;
|
||||
|
||||
AVCaptureDevicePosition defaultAVCaptureDevicePosition;
|
||||
AVCaptureVideoOrientation defaultAVCaptureVideoOrientation;
|
||||
NSString *const defaultAVCaptureSessionPreset;
|
||||
|
||||
int defaultFPS;
|
||||
|
||||
UIView* parentView;
|
||||
|
||||
int imageWidth;
|
||||
int imageHeight;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) AVCaptureSession* captureSession;
|
||||
@property (nonatomic, retain) AVCaptureConnection* videoCaptureConnection;
|
||||
|
||||
@property (nonatomic, readonly) BOOL running;
|
||||
@property (nonatomic, readonly) BOOL captureSessionLoaded;
|
||||
|
||||
@property (nonatomic, assign) int defaultFPS;
|
||||
@property (nonatomic, readonly) AVCaptureVideoPreviewLayer *captureVideoPreviewLayer;
|
||||
@property (nonatomic, assign) AVCaptureDevicePosition defaultAVCaptureDevicePosition;
|
||||
@property (nonatomic, assign) AVCaptureVideoOrientation defaultAVCaptureVideoOrientation;
|
||||
@property (nonatomic, assign) BOOL useAVCaptureVideoPreviewLayer;
|
||||
@property (nonatomic, strong) NSString *const defaultAVCaptureSessionPreset;
|
||||
|
||||
@property (nonatomic, assign) int imageWidth;
|
||||
@property (nonatomic, assign) int imageHeight;
|
||||
|
||||
@property (nonatomic, retain) UIView* parentView;
|
||||
|
||||
- (void)start;
|
||||
- (void)stop;
|
||||
- (void)switchCameras;
|
||||
|
||||
- (id)initWithParentView:(UIView*)parent;
|
||||
|
||||
- (void)createCaptureOutput;
|
||||
- (void)createVideoPreviewLayer;
|
||||
- (void)updateOrientation;
|
||||
|
||||
- (void)lockFocus;
|
||||
- (void)unlockFocus;
|
||||
- (void)lockExposure;
|
||||
- (void)unlockExposure;
|
||||
- (void)lockBalance;
|
||||
- (void)unlockBalance;
|
||||
|
||||
@end
|
||||
|
||||
///////////////////////////////// CvVideoCamera ///////////////////////////////////////////
|
||||
|
||||
@class CvVideoCamera;
|
||||
|
||||
@protocol CvVideoCameraDelegate <NSObject>
|
||||
|
||||
#ifdef __cplusplus
|
||||
// delegate method for processing image frames
|
||||
- (void)processImage:(cv::Mat&)image;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
@interface CvVideoCamera : CvAbstractCamera<AVCaptureVideoDataOutputSampleBufferDelegate>
|
||||
{
|
||||
AVCaptureVideoDataOutput *videoDataOutput;
|
||||
|
||||
dispatch_queue_t videoDataOutputQueue;
|
||||
CALayer *customPreviewLayer;
|
||||
|
||||
BOOL grayscaleMode;
|
||||
|
||||
BOOL recordVideo;
|
||||
BOOL rotateVideo;
|
||||
AVAssetWriterInput* recordAssetWriterInput;
|
||||
AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor;
|
||||
AVAssetWriter* recordAssetWriter;
|
||||
|
||||
CMTime lastSampleTime;
|
||||
|
||||
}
|
||||
|
||||
@property (nonatomic, assign) id<CvVideoCameraDelegate> delegate;
|
||||
@property (nonatomic, assign) BOOL grayscaleMode;
|
||||
|
||||
@property (nonatomic, assign) BOOL recordVideo;
|
||||
@property (nonatomic, assign) BOOL rotateVideo;
|
||||
@property (nonatomic, retain) AVAssetWriterInput* recordAssetWriterInput;
|
||||
@property (nonatomic, retain) AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor;
|
||||
@property (nonatomic, retain) AVAssetWriter* recordAssetWriter;
|
||||
|
||||
- (void)adjustLayoutToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
|
||||
- (void)layoutPreviewLayer;
|
||||
- (void)saveVideo;
|
||||
- (NSURL *)videoFileURL;
|
||||
- (NSString *)videoFileString;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
///////////////////////////////// CvPhotoCamera ///////////////////////////////////////////
|
||||
|
||||
@class CvPhotoCamera;
|
||||
|
||||
@protocol CvPhotoCameraDelegate <NSObject>
|
||||
|
||||
- (void)photoCamera:(CvPhotoCamera*)photoCamera capturedImage:(UIImage *)image;
|
||||
- (void)photoCameraCancel:(CvPhotoCamera*)photoCamera;
|
||||
|
||||
@end
|
||||
|
||||
@interface CvPhotoCamera : CvAbstractCamera
|
||||
{
|
||||
AVCaptureStillImageOutput *stillImageOutput;
|
||||
}
|
||||
|
||||
@property (nonatomic, assign) id<CvPhotoCameraDelegate> delegate;
|
||||
|
||||
- (void)takePicture;
|
||||
|
||||
@end
|
|
@ -1,255 +0,0 @@
|
|||
/*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.
|
||||
// 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_HIGHGUI_HPP__
|
||||
#define __OPENCV_HIGHGUI_HPP__
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/highgui/highgui_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
struct CvCapture;
|
||||
struct CvVideoWriter;
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
enum {
|
||||
// Flags for namedWindow
|
||||
WINDOW_NORMAL = CV_WINDOW_NORMAL, // the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
|
||||
WINDOW_AUTOSIZE = CV_WINDOW_AUTOSIZE, // the user cannot resize the window, the size is constrainted by the image displayed
|
||||
WINDOW_OPENGL = CV_WINDOW_OPENGL, // window with opengl support
|
||||
|
||||
// Flags for set / getWindowProperty
|
||||
WND_PROP_FULLSCREEN = CV_WND_PROP_FULLSCREEN, // fullscreen property
|
||||
WND_PROP_AUTOSIZE = CV_WND_PROP_AUTOSIZE, // autosize property
|
||||
WND_PROP_ASPECT_RATIO = CV_WND_PROP_ASPECTRATIO, // window's aspect ration
|
||||
WND_PROP_OPENGL = CV_WND_PROP_OPENGL // opengl support
|
||||
};
|
||||
|
||||
CV_EXPORTS_W void namedWindow(const string& winname, int flags = WINDOW_AUTOSIZE);
|
||||
CV_EXPORTS_W void destroyWindow(const string& winname);
|
||||
CV_EXPORTS_W void destroyAllWindows();
|
||||
|
||||
CV_EXPORTS_W int startWindowThread();
|
||||
|
||||
CV_EXPORTS_W int waitKey(int delay = 0);
|
||||
|
||||
CV_EXPORTS_W void imshow(const string& winname, InputArray mat);
|
||||
|
||||
CV_EXPORTS_W void resizeWindow(const string& winname, int width, int height);
|
||||
CV_EXPORTS_W void moveWindow(const string& winname, int x, int y);
|
||||
|
||||
CV_EXPORTS_W void setWindowProperty(const string& winname, int prop_id, double prop_value);//YV
|
||||
CV_EXPORTS_W double getWindowProperty(const string& winname, int prop_id);//YV
|
||||
|
||||
enum
|
||||
{
|
||||
EVENT_MOUSEMOVE =0,
|
||||
EVENT_LBUTTONDOWN =1,
|
||||
EVENT_RBUTTONDOWN =2,
|
||||
EVENT_MBUTTONDOWN =3,
|
||||
EVENT_LBUTTONUP =4,
|
||||
EVENT_RBUTTONUP =5,
|
||||
EVENT_MBUTTONUP =6,
|
||||
EVENT_LBUTTONDBLCLK =7,
|
||||
EVENT_RBUTTONDBLCLK =8,
|
||||
EVENT_MBUTTONDBLCLK =9
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EVENT_FLAG_LBUTTON =1,
|
||||
EVENT_FLAG_RBUTTON =2,
|
||||
EVENT_FLAG_MBUTTON =4,
|
||||
EVENT_FLAG_CTRLKEY =8,
|
||||
EVENT_FLAG_SHIFTKEY =16,
|
||||
EVENT_FLAG_ALTKEY =32
|
||||
};
|
||||
|
||||
typedef void (*MouseCallback)(int event, int x, int y, int flags, void* userdata);
|
||||
|
||||
//! assigns callback for mouse events
|
||||
CV_EXPORTS void setMouseCallback(const string& winname, MouseCallback onMouse, void* userdata = 0);
|
||||
|
||||
|
||||
typedef void (CV_CDECL *TrackbarCallback)(int pos, void* userdata);
|
||||
|
||||
CV_EXPORTS int createTrackbar(const string& trackbarname, const string& winname,
|
||||
int* value, int count,
|
||||
TrackbarCallback onChange = 0,
|
||||
void* userdata = 0);
|
||||
|
||||
CV_EXPORTS_W int getTrackbarPos(const string& trackbarname, const string& winname);
|
||||
CV_EXPORTS_W void setTrackbarPos(const string& trackbarname, const string& winname, int pos);
|
||||
|
||||
// OpenGL support
|
||||
|
||||
typedef void (*OpenGlDrawCallback)(void* userdata);
|
||||
CV_EXPORTS void setOpenGlDrawCallback(const string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0);
|
||||
|
||||
CV_EXPORTS void setOpenGlContext(const string& winname);
|
||||
|
||||
CV_EXPORTS void updateWindow(const string& winname);
|
||||
|
||||
// < Deperecated
|
||||
CV_EXPORTS void pointCloudShow(const string& winname, const GlCamera& camera, const GlArrays& arr);
|
||||
CV_EXPORTS void pointCloudShow(const string& winname, const GlCamera& camera, InputArray points, InputArray colors = noArray());
|
||||
// >
|
||||
|
||||
//Only for Qt
|
||||
|
||||
CV_EXPORTS CvFont fontQt(const string& nameFont, int pointSize=-1,
|
||||
Scalar color=Scalar::all(0), int weight=CV_FONT_NORMAL,
|
||||
int style=CV_STYLE_NORMAL, int spacing=0);
|
||||
CV_EXPORTS void addText( const Mat& img, const string& text, Point org, CvFont font);
|
||||
|
||||
CV_EXPORTS void displayOverlay(const string& winname, const string& text, int delayms CV_DEFAULT(0));
|
||||
CV_EXPORTS void displayStatusBar(const string& winname, const string& text, int delayms CV_DEFAULT(0));
|
||||
|
||||
CV_EXPORTS void saveWindowParameters(const string& windowName);
|
||||
CV_EXPORTS void loadWindowParameters(const string& windowName);
|
||||
CV_EXPORTS int startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
|
||||
CV_EXPORTS void stopLoop();
|
||||
|
||||
typedef void (CV_CDECL *ButtonCallback)(int state, void* userdata);
|
||||
CV_EXPORTS int createButton( const string& bar_name, ButtonCallback on_change,
|
||||
void* userdata=NULL, int type=CV_PUSH_BUTTON,
|
||||
bool initial_button_state=0);
|
||||
|
||||
//-------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
// 8bit, color or not
|
||||
IMREAD_UNCHANGED =-1,
|
||||
// 8bit, gray
|
||||
IMREAD_GRAYSCALE =0,
|
||||
// ?, color
|
||||
IMREAD_COLOR =1,
|
||||
// any depth, ?
|
||||
IMREAD_ANYDEPTH =2,
|
||||
// ?, any color
|
||||
IMREAD_ANYCOLOR =4
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
IMWRITE_JPEG_QUALITY =1,
|
||||
IMWRITE_PNG_COMPRESSION =16,
|
||||
IMWRITE_PNG_STRATEGY =17,
|
||||
IMWRITE_PNG_BILEVEL =18,
|
||||
IMWRITE_PNG_STRATEGY_DEFAULT =0,
|
||||
IMWRITE_PNG_STRATEGY_FILTERED =1,
|
||||
IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY =2,
|
||||
IMWRITE_PNG_STRATEGY_RLE =3,
|
||||
IMWRITE_PNG_STRATEGY_FIXED =4,
|
||||
IMWRITE_PXM_BINARY =32
|
||||
};
|
||||
|
||||
CV_EXPORTS_W Mat imread( const string& filename, int flags=1 );
|
||||
CV_EXPORTS_W bool imwrite( const string& filename, InputArray img,
|
||||
const vector<int>& params=vector<int>());
|
||||
CV_EXPORTS_W Mat imdecode( InputArray buf, int flags );
|
||||
CV_EXPORTS Mat imdecode( InputArray buf, int flags, Mat* dst );
|
||||
CV_EXPORTS_W bool imencode( const string& ext, InputArray img,
|
||||
CV_OUT vector<uchar>& buf,
|
||||
const vector<int>& params=vector<int>());
|
||||
|
||||
#ifndef CV_NO_VIDEO_CAPTURE_CPP_API
|
||||
|
||||
template<> void CV_EXPORTS Ptr<CvCapture>::delete_obj();
|
||||
template<> void CV_EXPORTS Ptr<CvVideoWriter>::delete_obj();
|
||||
|
||||
class CV_EXPORTS_W VideoCapture
|
||||
{
|
||||
public:
|
||||
CV_WRAP VideoCapture();
|
||||
CV_WRAP VideoCapture(const string& filename);
|
||||
CV_WRAP VideoCapture(int device);
|
||||
|
||||
virtual ~VideoCapture();
|
||||
CV_WRAP virtual bool open(const string& filename);
|
||||
CV_WRAP virtual bool open(int device);
|
||||
CV_WRAP virtual bool isOpened() const;
|
||||
CV_WRAP virtual void release();
|
||||
|
||||
CV_WRAP virtual bool grab();
|
||||
CV_WRAP virtual bool retrieve(CV_OUT Mat& image, int channel=0);
|
||||
virtual VideoCapture& operator >> (CV_OUT Mat& image);
|
||||
CV_WRAP virtual bool read(CV_OUT Mat& image);
|
||||
|
||||
CV_WRAP virtual bool set(int propId, double value);
|
||||
CV_WRAP virtual double get(int propId);
|
||||
|
||||
protected:
|
||||
Ptr<CvCapture> cap;
|
||||
};
|
||||
|
||||
|
||||
class CV_EXPORTS_W VideoWriter
|
||||
{
|
||||
public:
|
||||
CV_WRAP VideoWriter();
|
||||
CV_WRAP VideoWriter(const string& filename, int fourcc, double fps,
|
||||
Size frameSize, bool isColor=true);
|
||||
|
||||
virtual ~VideoWriter();
|
||||
CV_WRAP virtual bool open(const string& filename, int fourcc, double fps,
|
||||
Size frameSize, bool isColor=true);
|
||||
CV_WRAP virtual bool isOpened() const;
|
||||
CV_WRAP virtual void release();
|
||||
virtual VideoWriter& operator << (const Mat& image);
|
||||
CV_WRAP virtual void write(const Mat& image);
|
||||
|
||||
protected:
|
||||
Ptr<CvVideoWriter> writer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,660 +0,0 @@
|
|||
/*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.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, 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 Intel Corporation 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_HIGHGUI_H__
|
||||
#define __OPENCV_HIGHGUI_H__
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/****************************************************************************************\
|
||||
* Basic GUI functions *
|
||||
\****************************************************************************************/
|
||||
//YV
|
||||
//-----------New for Qt
|
||||
/* For font */
|
||||
enum { CV_FONT_LIGHT = 25,//QFont::Light,
|
||||
CV_FONT_NORMAL = 50,//QFont::Normal,
|
||||
CV_FONT_DEMIBOLD = 63,//QFont::DemiBold,
|
||||
CV_FONT_BOLD = 75,//QFont::Bold,
|
||||
CV_FONT_BLACK = 87 //QFont::Black
|
||||
};
|
||||
|
||||
enum { CV_STYLE_NORMAL = 0,//QFont::StyleNormal,
|
||||
CV_STYLE_ITALIC = 1,//QFont::StyleItalic,
|
||||
CV_STYLE_OBLIQUE = 2 //QFont::StyleOblique
|
||||
};
|
||||
/* ---------*/
|
||||
|
||||
//for color cvScalar(blue_component, green_component, red\_component[, alpha_component])
|
||||
//and alpha= 0 <-> 0xFF (not transparent <-> transparent)
|
||||
CVAPI(CvFont) cvFontQt(const char* nameFont, int pointSize CV_DEFAULT(-1), CvScalar color CV_DEFAULT(cvScalarAll(0)), int weight CV_DEFAULT(CV_FONT_NORMAL), int style CV_DEFAULT(CV_STYLE_NORMAL), int spacing CV_DEFAULT(0));
|
||||
|
||||
CVAPI(void) cvAddText(const CvArr* img, const char* text, CvPoint org, CvFont *arg2);
|
||||
|
||||
CVAPI(void) cvDisplayOverlay(const char* name, const char* text, int delayms CV_DEFAULT(0));
|
||||
CVAPI(void) cvDisplayStatusBar(const char* name, const char* text, int delayms CV_DEFAULT(0));
|
||||
|
||||
CVAPI(void) cvSaveWindowParameters(const char* name);
|
||||
CVAPI(void) cvLoadWindowParameters(const char* name);
|
||||
CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
|
||||
CVAPI(void) cvStopLoop( void );
|
||||
|
||||
typedef void (CV_CDECL *CvButtonCallback)(int state, void* userdata);
|
||||
enum {CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1, CV_RADIOBOX = 2};
|
||||
CVAPI(int) cvCreateButton( const char* button_name CV_DEFAULT(NULL),CvButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL) , int button_type CV_DEFAULT(CV_PUSH_BUTTON), int initial_button_state CV_DEFAULT(0));
|
||||
//----------------------
|
||||
|
||||
|
||||
/* this function is used to set some external parameters in case of X Window */
|
||||
CVAPI(int) cvInitSystem( int argc, char** argv );
|
||||
|
||||
CVAPI(int) cvStartWindowThread( void );
|
||||
|
||||
// --------- YV ---------
|
||||
enum
|
||||
{
|
||||
//These 3 flags are used by cvSet/GetWindowProperty
|
||||
CV_WND_PROP_FULLSCREEN = 0, //to change/get window's fullscreen property
|
||||
CV_WND_PROP_AUTOSIZE = 1, //to change/get window's autosize property
|
||||
CV_WND_PROP_ASPECTRATIO= 2, //to change/get window's aspectratio property
|
||||
CV_WND_PROP_OPENGL = 3, //to change/get window's opengl support
|
||||
|
||||
//These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty
|
||||
CV_WINDOW_NORMAL = 0x00000000, //the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
|
||||
CV_WINDOW_AUTOSIZE = 0x00000001, //the user cannot resize the window, the size is constrainted by the image displayed
|
||||
CV_WINDOW_OPENGL = 0x00001000, //window with opengl support
|
||||
|
||||
//Those flags are only for Qt
|
||||
CV_GUI_EXPANDED = 0x00000000, //status bar and tool bar
|
||||
CV_GUI_NORMAL = 0x00000010, //old fashious way
|
||||
|
||||
//These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty
|
||||
CV_WINDOW_FULLSCREEN = 1,//change the window to fullscreen
|
||||
CV_WINDOW_FREERATIO = 0x00000100,//the image expends as much as it can (no ratio constraint)
|
||||
CV_WINDOW_KEEPRATIO = 0x00000000//the ration image is respected.
|
||||
};
|
||||
|
||||
/* create window */
|
||||
CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) );
|
||||
|
||||
/* Set and Get Property of the window */
|
||||
CVAPI(void) cvSetWindowProperty(const char* name, int prop_id, double prop_value);
|
||||
CVAPI(double) cvGetWindowProperty(const char* name, int prop_id);
|
||||
|
||||
/* display image within window (highgui windows remember their content) */
|
||||
CVAPI(void) cvShowImage( const char* name, const CvArr* image );
|
||||
|
||||
/* resize/move window */
|
||||
CVAPI(void) cvResizeWindow( const char* name, int width, int height );
|
||||
CVAPI(void) cvMoveWindow( const char* name, int x, int y );
|
||||
|
||||
|
||||
/* destroy window and all the trackers associated with it */
|
||||
CVAPI(void) cvDestroyWindow( const char* name );
|
||||
|
||||
CVAPI(void) cvDestroyAllWindows(void);
|
||||
|
||||
/* get native window handle (HWND in case of Win32 and Widget in case of X Window) */
|
||||
CVAPI(void*) cvGetWindowHandle( const char* name );
|
||||
|
||||
/* get name of highgui window given its native handle */
|
||||
CVAPI(const char*) cvGetWindowName( void* window_handle );
|
||||
|
||||
|
||||
typedef void (CV_CDECL *CvTrackbarCallback)(int pos);
|
||||
|
||||
/* create trackbar and display it on top of given window, set callback */
|
||||
CVAPI(int) cvCreateTrackbar( const char* trackbar_name, const char* window_name,
|
||||
int* value, int count, CvTrackbarCallback on_change CV_DEFAULT(NULL));
|
||||
|
||||
typedef void (CV_CDECL *CvTrackbarCallback2)(int pos, void* userdata);
|
||||
|
||||
CVAPI(int) cvCreateTrackbar2( const char* trackbar_name, const char* window_name,
|
||||
int* value, int count, CvTrackbarCallback2 on_change,
|
||||
void* userdata CV_DEFAULT(0));
|
||||
|
||||
/* retrieve or set trackbar position */
|
||||
CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* window_name );
|
||||
CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos );
|
||||
CVAPI(void) cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval);
|
||||
|
||||
enum
|
||||
{
|
||||
CV_EVENT_MOUSEMOVE =0,
|
||||
CV_EVENT_LBUTTONDOWN =1,
|
||||
CV_EVENT_RBUTTONDOWN =2,
|
||||
CV_EVENT_MBUTTONDOWN =3,
|
||||
CV_EVENT_LBUTTONUP =4,
|
||||
CV_EVENT_RBUTTONUP =5,
|
||||
CV_EVENT_MBUTTONUP =6,
|
||||
CV_EVENT_LBUTTONDBLCLK =7,
|
||||
CV_EVENT_RBUTTONDBLCLK =8,
|
||||
CV_EVENT_MBUTTONDBLCLK =9
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CV_EVENT_FLAG_LBUTTON =1,
|
||||
CV_EVENT_FLAG_RBUTTON =2,
|
||||
CV_EVENT_FLAG_MBUTTON =4,
|
||||
CV_EVENT_FLAG_CTRLKEY =8,
|
||||
CV_EVENT_FLAG_SHIFTKEY =16,
|
||||
CV_EVENT_FLAG_ALTKEY =32
|
||||
};
|
||||
|
||||
typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param);
|
||||
|
||||
/* assign callback for mouse events */
|
||||
CVAPI(void) cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse,
|
||||
void* param CV_DEFAULT(NULL));
|
||||
|
||||
enum
|
||||
{
|
||||
/* 8bit, color or not */
|
||||
CV_LOAD_IMAGE_UNCHANGED =-1,
|
||||
/* 8bit, gray */
|
||||
CV_LOAD_IMAGE_GRAYSCALE =0,
|
||||
/* ?, color */
|
||||
CV_LOAD_IMAGE_COLOR =1,
|
||||
/* any depth, ? */
|
||||
CV_LOAD_IMAGE_ANYDEPTH =2,
|
||||
/* ?, any color */
|
||||
CV_LOAD_IMAGE_ANYCOLOR =4
|
||||
};
|
||||
|
||||
/* load image from file
|
||||
iscolor can be a combination of above flags where CV_LOAD_IMAGE_UNCHANGED
|
||||
overrides the other flags
|
||||
using CV_LOAD_IMAGE_ANYCOLOR alone is equivalent to CV_LOAD_IMAGE_UNCHANGED
|
||||
unless CV_LOAD_IMAGE_ANYDEPTH is specified images are converted to 8bit
|
||||
*/
|
||||
CVAPI(IplImage*) cvLoadImage( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
|
||||
CVAPI(CvMat*) cvLoadImageM( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
|
||||
|
||||
enum
|
||||
{
|
||||
CV_IMWRITE_JPEG_QUALITY =1,
|
||||
CV_IMWRITE_PNG_COMPRESSION =16,
|
||||
CV_IMWRITE_PNG_STRATEGY =17,
|
||||
CV_IMWRITE_PNG_BILEVEL =18,
|
||||
CV_IMWRITE_PNG_STRATEGY_DEFAULT =0,
|
||||
CV_IMWRITE_PNG_STRATEGY_FILTERED =1,
|
||||
CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY =2,
|
||||
CV_IMWRITE_PNG_STRATEGY_RLE =3,
|
||||
CV_IMWRITE_PNG_STRATEGY_FIXED =4,
|
||||
CV_IMWRITE_PXM_BINARY =32
|
||||
};
|
||||
|
||||
/* save image to file */
|
||||
CVAPI(int) cvSaveImage( const char* filename, const CvArr* image,
|
||||
const int* params CV_DEFAULT(0) );
|
||||
|
||||
/* decode image stored in the buffer */
|
||||
CVAPI(IplImage*) cvDecodeImage( const CvMat* buf, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
|
||||
CVAPI(CvMat*) cvDecodeImageM( const CvMat* buf, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
|
||||
|
||||
/* encode image and store the result as a byte vector (single-row 8uC1 matrix) */
|
||||
CVAPI(CvMat*) cvEncodeImage( const char* ext, const CvArr* image,
|
||||
const int* params CV_DEFAULT(0) );
|
||||
|
||||
enum
|
||||
{
|
||||
CV_CVTIMG_FLIP =1,
|
||||
CV_CVTIMG_SWAP_RB =2
|
||||
};
|
||||
|
||||
/* utility function: convert one image to another with optional vertical flip */
|
||||
CVAPI(void) cvConvertImage( const CvArr* src, CvArr* dst, int flags CV_DEFAULT(0));
|
||||
|
||||
/* wait for key event infinitely (delay<=0) or for "delay" milliseconds */
|
||||
CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0));
|
||||
|
||||
// OpenGL support
|
||||
|
||||
typedef void (CV_CDECL *CvOpenGlDrawCallback)(void* userdata);
|
||||
CVAPI(void) cvSetOpenGlDrawCallback(const char* window_name, CvOpenGlDrawCallback callback, void* userdata CV_DEFAULT(NULL));
|
||||
|
||||
CVAPI(void) cvSetOpenGlContext(const char* window_name);
|
||||
CVAPI(void) cvUpdateWindow(const char* window_name);
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
* Working with Video Files and Cameras *
|
||||
\****************************************************************************************/
|
||||
|
||||
/* "black box" capture structure */
|
||||
typedef struct CvCapture CvCapture;
|
||||
|
||||
/* start capturing frames from video file */
|
||||
CVAPI(CvCapture*) cvCreateFileCapture( const char* filename );
|
||||
|
||||
enum
|
||||
{
|
||||
CV_CAP_ANY =0, // autodetect
|
||||
|
||||
CV_CAP_MIL =100, // MIL proprietary drivers
|
||||
|
||||
CV_CAP_VFW =200, // platform native
|
||||
CV_CAP_V4L =200,
|
||||
CV_CAP_V4L2 =200,
|
||||
|
||||
CV_CAP_FIREWARE =300, // IEEE 1394 drivers
|
||||
CV_CAP_FIREWIRE =300,
|
||||
CV_CAP_IEEE1394 =300,
|
||||
CV_CAP_DC1394 =300,
|
||||
CV_CAP_CMU1394 =300,
|
||||
|
||||
CV_CAP_STEREO =400, // TYZX proprietary drivers
|
||||
CV_CAP_TYZX =400,
|
||||
CV_TYZX_LEFT =400,
|
||||
CV_TYZX_RIGHT =401,
|
||||
CV_TYZX_COLOR =402,
|
||||
CV_TYZX_Z =403,
|
||||
|
||||
CV_CAP_QT =500, // QuickTime
|
||||
|
||||
CV_CAP_UNICAP =600, // Unicap drivers
|
||||
|
||||
CV_CAP_DSHOW =700, // DirectShow (via videoInput)
|
||||
CV_CAP_MSMF =1400, // Microsoft Media Foundation (via videoInput)
|
||||
|
||||
CV_CAP_PVAPI =800, // PvAPI, Prosilica GigE SDK
|
||||
|
||||
CV_CAP_OPENNI =900, // OpenNI (for Kinect)
|
||||
CV_CAP_OPENNI_ASUS =910, // OpenNI (for Asus Xtion)
|
||||
|
||||
CV_CAP_ANDROID =1000, // Android
|
||||
CV_CAP_ANDROID_BACK =CV_CAP_ANDROID+99, // Android back camera
|
||||
CV_CAP_ANDROID_FRONT =CV_CAP_ANDROID+98, // Android front camera
|
||||
|
||||
CV_CAP_XIAPI =1100, // XIMEA Camera API
|
||||
|
||||
CV_CAP_AVFOUNDATION = 1200, // AVFoundation framework for iOS (OS X Lion will have the same API)
|
||||
|
||||
CV_CAP_GIGANETIX = 1300, // Smartek Giganetix GigEVisionSDK
|
||||
|
||||
CV_CAP_INTELPERC = 1500 // Intel Perceptual Computing SDK
|
||||
};
|
||||
|
||||
/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */
|
||||
CVAPI(CvCapture*) cvCreateCameraCapture( int index );
|
||||
|
||||
/* grab a frame, return 1 on success, 0 on fail.
|
||||
this function is thought to be fast */
|
||||
CVAPI(int) cvGrabFrame( CvCapture* capture );
|
||||
|
||||
/* get the frame grabbed with cvGrabFrame(..)
|
||||
This function may apply some frame processing like
|
||||
frame decompression, flipping etc.
|
||||
!!!DO NOT RELEASE or MODIFY the retrieved frame!!! */
|
||||
CVAPI(IplImage*) cvRetrieveFrame( CvCapture* capture, int streamIdx CV_DEFAULT(0) );
|
||||
|
||||
/* Just a combination of cvGrabFrame and cvRetrieveFrame
|
||||
!!!DO NOT RELEASE or MODIFY the retrieved frame!!! */
|
||||
CVAPI(IplImage*) cvQueryFrame( CvCapture* capture );
|
||||
|
||||
/* stop capturing/reading and free resources */
|
||||
CVAPI(void) cvReleaseCapture( CvCapture** capture );
|
||||
|
||||
enum
|
||||
{
|
||||
// modes of the controlling registers (can be: auto, manual, auto single push, absolute Latter allowed with any other mode)
|
||||
// every feature can have only one mode turned on at a time
|
||||
CV_CAP_PROP_DC1394_OFF = -4, //turn the feature off (not controlled manually nor automatically)
|
||||
CV_CAP_PROP_DC1394_MODE_MANUAL = -3, //set automatically when a value of the feature is set by the user
|
||||
CV_CAP_PROP_DC1394_MODE_AUTO = -2,
|
||||
CV_CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO = -1,
|
||||
CV_CAP_PROP_POS_MSEC =0,
|
||||
CV_CAP_PROP_POS_FRAMES =1,
|
||||
CV_CAP_PROP_POS_AVI_RATIO =2,
|
||||
CV_CAP_PROP_FRAME_WIDTH =3,
|
||||
CV_CAP_PROP_FRAME_HEIGHT =4,
|
||||
CV_CAP_PROP_FPS =5,
|
||||
CV_CAP_PROP_FOURCC =6,
|
||||
CV_CAP_PROP_FRAME_COUNT =7,
|
||||
CV_CAP_PROP_FORMAT =8,
|
||||
CV_CAP_PROP_MODE =9,
|
||||
CV_CAP_PROP_BRIGHTNESS =10,
|
||||
CV_CAP_PROP_CONTRAST =11,
|
||||
CV_CAP_PROP_SATURATION =12,
|
||||
CV_CAP_PROP_HUE =13,
|
||||
CV_CAP_PROP_GAIN =14,
|
||||
CV_CAP_PROP_EXPOSURE =15,
|
||||
CV_CAP_PROP_CONVERT_RGB =16,
|
||||
CV_CAP_PROP_WHITE_BALANCE_U =17,
|
||||
CV_CAP_PROP_RECTIFICATION =18,
|
||||
CV_CAP_PROP_MONOCROME =19,
|
||||
CV_CAP_PROP_SHARPNESS =20,
|
||||
CV_CAP_PROP_AUTO_EXPOSURE =21, // exposure control done by camera,
|
||||
// user can adjust refernce level
|
||||
// using this feature
|
||||
CV_CAP_PROP_GAMMA =22,
|
||||
CV_CAP_PROP_TEMPERATURE =23,
|
||||
CV_CAP_PROP_TRIGGER =24,
|
||||
CV_CAP_PROP_TRIGGER_DELAY =25,
|
||||
CV_CAP_PROP_WHITE_BALANCE_V =26,
|
||||
CV_CAP_PROP_ZOOM =27,
|
||||
CV_CAP_PROP_FOCUS =28,
|
||||
CV_CAP_PROP_GUID =29,
|
||||
CV_CAP_PROP_ISO_SPEED =30,
|
||||
CV_CAP_PROP_MAX_DC1394 =31,
|
||||
CV_CAP_PROP_BACKLIGHT =32,
|
||||
CV_CAP_PROP_PAN =33,
|
||||
CV_CAP_PROP_TILT =34,
|
||||
CV_CAP_PROP_ROLL =35,
|
||||
CV_CAP_PROP_IRIS =36,
|
||||
CV_CAP_PROP_SETTINGS =37,
|
||||
CV_CAP_PROP_BUFFERSIZE =38,
|
||||
|
||||
CV_CAP_PROP_AUTOGRAB =1024, // property for highgui class CvCapture_Android only
|
||||
CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING=1025, // readonly, tricky property, returns cpnst char* indeed
|
||||
CV_CAP_PROP_PREVIEW_FORMAT=1026, // readonly, tricky property, returns cpnst char* indeed
|
||||
|
||||
// OpenNI map generators
|
||||
CV_CAP_OPENNI_DEPTH_GENERATOR = 1 << 31,
|
||||
CV_CAP_OPENNI_IMAGE_GENERATOR = 1 << 30,
|
||||
CV_CAP_OPENNI_GENERATORS_MASK = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_OPENNI_IMAGE_GENERATOR,
|
||||
|
||||
// Properties of cameras available through OpenNI interfaces
|
||||
CV_CAP_PROP_OPENNI_OUTPUT_MODE = 100,
|
||||
CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH = 101, // in mm
|
||||
CV_CAP_PROP_OPENNI_BASELINE = 102, // in mm
|
||||
CV_CAP_PROP_OPENNI_FOCAL_LENGTH = 103, // in pixels
|
||||
CV_CAP_PROP_OPENNI_REGISTRATION = 104, // flag
|
||||
CV_CAP_PROP_OPENNI_REGISTRATION_ON = CV_CAP_PROP_OPENNI_REGISTRATION, // flag that synchronizes the remapping depth map to image map
|
||||
// by changing depth generator's view point (if the flag is "on") or
|
||||
// sets this view point to its normal one (if the flag is "off").
|
||||
CV_CAP_PROP_OPENNI_APPROX_FRAME_SYNC = 105,
|
||||
CV_CAP_PROP_OPENNI_MAX_BUFFER_SIZE = 106,
|
||||
CV_CAP_PROP_OPENNI_CIRCLE_BUFFER = 107,
|
||||
CV_CAP_PROP_OPENNI_MAX_TIME_DURATION = 108,
|
||||
|
||||
CV_CAP_PROP_OPENNI_GENERATOR_PRESENT = 109,
|
||||
|
||||
CV_CAP_OPENNI_IMAGE_GENERATOR_PRESENT = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_GENERATOR_PRESENT,
|
||||
CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_OUTPUT_MODE,
|
||||
CV_CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_BASELINE,
|
||||
CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_FOCAL_LENGTH,
|
||||
CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_REGISTRATION,
|
||||
CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION,
|
||||
|
||||
// Properties of cameras available through GStreamer interface
|
||||
CV_CAP_GSTREAMER_QUEUE_LENGTH = 200, // default is 1
|
||||
|
||||
// PVAPI
|
||||
CV_CAP_PROP_PVAPI_MULTICASTIP = 300, // ip for anable multicast master mode. 0 for disable multicast
|
||||
CV_CAP_PROP_PVAPI_FRAMESTARTTRIGGERMODE = 301, // FrameStartTriggerMode: Determines how a frame is initiated
|
||||
CV_CAP_PROP_PVAPI_DECIMATIONHORIZONTAL = 302, // Horizontal sub-sampling of the image
|
||||
CV_CAP_PROP_PVAPI_DECIMATIONVERTICAL = 303, // Vertical sub-sampling of the image
|
||||
CV_CAP_PROP_PVAPI_BINNINGX = 304, // Horizontal binning factor
|
||||
CV_CAP_PROP_PVAPI_BINNINGY = 305, // Vertical binning factor
|
||||
CV_CAP_PROP_PVAPI_PIXELFORMAT = 306, // Pixel format
|
||||
|
||||
// Properties of cameras available through XIMEA SDK interface
|
||||
CV_CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping.
|
||||
CV_CAP_PROP_XI_DATA_FORMAT = 401, // Output data format.
|
||||
CV_CAP_PROP_XI_OFFSET_X = 402, // Horizontal offset from the origin to the area of interest (in pixels).
|
||||
CV_CAP_PROP_XI_OFFSET_Y = 403, // Vertical offset from the origin to the area of interest (in pixels).
|
||||
CV_CAP_PROP_XI_TRG_SOURCE = 404, // Defines source of trigger.
|
||||
CV_CAP_PROP_XI_TRG_SOFTWARE = 405, // Generates an internal trigger. PRM_TRG_SOURCE must be set to TRG_SOFTWARE.
|
||||
CV_CAP_PROP_XI_GPI_SELECTOR = 406, // Selects general purpose input
|
||||
CV_CAP_PROP_XI_GPI_MODE = 407, // Set general purpose input mode
|
||||
CV_CAP_PROP_XI_GPI_LEVEL = 408, // Get general purpose level
|
||||
CV_CAP_PROP_XI_GPO_SELECTOR = 409, // Selects general purpose output
|
||||
CV_CAP_PROP_XI_GPO_MODE = 410, // Set general purpose output mode
|
||||
CV_CAP_PROP_XI_LED_SELECTOR = 411, // Selects camera signalling LED
|
||||
CV_CAP_PROP_XI_LED_MODE = 412, // Define camera signalling LED functionality
|
||||
CV_CAP_PROP_XI_MANUAL_WB = 413, // Calculates White Balance(must be called during acquisition)
|
||||
CV_CAP_PROP_XI_AUTO_WB = 414, // Automatic white balance
|
||||
CV_CAP_PROP_XI_AEAG = 415, // Automatic exposure/gain
|
||||
CV_CAP_PROP_XI_EXP_PRIORITY = 416, // Exposure priority (0.5 - exposure 50%, gain 50%).
|
||||
CV_CAP_PROP_XI_AE_MAX_LIMIT = 417, // Maximum limit of exposure in AEAG procedure
|
||||
CV_CAP_PROP_XI_AG_MAX_LIMIT = 418, // Maximum limit of gain in AEAG procedure
|
||||
CV_CAP_PROP_XI_AEAG_LEVEL = 419, // Average intensity of output signal AEAG should achieve(in %)
|
||||
CV_CAP_PROP_XI_TIMEOUT = 420, // Image capture timeout in milliseconds
|
||||
|
||||
// Properties for Android cameras
|
||||
CV_CAP_PROP_ANDROID_FLASH_MODE = 8001,
|
||||
CV_CAP_PROP_ANDROID_FOCUS_MODE = 8002,
|
||||
CV_CAP_PROP_ANDROID_WHITE_BALANCE = 8003,
|
||||
CV_CAP_PROP_ANDROID_ANTIBANDING = 8004,
|
||||
CV_CAP_PROP_ANDROID_FOCAL_LENGTH = 8005,
|
||||
CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_NEAR = 8006,
|
||||
CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_OPTIMAL = 8007,
|
||||
CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_FAR = 8008,
|
||||
CV_CAP_PROP_ANDROID_EXPOSE_LOCK = 8009,
|
||||
CV_CAP_PROP_ANDROID_WHITEBALANCE_LOCK = 8010,
|
||||
|
||||
// Properties of cameras available through AVFOUNDATION interface
|
||||
CV_CAP_PROP_IOS_DEVICE_FOCUS = 9001,
|
||||
CV_CAP_PROP_IOS_DEVICE_EXPOSURE = 9002,
|
||||
CV_CAP_PROP_IOS_DEVICE_FLASH = 9003,
|
||||
CV_CAP_PROP_IOS_DEVICE_WHITEBALANCE = 9004,
|
||||
CV_CAP_PROP_IOS_DEVICE_TORCH = 9005,
|
||||
|
||||
// Properties of cameras available through Smartek Giganetix Ethernet Vision interface
|
||||
/* --- Vladimir Litvinenko (litvinenko.vladimir@gmail.com) --- */
|
||||
CV_CAP_PROP_GIGA_FRAME_OFFSET_X = 10001,
|
||||
CV_CAP_PROP_GIGA_FRAME_OFFSET_Y = 10002,
|
||||
CV_CAP_PROP_GIGA_FRAME_WIDTH_MAX = 10003,
|
||||
CV_CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004,
|
||||
CV_CAP_PROP_GIGA_FRAME_SENS_WIDTH = 10005,
|
||||
CV_CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006,
|
||||
|
||||
CV_CAP_PROP_INTELPERC_PROFILE_COUNT = 11001,
|
||||
CV_CAP_PROP_INTELPERC_PROFILE_IDX = 11002,
|
||||
CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE = 11003,
|
||||
CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE = 11004,
|
||||
CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD = 11005,
|
||||
CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ = 11006,
|
||||
CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007,
|
||||
|
||||
// Intel PerC streams
|
||||
CV_CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29,
|
||||
CV_CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28,
|
||||
CV_CAP_INTELPERC_GENERATORS_MASK = CV_CAP_INTELPERC_DEPTH_GENERATOR + CV_CAP_INTELPERC_IMAGE_GENERATOR
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// Data given from depth generator.
|
||||
CV_CAP_OPENNI_DEPTH_MAP = 0, // Depth values in mm (CV_16UC1)
|
||||
CV_CAP_OPENNI_POINT_CLOUD_MAP = 1, // XYZ in meters (CV_32FC3)
|
||||
CV_CAP_OPENNI_DISPARITY_MAP = 2, // Disparity in pixels (CV_8UC1)
|
||||
CV_CAP_OPENNI_DISPARITY_MAP_32F = 3, // Disparity in pixels (CV_32FC1)
|
||||
CV_CAP_OPENNI_VALID_DEPTH_MASK = 4, // CV_8UC1
|
||||
|
||||
// Data given from RGB image generator.
|
||||
CV_CAP_OPENNI_BGR_IMAGE = 5,
|
||||
CV_CAP_OPENNI_GRAY_IMAGE = 6
|
||||
};
|
||||
|
||||
// Supported output modes of OpenNI image generator
|
||||
enum
|
||||
{
|
||||
CV_CAP_OPENNI_VGA_30HZ = 0,
|
||||
CV_CAP_OPENNI_SXGA_15HZ = 1,
|
||||
CV_CAP_OPENNI_SXGA_30HZ = 2,
|
||||
CV_CAP_OPENNI_QVGA_30HZ = 3,
|
||||
CV_CAP_OPENNI_QVGA_60HZ = 4
|
||||
};
|
||||
|
||||
//supported by Android camera output formats
|
||||
enum
|
||||
{
|
||||
CV_CAP_ANDROID_COLOR_FRAME_BGR = 0, //BGR
|
||||
CV_CAP_ANDROID_COLOR_FRAME = CV_CAP_ANDROID_COLOR_FRAME_BGR,
|
||||
CV_CAP_ANDROID_GREY_FRAME = 1, //Y
|
||||
CV_CAP_ANDROID_COLOR_FRAME_RGB = 2,
|
||||
CV_CAP_ANDROID_COLOR_FRAME_BGRA = 3,
|
||||
CV_CAP_ANDROID_COLOR_FRAME_RGBA = 4
|
||||
};
|
||||
|
||||
// supported Android camera flash modes
|
||||
enum
|
||||
{
|
||||
CV_CAP_ANDROID_FLASH_MODE_AUTO = 0,
|
||||
CV_CAP_ANDROID_FLASH_MODE_OFF,
|
||||
CV_CAP_ANDROID_FLASH_MODE_ON,
|
||||
CV_CAP_ANDROID_FLASH_MODE_RED_EYE,
|
||||
CV_CAP_ANDROID_FLASH_MODE_TORCH
|
||||
};
|
||||
|
||||
// supported Android camera focus modes
|
||||
enum
|
||||
{
|
||||
CV_CAP_ANDROID_FOCUS_MODE_AUTO = 0,
|
||||
CV_CAP_ANDROID_FOCUS_MODE_CONTINUOUS_PICTURE,
|
||||
CV_CAP_ANDROID_FOCUS_MODE_CONTINUOUS_VIDEO,
|
||||
CV_CAP_ANDROID_FOCUS_MODE_EDOF,
|
||||
CV_CAP_ANDROID_FOCUS_MODE_FIXED,
|
||||
CV_CAP_ANDROID_FOCUS_MODE_INFINITY,
|
||||
CV_CAP_ANDROID_FOCUS_MODE_MACRO
|
||||
};
|
||||
|
||||
// supported Android camera white balance modes
|
||||
enum
|
||||
{
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_AUTO = 0,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_CLOUDY_DAYLIGHT,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_DAYLIGHT,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_FLUORESCENT,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_INCANDESCENT,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_SHADE,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_TWILIGHT,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_WARM_FLUORESCENT
|
||||
};
|
||||
|
||||
// supported Android camera antibanding modes
|
||||
enum
|
||||
{
|
||||
CV_CAP_ANDROID_ANTIBANDING_50HZ = 0,
|
||||
CV_CAP_ANDROID_ANTIBANDING_60HZ,
|
||||
CV_CAP_ANDROID_ANTIBANDING_AUTO,
|
||||
CV_CAP_ANDROID_ANTIBANDING_OFF
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CV_CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth.
|
||||
CV_CAP_INTELPERC_UVDEPTH_MAP = 1, // Each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates.
|
||||
CV_CAP_INTELPERC_IR_MAP = 2, // Each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam.
|
||||
CV_CAP_INTELPERC_IMAGE = 3
|
||||
};
|
||||
|
||||
/* retrieve or set capture properties */
|
||||
CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id );
|
||||
CVAPI(int) cvSetCaptureProperty( CvCapture* capture, int property_id, double value );
|
||||
|
||||
// Return the type of the capturer (eg, CV_CAP_V4W, CV_CAP_UNICAP), which is unknown if created with CV_CAP_ANY
|
||||
CVAPI(int) cvGetCaptureDomain( CvCapture* capture);
|
||||
|
||||
/* "black box" video file writer structure */
|
||||
typedef struct CvVideoWriter CvVideoWriter;
|
||||
|
||||
#define CV_FOURCC_MACRO(c1, c2, c3, c4) (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24))
|
||||
|
||||
CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4)
|
||||
{
|
||||
return CV_FOURCC_MACRO(c1, c2, c3, c4);
|
||||
}
|
||||
|
||||
#define CV_FOURCC_PROMPT -1 /* Open Codec Selection Dialog (Windows only) */
|
||||
#define CV_FOURCC_DEFAULT CV_FOURCC('I', 'Y', 'U', 'V') /* Use default codec for specified filename (Linux only) */
|
||||
|
||||
/* initialize video file writer */
|
||||
CVAPI(CvVideoWriter*) cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
double fps, CvSize frame_size,
|
||||
int is_color CV_DEFAULT(1));
|
||||
|
||||
//CVAPI(CvVideoWriter*) cvCreateImageSequenceWriter( const char* filename,
|
||||
// int is_color CV_DEFAULT(1));
|
||||
|
||||
/* write frame to video file */
|
||||
CVAPI(int) cvWriteFrame( CvVideoWriter* writer, const IplImage* image );
|
||||
|
||||
/* close video file writer */
|
||||
CVAPI(void) cvReleaseVideoWriter( CvVideoWriter** writer );
|
||||
|
||||
/****************************************************************************************\
|
||||
* Obsolete functions/synonyms *
|
||||
\****************************************************************************************/
|
||||
|
||||
#define cvCaptureFromFile cvCreateFileCapture
|
||||
#define cvCaptureFromCAM cvCreateCameraCapture
|
||||
#define cvCaptureFromAVI cvCaptureFromFile
|
||||
#define cvCreateAVIWriter cvCreateVideoWriter
|
||||
#define cvWriteToAVI cvWriteFrame
|
||||
#define cvAddSearchPath(path)
|
||||
#define cvvInitSystem cvInitSystem
|
||||
#define cvvNamedWindow cvNamedWindow
|
||||
#define cvvShowImage cvShowImage
|
||||
#define cvvResizeWindow cvResizeWindow
|
||||
#define cvvDestroyWindow cvDestroyWindow
|
||||
#define cvvCreateTrackbar cvCreateTrackbar
|
||||
#define cvvLoadImage(name) cvLoadImage((name),1)
|
||||
#define cvvSaveImage cvSaveImage
|
||||
#define cvvAddSearchPath cvAddSearchPath
|
||||
#define cvvWaitKey(name) cvWaitKey(0)
|
||||
#define cvvWaitKeyEx(name,delay) cvWaitKey(delay)
|
||||
#define cvvConvertImage cvConvertImage
|
||||
#define HG_AUTOSIZE CV_WINDOW_AUTOSIZE
|
||||
#define set_preprocess_func cvSetPreprocessFuncWin32
|
||||
#define set_postprocess_func cvSetPostprocessFuncWin32
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
|
||||
CVAPI(void) cvSetPreprocessFuncWin32_(const void* callback);
|
||||
CVAPI(void) cvSetPostprocessFuncWin32_(const void* callback);
|
||||
#define cvSetPreprocessFuncWin32(callback) cvSetPreprocessFuncWin32_((const void*)(callback))
|
||||
#define cvSetPostprocessFuncWin32(callback) cvSetPostprocessFuncWin32_((const void*)(callback))
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
/*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.
|
||||
// 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*/
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#import "opencv2/highgui/cap_ios.h"
|
||||
|
||||
UIImage* MatToUIImage(const cv::Mat& image);
|
||||
void UIImageToMat(const UIImage* image,
|
||||
cv::Mat& m, bool alphaExist = false);
|
File diff suppressed because it is too large
Load Diff
|
@ -1,623 +0,0 @@
|
|||
/*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.
|
||||
// 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_IMGPROC_IMGPROC_C_H__
|
||||
#define __OPENCV_IMGPROC_IMGPROC_C_H__
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/imgproc/types_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************** Background statistics accumulation *****************************/
|
||||
|
||||
/* Adds image to accumulator */
|
||||
CVAPI(void) cvAcc( const CvArr* image, CvArr* sum,
|
||||
const CvArr* mask CV_DEFAULT(NULL) );
|
||||
|
||||
/* Adds squared image to accumulator */
|
||||
CVAPI(void) cvSquareAcc( const CvArr* image, CvArr* sqsum,
|
||||
const CvArr* mask CV_DEFAULT(NULL) );
|
||||
|
||||
/* Adds a product of two images to accumulator */
|
||||
CVAPI(void) cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc,
|
||||
const CvArr* mask CV_DEFAULT(NULL) );
|
||||
|
||||
/* Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha */
|
||||
CVAPI(void) cvRunningAvg( const CvArr* image, CvArr* acc, double alpha,
|
||||
const CvArr* mask CV_DEFAULT(NULL) );
|
||||
|
||||
/****************************************************************************************\
|
||||
* Image Processing *
|
||||
\****************************************************************************************/
|
||||
|
||||
/* Copies source 2D array inside of the larger destination array and
|
||||
makes a border of the specified type (IPL_BORDER_*) around the copied area. */
|
||||
CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset,
|
||||
int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0)));
|
||||
|
||||
/* Smoothes array (removes noise) */
|
||||
CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst,
|
||||
int smoothtype CV_DEFAULT(CV_GAUSSIAN),
|
||||
int size1 CV_DEFAULT(3),
|
||||
int size2 CV_DEFAULT(0),
|
||||
double sigma1 CV_DEFAULT(0),
|
||||
double sigma2 CV_DEFAULT(0));
|
||||
|
||||
/* Convolves the image with the kernel */
|
||||
CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel,
|
||||
CvPoint anchor CV_DEFAULT(cvPoint(-1,-1)));
|
||||
|
||||
/* Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y) */
|
||||
CVAPI(void) cvIntegral( const CvArr* image, CvArr* sum,
|
||||
CvArr* sqsum CV_DEFAULT(NULL),
|
||||
CvArr* tilted_sum CV_DEFAULT(NULL));
|
||||
|
||||
/*
|
||||
Smoothes the input image with gaussian kernel and then down-samples it.
|
||||
dst_width = floor(src_width/2)[+1],
|
||||
dst_height = floor(src_height/2)[+1]
|
||||
*/
|
||||
CVAPI(void) cvPyrDown( const CvArr* src, CvArr* dst,
|
||||
int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
|
||||
|
||||
/*
|
||||
Up-samples image and smoothes the result with gaussian kernel.
|
||||
dst_width = src_width*2,
|
||||
dst_height = src_height*2
|
||||
*/
|
||||
CVAPI(void) cvPyrUp( const CvArr* src, CvArr* dst,
|
||||
int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
|
||||
|
||||
/* Builds pyramid for an image */
|
||||
CVAPI(CvMat**) cvCreatePyramid( const CvArr* img, int extra_layers, double rate,
|
||||
const CvSize* layer_sizes CV_DEFAULT(0),
|
||||
CvArr* bufarr CV_DEFAULT(0),
|
||||
int calc CV_DEFAULT(1),
|
||||
int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
|
||||
|
||||
/* Releases pyramid */
|
||||
CVAPI(void) cvReleasePyramid( CvMat*** pyramid, int extra_layers );
|
||||
|
||||
|
||||
/* Filters image using meanshift algorithm */
|
||||
CVAPI(void) cvPyrMeanShiftFiltering( const CvArr* src, CvArr* dst,
|
||||
double sp, double sr, int max_level CV_DEFAULT(1),
|
||||
CvTermCriteria termcrit CV_DEFAULT(cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,5,1)));
|
||||
|
||||
/* Segments image using seed "markers" */
|
||||
CVAPI(void) cvWatershed( const CvArr* image, CvArr* markers );
|
||||
|
||||
/* Calculates an image derivative using generalized Sobel
|
||||
(aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator.
|
||||
Scharr can be used only for the first dx or dy derivative */
|
||||
CVAPI(void) cvSobel( const CvArr* src, CvArr* dst,
|
||||
int xorder, int yorder,
|
||||
int aperture_size CV_DEFAULT(3));
|
||||
|
||||
/* Calculates the image Laplacian: (d2/dx + d2/dy)I */
|
||||
CVAPI(void) cvLaplace( const CvArr* src, CvArr* dst,
|
||||
int aperture_size CV_DEFAULT(3) );
|
||||
|
||||
/* Converts input array pixels from one color space to another */
|
||||
CVAPI(void) cvCvtColor( const CvArr* src, CvArr* dst, int code );
|
||||
|
||||
|
||||
/* Resizes image (input array is resized to fit the destination array) */
|
||||
CVAPI(void) cvResize( const CvArr* src, CvArr* dst,
|
||||
int interpolation CV_DEFAULT( CV_INTER_LINEAR ));
|
||||
|
||||
/* Warps image with affine transform */
|
||||
CVAPI(void) cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
|
||||
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
|
||||
CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
|
||||
|
||||
/* Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2) */
|
||||
CVAPI(CvMat*) cvGetAffineTransform( const CvPoint2D32f * src,
|
||||
const CvPoint2D32f * dst,
|
||||
CvMat * map_matrix );
|
||||
|
||||
/* Computes rotation_matrix matrix */
|
||||
CVAPI(CvMat*) cv2DRotationMatrix( CvPoint2D32f center, double angle,
|
||||
double scale, CvMat* map_matrix );
|
||||
|
||||
/* Warps image with perspective (projective) transform */
|
||||
CVAPI(void) cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
|
||||
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
|
||||
CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
|
||||
|
||||
/* Computes perspective transform matrix for mapping src[i] to dst[i] (i=0,1,2,3) */
|
||||
CVAPI(CvMat*) cvGetPerspectiveTransform( const CvPoint2D32f* src,
|
||||
const CvPoint2D32f* dst,
|
||||
CvMat* map_matrix );
|
||||
|
||||
/* Performs generic geometric transformation using the specified coordinate maps */
|
||||
CVAPI(void) cvRemap( const CvArr* src, CvArr* dst,
|
||||
const CvArr* mapx, const CvArr* mapy,
|
||||
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
|
||||
CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
|
||||
|
||||
/* Converts mapx & mapy from floating-point to integer formats for cvRemap */
|
||||
CVAPI(void) cvConvertMaps( const CvArr* mapx, const CvArr* mapy,
|
||||
CvArr* mapxy, CvArr* mapalpha );
|
||||
|
||||
/* Performs forward or inverse log-polar image transform */
|
||||
CVAPI(void) cvLogPolar( const CvArr* src, CvArr* dst,
|
||||
CvPoint2D32f center, double M,
|
||||
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
|
||||
|
||||
/* Performs forward or inverse linear-polar image transform */
|
||||
CVAPI(void) cvLinearPolar( const CvArr* src, CvArr* dst,
|
||||
CvPoint2D32f center, double maxRadius,
|
||||
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
|
||||
|
||||
/* Transforms the input image to compensate lens distortion */
|
||||
CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst,
|
||||
const CvMat* camera_matrix,
|
||||
const CvMat* distortion_coeffs,
|
||||
const CvMat* new_camera_matrix CV_DEFAULT(0) );
|
||||
|
||||
/* Computes transformation map from intrinsic camera parameters
|
||||
that can used by cvRemap */
|
||||
CVAPI(void) cvInitUndistortMap( const CvMat* camera_matrix,
|
||||
const CvMat* distortion_coeffs,
|
||||
CvArr* mapx, CvArr* mapy );
|
||||
|
||||
/* Computes undistortion+rectification map for a head of stereo camera */
|
||||
CVAPI(void) cvInitUndistortRectifyMap( const CvMat* camera_matrix,
|
||||
const CvMat* dist_coeffs,
|
||||
const CvMat *R, const CvMat* new_camera_matrix,
|
||||
CvArr* mapx, CvArr* mapy );
|
||||
|
||||
/* Computes the original (undistorted) feature coordinates
|
||||
from the observed (distorted) coordinates */
|
||||
CVAPI(void) cvUndistortPoints( const CvMat* src, CvMat* dst,
|
||||
const CvMat* camera_matrix,
|
||||
const CvMat* dist_coeffs,
|
||||
const CvMat* R CV_DEFAULT(0),
|
||||
const CvMat* P CV_DEFAULT(0));
|
||||
|
||||
/* creates structuring element used for morphological operations */
|
||||
CVAPI(IplConvKernel*) cvCreateStructuringElementEx(
|
||||
int cols, int rows, int anchor_x, int anchor_y,
|
||||
int shape, int* values CV_DEFAULT(NULL) );
|
||||
|
||||
/* releases structuring element */
|
||||
CVAPI(void) cvReleaseStructuringElement( IplConvKernel** element );
|
||||
|
||||
/* erodes input image (applies minimum filter) one or more times.
|
||||
If element pointer is NULL, 3x3 rectangular element is used */
|
||||
CVAPI(void) cvErode( const CvArr* src, CvArr* dst,
|
||||
IplConvKernel* element CV_DEFAULT(NULL),
|
||||
int iterations CV_DEFAULT(1) );
|
||||
|
||||
/* dilates input image (applies maximum filter) one or more times.
|
||||
If element pointer is NULL, 3x3 rectangular element is used */
|
||||
CVAPI(void) cvDilate( const CvArr* src, CvArr* dst,
|
||||
IplConvKernel* element CV_DEFAULT(NULL),
|
||||
int iterations CV_DEFAULT(1) );
|
||||
|
||||
/* Performs complex morphological transformation */
|
||||
CVAPI(void) cvMorphologyEx( const CvArr* src, CvArr* dst,
|
||||
CvArr* temp, IplConvKernel* element,
|
||||
int operation, int iterations CV_DEFAULT(1) );
|
||||
|
||||
/* Calculates all spatial and central moments up to the 3rd order */
|
||||
CVAPI(void) cvMoments( const CvArr* arr, CvMoments* moments, int binary CV_DEFAULT(0));
|
||||
|
||||
/* Retrieve particular spatial, central or normalized central moments */
|
||||
CVAPI(double) cvGetSpatialMoment( CvMoments* moments, int x_order, int y_order );
|
||||
CVAPI(double) cvGetCentralMoment( CvMoments* moments, int x_order, int y_order );
|
||||
CVAPI(double) cvGetNormalizedCentralMoment( CvMoments* moments,
|
||||
int x_order, int y_order );
|
||||
|
||||
/* Calculates 7 Hu's invariants from precalculated spatial and central moments */
|
||||
CVAPI(void) cvGetHuMoments( CvMoments* moments, CvHuMoments* hu_moments );
|
||||
|
||||
/*********************************** data sampling **************************************/
|
||||
|
||||
/* Fetches pixels that belong to the specified line segment and stores them to the buffer.
|
||||
Returns the number of retrieved points. */
|
||||
CVAPI(int) cvSampleLine( const CvArr* image, CvPoint pt1, CvPoint pt2, void* buffer,
|
||||
int connectivity CV_DEFAULT(8));
|
||||
|
||||
/* Retrieves the rectangular image region with specified center from the input array.
|
||||
dst(x,y) <- src(x + center.x - dst_width/2, y + center.y - dst_height/2).
|
||||
Values of pixels with fractional coordinates are retrieved using bilinear interpolation*/
|
||||
CVAPI(void) cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center );
|
||||
|
||||
|
||||
/* Retrieves quadrangle from the input array.
|
||||
matrixarr = ( a11 a12 | b1 ) dst(x,y) <- src(A[x y]' + b)
|
||||
( a21 a22 | b2 ) (bilinear interpolation is used to retrieve pixels
|
||||
with fractional coordinates)
|
||||
*/
|
||||
CVAPI(void) cvGetQuadrangleSubPix( const CvArr* src, CvArr* dst,
|
||||
const CvMat* map_matrix );
|
||||
|
||||
/* Measures similarity between template and overlapped windows in the source image
|
||||
and fills the resultant image with the measurements */
|
||||
CVAPI(void) cvMatchTemplate( const CvArr* image, const CvArr* templ,
|
||||
CvArr* result, int method );
|
||||
|
||||
/* Computes earth mover distance between
|
||||
two weighted point sets (called signatures) */
|
||||
CVAPI(float) cvCalcEMD2( const CvArr* signature1,
|
||||
const CvArr* signature2,
|
||||
int distance_type,
|
||||
CvDistanceFunction distance_func CV_DEFAULT(NULL),
|
||||
const CvArr* cost_matrix CV_DEFAULT(NULL),
|
||||
CvArr* flow CV_DEFAULT(NULL),
|
||||
float* lower_bound CV_DEFAULT(NULL),
|
||||
void* userdata CV_DEFAULT(NULL));
|
||||
|
||||
/****************************************************************************************\
|
||||
* Contours retrieving *
|
||||
\****************************************************************************************/
|
||||
|
||||
/* Retrieves outer and optionally inner boundaries of white (non-zero) connected
|
||||
components in the black (zero) background */
|
||||
CVAPI(int) cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour,
|
||||
int header_size CV_DEFAULT(sizeof(CvContour)),
|
||||
int mode CV_DEFAULT(CV_RETR_LIST),
|
||||
int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
|
||||
CvPoint offset CV_DEFAULT(cvPoint(0,0)));
|
||||
|
||||
/* Initializes contour retrieving process.
|
||||
Calls cvStartFindContours.
|
||||
Calls cvFindNextContour until null pointer is returned
|
||||
or some other condition becomes true.
|
||||
Calls cvEndFindContours at the end. */
|
||||
CVAPI(CvContourScanner) cvStartFindContours( CvArr* image, CvMemStorage* storage,
|
||||
int header_size CV_DEFAULT(sizeof(CvContour)),
|
||||
int mode CV_DEFAULT(CV_RETR_LIST),
|
||||
int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
|
||||
CvPoint offset CV_DEFAULT(cvPoint(0,0)));
|
||||
|
||||
/* Retrieves next contour */
|
||||
CVAPI(CvSeq*) cvFindNextContour( CvContourScanner scanner );
|
||||
|
||||
|
||||
/* Substitutes the last retrieved contour with the new one
|
||||
(if the substitutor is null, the last retrieved contour is removed from the tree) */
|
||||
CVAPI(void) cvSubstituteContour( CvContourScanner scanner, CvSeq* new_contour );
|
||||
|
||||
|
||||
/* Releases contour scanner and returns pointer to the first outer contour */
|
||||
CVAPI(CvSeq*) cvEndFindContours( CvContourScanner* scanner );
|
||||
|
||||
/* Approximates a single Freeman chain or a tree of chains to polygonal curves */
|
||||
CVAPI(CvSeq*) cvApproxChains( CvSeq* src_seq, CvMemStorage* storage,
|
||||
int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
|
||||
double parameter CV_DEFAULT(0),
|
||||
int minimal_perimeter CV_DEFAULT(0),
|
||||
int recursive CV_DEFAULT(0));
|
||||
|
||||
/* Initializes Freeman chain reader.
|
||||
The reader is used to iteratively get coordinates of all the chain points.
|
||||
If the Freeman codes should be read as is, a simple sequence reader should be used */
|
||||
CVAPI(void) cvStartReadChainPoints( CvChain* chain, CvChainPtReader* reader );
|
||||
|
||||
/* Retrieves the next chain point */
|
||||
CVAPI(CvPoint) cvReadChainPoint( CvChainPtReader* reader );
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
* Contour Processing and Shape Analysis *
|
||||
\****************************************************************************************/
|
||||
|
||||
/* Approximates a single polygonal curve (contour) or
|
||||
a tree of polygonal curves (contours) */
|
||||
CVAPI(CvSeq*) cvApproxPoly( const void* src_seq,
|
||||
int header_size, CvMemStorage* storage,
|
||||
int method, double eps,
|
||||
int recursive CV_DEFAULT(0));
|
||||
|
||||
/* Calculates perimeter of a contour or length of a part of contour */
|
||||
CVAPI(double) cvArcLength( const void* curve,
|
||||
CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
|
||||
int is_closed CV_DEFAULT(-1));
|
||||
|
||||
CV_INLINE double cvContourPerimeter( const void* contour )
|
||||
{
|
||||
return cvArcLength( contour, CV_WHOLE_SEQ, 1 );
|
||||
}
|
||||
|
||||
|
||||
/* Calculates contour bounding rectangle (update=1) or
|
||||
just retrieves pre-calculated rectangle (update=0) */
|
||||
CVAPI(CvRect) cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) );
|
||||
|
||||
/* Calculates area of a contour or contour segment */
|
||||
CVAPI(double) cvContourArea( const CvArr* contour,
|
||||
CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
|
||||
int oriented CV_DEFAULT(0));
|
||||
|
||||
/* Finds minimum area rotated rectangle bounding a set of points */
|
||||
CVAPI(CvBox2D) cvMinAreaRect2( const CvArr* points,
|
||||
CvMemStorage* storage CV_DEFAULT(NULL));
|
||||
|
||||
/* Finds minimum enclosing circle for a set of points */
|
||||
CVAPI(int) cvMinEnclosingCircle( const CvArr* points,
|
||||
CvPoint2D32f* center, float* radius );
|
||||
|
||||
/* Compares two contours by matching their moments */
|
||||
CVAPI(double) cvMatchShapes( const void* object1, const void* object2,
|
||||
int method, double parameter CV_DEFAULT(0));
|
||||
|
||||
/* Calculates exact convex hull of 2d point set */
|
||||
CVAPI(CvSeq*) cvConvexHull2( const CvArr* input,
|
||||
void* hull_storage CV_DEFAULT(NULL),
|
||||
int orientation CV_DEFAULT(CV_CLOCKWISE),
|
||||
int return_points CV_DEFAULT(0));
|
||||
|
||||
/* Checks whether the contour is convex or not (returns 1 if convex, 0 if not) */
|
||||
CVAPI(int) cvCheckContourConvexity( const CvArr* contour );
|
||||
|
||||
|
||||
/* Finds convexity defects for the contour */
|
||||
CVAPI(CvSeq*) cvConvexityDefects( const CvArr* contour, const CvArr* convexhull,
|
||||
CvMemStorage* storage CV_DEFAULT(NULL));
|
||||
|
||||
/* Fits ellipse into a set of 2d points */
|
||||
CVAPI(CvBox2D) cvFitEllipse2( const CvArr* points );
|
||||
|
||||
/* Finds minimum rectangle containing two given rectangles */
|
||||
CVAPI(CvRect) cvMaxRect( const CvRect* rect1, const CvRect* rect2 );
|
||||
|
||||
/* Finds coordinates of the box vertices */
|
||||
CVAPI(void) cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] );
|
||||
|
||||
/* Initializes sequence header for a matrix (column or row vector) of points -
|
||||
a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!) */
|
||||
CVAPI(CvSeq*) cvPointSeqFromMat( int seq_kind, const CvArr* mat,
|
||||
CvContour* contour_header,
|
||||
CvSeqBlock* block );
|
||||
|
||||
/* Checks whether the point is inside polygon, outside, on an edge (at a vertex).
|
||||
Returns positive, negative or zero value, correspondingly.
|
||||
Optionally, measures a signed distance between
|
||||
the point and the nearest polygon edge (measure_dist=1) */
|
||||
CVAPI(double) cvPointPolygonTest( const CvArr* contour,
|
||||
CvPoint2D32f pt, int measure_dist );
|
||||
|
||||
/****************************************************************************************\
|
||||
* Histogram functions *
|
||||
\****************************************************************************************/
|
||||
|
||||
/* Creates new histogram */
|
||||
CVAPI(CvHistogram*) cvCreateHist( int dims, int* sizes, int type,
|
||||
float** ranges CV_DEFAULT(NULL),
|
||||
int uniform CV_DEFAULT(1));
|
||||
|
||||
/* Assignes histogram bin ranges */
|
||||
CVAPI(void) cvSetHistBinRanges( CvHistogram* hist, float** ranges,
|
||||
int uniform CV_DEFAULT(1));
|
||||
|
||||
/* Creates histogram header for array */
|
||||
CVAPI(CvHistogram*) cvMakeHistHeaderForArray(
|
||||
int dims, int* sizes, CvHistogram* hist,
|
||||
float* data, float** ranges CV_DEFAULT(NULL),
|
||||
int uniform CV_DEFAULT(1));
|
||||
|
||||
/* Releases histogram */
|
||||
CVAPI(void) cvReleaseHist( CvHistogram** hist );
|
||||
|
||||
/* Clears all the histogram bins */
|
||||
CVAPI(void) cvClearHist( CvHistogram* hist );
|
||||
|
||||
/* Finds indices and values of minimum and maximum histogram bins */
|
||||
CVAPI(void) cvGetMinMaxHistValue( const CvHistogram* hist,
|
||||
float* min_value, float* max_value,
|
||||
int* min_idx CV_DEFAULT(NULL),
|
||||
int* max_idx CV_DEFAULT(NULL));
|
||||
|
||||
|
||||
/* Normalizes histogram by dividing all bins by sum of the bins, multiplied by <factor>.
|
||||
After that sum of histogram bins is equal to <factor> */
|
||||
CVAPI(void) cvNormalizeHist( CvHistogram* hist, double factor );
|
||||
|
||||
|
||||
/* Clear all histogram bins that are below the threshold */
|
||||
CVAPI(void) cvThreshHist( CvHistogram* hist, double threshold );
|
||||
|
||||
|
||||
/* Compares two histogram */
|
||||
CVAPI(double) cvCompareHist( const CvHistogram* hist1,
|
||||
const CvHistogram* hist2,
|
||||
int method);
|
||||
|
||||
/* Copies one histogram to another. Destination histogram is created if
|
||||
the destination pointer is NULL */
|
||||
CVAPI(void) cvCopyHist( const CvHistogram* src, CvHistogram** dst );
|
||||
|
||||
|
||||
/* Calculates bayesian probabilistic histograms
|
||||
(each or src and dst is an array of <number> histograms */
|
||||
CVAPI(void) cvCalcBayesianProb( CvHistogram** src, int number,
|
||||
CvHistogram** dst);
|
||||
|
||||
/* Calculates array histogram */
|
||||
CVAPI(void) cvCalcArrHist( CvArr** arr, CvHistogram* hist,
|
||||
int accumulate CV_DEFAULT(0),
|
||||
const CvArr* mask CV_DEFAULT(NULL) );
|
||||
|
||||
CV_INLINE void cvCalcHist( IplImage** image, CvHistogram* hist,
|
||||
int accumulate CV_DEFAULT(0),
|
||||
const CvArr* mask CV_DEFAULT(NULL) )
|
||||
{
|
||||
cvCalcArrHist( (CvArr**)image, hist, accumulate, mask );
|
||||
}
|
||||
|
||||
/* Calculates back project */
|
||||
CVAPI(void) cvCalcArrBackProject( CvArr** image, CvArr* dst,
|
||||
const CvHistogram* hist );
|
||||
#define cvCalcBackProject(image, dst, hist) cvCalcArrBackProject((CvArr**)image, dst, hist)
|
||||
|
||||
|
||||
/* Does some sort of template matching but compares histograms of
|
||||
template and each window location */
|
||||
CVAPI(void) cvCalcArrBackProjectPatch( CvArr** image, CvArr* dst, CvSize range,
|
||||
CvHistogram* hist, int method,
|
||||
double factor );
|
||||
#define cvCalcBackProjectPatch( image, dst, range, hist, method, factor ) \
|
||||
cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor )
|
||||
|
||||
|
||||
/* calculates probabilistic density (divides one histogram by another) */
|
||||
CVAPI(void) cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2,
|
||||
CvHistogram* dst_hist, double scale CV_DEFAULT(255) );
|
||||
|
||||
/* equalizes histogram of 8-bit single-channel image */
|
||||
CVAPI(void) cvEqualizeHist( const CvArr* src, CvArr* dst );
|
||||
|
||||
|
||||
/* Applies distance transform to binary image */
|
||||
CVAPI(void) cvDistTransform( const CvArr* src, CvArr* dst,
|
||||
int distance_type CV_DEFAULT(CV_DIST_L2),
|
||||
int mask_size CV_DEFAULT(3),
|
||||
const float* mask CV_DEFAULT(NULL),
|
||||
CvArr* labels CV_DEFAULT(NULL),
|
||||
int labelType CV_DEFAULT(CV_DIST_LABEL_CCOMP));
|
||||
|
||||
|
||||
/* Applies fixed-level threshold to grayscale image.
|
||||
This is a basic operation applied before retrieving contours */
|
||||
CVAPI(double) cvThreshold( const CvArr* src, CvArr* dst,
|
||||
double threshold, double max_value,
|
||||
int threshold_type );
|
||||
|
||||
/* Applies adaptive threshold to grayscale image.
|
||||
The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and
|
||||
CV_ADAPTIVE_THRESH_GAUSSIAN_C are:
|
||||
neighborhood size (3, 5, 7 etc.),
|
||||
and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...) */
|
||||
CVAPI(void) cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
|
||||
int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C),
|
||||
int threshold_type CV_DEFAULT(CV_THRESH_BINARY),
|
||||
int block_size CV_DEFAULT(3),
|
||||
double param1 CV_DEFAULT(5));
|
||||
|
||||
/* Fills the connected component until the color difference gets large enough */
|
||||
CVAPI(void) cvFloodFill( CvArr* image, CvPoint seed_point,
|
||||
CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)),
|
||||
CvScalar up_diff CV_DEFAULT(cvScalarAll(0)),
|
||||
CvConnectedComp* comp CV_DEFAULT(NULL),
|
||||
int flags CV_DEFAULT(4),
|
||||
CvArr* mask CV_DEFAULT(NULL));
|
||||
|
||||
/****************************************************************************************\
|
||||
* Feature detection *
|
||||
\****************************************************************************************/
|
||||
|
||||
/* Runs canny edge detector */
|
||||
CVAPI(void) cvCanny( const CvArr* image, CvArr* edges, double threshold1,
|
||||
double threshold2, int aperture_size CV_DEFAULT(3) );
|
||||
|
||||
/* Calculates constraint image for corner detection
|
||||
Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy.
|
||||
Applying threshold to the result gives coordinates of corners */
|
||||
CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners,
|
||||
int aperture_size CV_DEFAULT(3) );
|
||||
|
||||
/* Calculates eigen values and vectors of 2x2
|
||||
gradient covariation matrix at every image pixel */
|
||||
CVAPI(void) cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv,
|
||||
int block_size, int aperture_size CV_DEFAULT(3) );
|
||||
|
||||
/* Calculates minimal eigenvalue for 2x2 gradient covariation matrix at
|
||||
every image pixel */
|
||||
CVAPI(void) cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval,
|
||||
int block_size, int aperture_size CV_DEFAULT(3) );
|
||||
|
||||
/* Harris corner detector:
|
||||
Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel */
|
||||
CVAPI(void) cvCornerHarris( const CvArr* image, CvArr* harris_response,
|
||||
int block_size, int aperture_size CV_DEFAULT(3),
|
||||
double k CV_DEFAULT(0.04) );
|
||||
|
||||
/* Adjust corner position using some sort of gradient search */
|
||||
CVAPI(void) cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners,
|
||||
int count, CvSize win, CvSize zero_zone,
|
||||
CvTermCriteria criteria );
|
||||
|
||||
/* Finds a sparse set of points within the selected region
|
||||
that seem to be easy to track */
|
||||
CVAPI(void) cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image,
|
||||
CvArr* temp_image, CvPoint2D32f* corners,
|
||||
int* corner_count, double quality_level,
|
||||
double min_distance,
|
||||
const CvArr* mask CV_DEFAULT(NULL),
|
||||
int block_size CV_DEFAULT(3),
|
||||
int use_harris CV_DEFAULT(0),
|
||||
double k CV_DEFAULT(0.04) );
|
||||
|
||||
/* Finds lines on binary image using one of several methods.
|
||||
line_storage is either memory storage or 1 x <max number of lines> CvMat, its
|
||||
number of columns is changed by the function.
|
||||
method is one of CV_HOUGH_*;
|
||||
rho, theta and threshold are used for each of those methods;
|
||||
param1 ~ line length, param2 ~ line gap - for probabilistic,
|
||||
param1 ~ srn, param2 ~ stn - for multi-scale */
|
||||
CVAPI(CvSeq*) cvHoughLines2( CvArr* image, void* line_storage, int method,
|
||||
double rho, double theta, int threshold,
|
||||
double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0));
|
||||
|
||||
/* Finds circles in the image */
|
||||
CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage,
|
||||
int method, double dp, double min_dist,
|
||||
double param1 CV_DEFAULT(100),
|
||||
double param2 CV_DEFAULT(100),
|
||||
int min_radius CV_DEFAULT(0),
|
||||
int max_radius CV_DEFAULT(0));
|
||||
|
||||
/* Fits a line into set of 2d or 3d points in a robust way (M-estimator technique) */
|
||||
CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param,
|
||||
double reps, double aeps, float* line );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,640 +0,0 @@
|
|||
/*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.
|
||||
// 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_IMGPROC_TYPES_C_H__
|
||||
#define __OPENCV_IMGPROC_TYPES_C_H__
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Connected component structure */
|
||||
typedef struct CvConnectedComp
|
||||
{
|
||||
double area; /* area of the connected component */
|
||||
CvScalar value; /* average color of the connected component */
|
||||
CvRect rect; /* ROI of the component */
|
||||
CvSeq* contour; /* optional component boundary
|
||||
(the contour might have child contours corresponding to the holes)*/
|
||||
}
|
||||
CvConnectedComp;
|
||||
|
||||
/* Image smooth methods */
|
||||
enum
|
||||
{
|
||||
CV_BLUR_NO_SCALE =0,
|
||||
CV_BLUR =1,
|
||||
CV_GAUSSIAN =2,
|
||||
CV_MEDIAN =3,
|
||||
CV_BILATERAL =4
|
||||
};
|
||||
|
||||
/* Filters used in pyramid decomposition */
|
||||
enum
|
||||
{
|
||||
CV_GAUSSIAN_5x5 = 7
|
||||
};
|
||||
|
||||
/* Special filters */
|
||||
enum
|
||||
{
|
||||
CV_SCHARR =-1,
|
||||
CV_MAX_SOBEL_KSIZE =7
|
||||
};
|
||||
|
||||
/* Constants for color conversion */
|
||||
enum
|
||||
{
|
||||
CV_BGR2BGRA =0,
|
||||
CV_RGB2RGBA =CV_BGR2BGRA,
|
||||
|
||||
CV_BGRA2BGR =1,
|
||||
CV_RGBA2RGB =CV_BGRA2BGR,
|
||||
|
||||
CV_BGR2RGBA =2,
|
||||
CV_RGB2BGRA =CV_BGR2RGBA,
|
||||
|
||||
CV_RGBA2BGR =3,
|
||||
CV_BGRA2RGB =CV_RGBA2BGR,
|
||||
|
||||
CV_BGR2RGB =4,
|
||||
CV_RGB2BGR =CV_BGR2RGB,
|
||||
|
||||
CV_BGRA2RGBA =5,
|
||||
CV_RGBA2BGRA =CV_BGRA2RGBA,
|
||||
|
||||
CV_BGR2GRAY =6,
|
||||
CV_RGB2GRAY =7,
|
||||
CV_GRAY2BGR =8,
|
||||
CV_GRAY2RGB =CV_GRAY2BGR,
|
||||
CV_GRAY2BGRA =9,
|
||||
CV_GRAY2RGBA =CV_GRAY2BGRA,
|
||||
CV_BGRA2GRAY =10,
|
||||
CV_RGBA2GRAY =11,
|
||||
|
||||
CV_BGR2BGR565 =12,
|
||||
CV_RGB2BGR565 =13,
|
||||
CV_BGR5652BGR =14,
|
||||
CV_BGR5652RGB =15,
|
||||
CV_BGRA2BGR565 =16,
|
||||
CV_RGBA2BGR565 =17,
|
||||
CV_BGR5652BGRA =18,
|
||||
CV_BGR5652RGBA =19,
|
||||
|
||||
CV_GRAY2BGR565 =20,
|
||||
CV_BGR5652GRAY =21,
|
||||
|
||||
CV_BGR2BGR555 =22,
|
||||
CV_RGB2BGR555 =23,
|
||||
CV_BGR5552BGR =24,
|
||||
CV_BGR5552RGB =25,
|
||||
CV_BGRA2BGR555 =26,
|
||||
CV_RGBA2BGR555 =27,
|
||||
CV_BGR5552BGRA =28,
|
||||
CV_BGR5552RGBA =29,
|
||||
|
||||
CV_GRAY2BGR555 =30,
|
||||
CV_BGR5552GRAY =31,
|
||||
|
||||
CV_BGR2XYZ =32,
|
||||
CV_RGB2XYZ =33,
|
||||
CV_XYZ2BGR =34,
|
||||
CV_XYZ2RGB =35,
|
||||
|
||||
CV_BGR2YCrCb =36,
|
||||
CV_RGB2YCrCb =37,
|
||||
CV_YCrCb2BGR =38,
|
||||
CV_YCrCb2RGB =39,
|
||||
|
||||
CV_BGR2HSV =40,
|
||||
CV_RGB2HSV =41,
|
||||
|
||||
CV_BGR2Lab =44,
|
||||
CV_RGB2Lab =45,
|
||||
|
||||
CV_BayerBG2BGR =46,
|
||||
CV_BayerGB2BGR =47,
|
||||
CV_BayerRG2BGR =48,
|
||||
CV_BayerGR2BGR =49,
|
||||
|
||||
CV_BayerBG2RGB =CV_BayerRG2BGR,
|
||||
CV_BayerGB2RGB =CV_BayerGR2BGR,
|
||||
CV_BayerRG2RGB =CV_BayerBG2BGR,
|
||||
CV_BayerGR2RGB =CV_BayerGB2BGR,
|
||||
|
||||
CV_BGR2Luv =50,
|
||||
CV_RGB2Luv =51,
|
||||
CV_BGR2HLS =52,
|
||||
CV_RGB2HLS =53,
|
||||
|
||||
CV_HSV2BGR =54,
|
||||
CV_HSV2RGB =55,
|
||||
|
||||
CV_Lab2BGR =56,
|
||||
CV_Lab2RGB =57,
|
||||
CV_Luv2BGR =58,
|
||||
CV_Luv2RGB =59,
|
||||
CV_HLS2BGR =60,
|
||||
CV_HLS2RGB =61,
|
||||
|
||||
CV_BayerBG2BGR_VNG =62,
|
||||
CV_BayerGB2BGR_VNG =63,
|
||||
CV_BayerRG2BGR_VNG =64,
|
||||
CV_BayerGR2BGR_VNG =65,
|
||||
|
||||
CV_BayerBG2RGB_VNG =CV_BayerRG2BGR_VNG,
|
||||
CV_BayerGB2RGB_VNG =CV_BayerGR2BGR_VNG,
|
||||
CV_BayerRG2RGB_VNG =CV_BayerBG2BGR_VNG,
|
||||
CV_BayerGR2RGB_VNG =CV_BayerGB2BGR_VNG,
|
||||
|
||||
CV_BGR2HSV_FULL = 66,
|
||||
CV_RGB2HSV_FULL = 67,
|
||||
CV_BGR2HLS_FULL = 68,
|
||||
CV_RGB2HLS_FULL = 69,
|
||||
|
||||
CV_HSV2BGR_FULL = 70,
|
||||
CV_HSV2RGB_FULL = 71,
|
||||
CV_HLS2BGR_FULL = 72,
|
||||
CV_HLS2RGB_FULL = 73,
|
||||
|
||||
CV_LBGR2Lab = 74,
|
||||
CV_LRGB2Lab = 75,
|
||||
CV_LBGR2Luv = 76,
|
||||
CV_LRGB2Luv = 77,
|
||||
|
||||
CV_Lab2LBGR = 78,
|
||||
CV_Lab2LRGB = 79,
|
||||
CV_Luv2LBGR = 80,
|
||||
CV_Luv2LRGB = 81,
|
||||
|
||||
CV_BGR2YUV = 82,
|
||||
CV_RGB2YUV = 83,
|
||||
CV_YUV2BGR = 84,
|
||||
CV_YUV2RGB = 85,
|
||||
|
||||
CV_BayerBG2GRAY = 86,
|
||||
CV_BayerGB2GRAY = 87,
|
||||
CV_BayerRG2GRAY = 88,
|
||||
CV_BayerGR2GRAY = 89,
|
||||
|
||||
//YUV 4:2:0 formats family
|
||||
CV_YUV2RGB_NV12 = 90,
|
||||
CV_YUV2BGR_NV12 = 91,
|
||||
CV_YUV2RGB_NV21 = 92,
|
||||
CV_YUV2BGR_NV21 = 93,
|
||||
CV_YUV420sp2RGB = CV_YUV2RGB_NV21,
|
||||
CV_YUV420sp2BGR = CV_YUV2BGR_NV21,
|
||||
|
||||
CV_YUV2RGBA_NV12 = 94,
|
||||
CV_YUV2BGRA_NV12 = 95,
|
||||
CV_YUV2RGBA_NV21 = 96,
|
||||
CV_YUV2BGRA_NV21 = 97,
|
||||
CV_YUV420sp2RGBA = CV_YUV2RGBA_NV21,
|
||||
CV_YUV420sp2BGRA = CV_YUV2BGRA_NV21,
|
||||
|
||||
CV_YUV2RGB_YV12 = 98,
|
||||
CV_YUV2BGR_YV12 = 99,
|
||||
CV_YUV2RGB_IYUV = 100,
|
||||
CV_YUV2BGR_IYUV = 101,
|
||||
CV_YUV2RGB_I420 = CV_YUV2RGB_IYUV,
|
||||
CV_YUV2BGR_I420 = CV_YUV2BGR_IYUV,
|
||||
CV_YUV420p2RGB = CV_YUV2RGB_YV12,
|
||||
CV_YUV420p2BGR = CV_YUV2BGR_YV12,
|
||||
|
||||
CV_YUV2RGBA_YV12 = 102,
|
||||
CV_YUV2BGRA_YV12 = 103,
|
||||
CV_YUV2RGBA_IYUV = 104,
|
||||
CV_YUV2BGRA_IYUV = 105,
|
||||
CV_YUV2RGBA_I420 = CV_YUV2RGBA_IYUV,
|
||||
CV_YUV2BGRA_I420 = CV_YUV2BGRA_IYUV,
|
||||
CV_YUV420p2RGBA = CV_YUV2RGBA_YV12,
|
||||
CV_YUV420p2BGRA = CV_YUV2BGRA_YV12,
|
||||
|
||||
CV_YUV2GRAY_420 = 106,
|
||||
CV_YUV2GRAY_NV21 = CV_YUV2GRAY_420,
|
||||
CV_YUV2GRAY_NV12 = CV_YUV2GRAY_420,
|
||||
CV_YUV2GRAY_YV12 = CV_YUV2GRAY_420,
|
||||
CV_YUV2GRAY_IYUV = CV_YUV2GRAY_420,
|
||||
CV_YUV2GRAY_I420 = CV_YUV2GRAY_420,
|
||||
CV_YUV420sp2GRAY = CV_YUV2GRAY_420,
|
||||
CV_YUV420p2GRAY = CV_YUV2GRAY_420,
|
||||
|
||||
//YUV 4:2:2 formats family
|
||||
CV_YUV2RGB_UYVY = 107,
|
||||
CV_YUV2BGR_UYVY = 108,
|
||||
//CV_YUV2RGB_VYUY = 109,
|
||||
//CV_YUV2BGR_VYUY = 110,
|
||||
CV_YUV2RGB_Y422 = CV_YUV2RGB_UYVY,
|
||||
CV_YUV2BGR_Y422 = CV_YUV2BGR_UYVY,
|
||||
CV_YUV2RGB_UYNV = CV_YUV2RGB_UYVY,
|
||||
CV_YUV2BGR_UYNV = CV_YUV2BGR_UYVY,
|
||||
|
||||
CV_YUV2RGBA_UYVY = 111,
|
||||
CV_YUV2BGRA_UYVY = 112,
|
||||
//CV_YUV2RGBA_VYUY = 113,
|
||||
//CV_YUV2BGRA_VYUY = 114,
|
||||
CV_YUV2RGBA_Y422 = CV_YUV2RGBA_UYVY,
|
||||
CV_YUV2BGRA_Y422 = CV_YUV2BGRA_UYVY,
|
||||
CV_YUV2RGBA_UYNV = CV_YUV2RGBA_UYVY,
|
||||
CV_YUV2BGRA_UYNV = CV_YUV2BGRA_UYVY,
|
||||
|
||||
CV_YUV2RGB_YUY2 = 115,
|
||||
CV_YUV2BGR_YUY2 = 116,
|
||||
CV_YUV2RGB_YVYU = 117,
|
||||
CV_YUV2BGR_YVYU = 118,
|
||||
CV_YUV2RGB_YUYV = CV_YUV2RGB_YUY2,
|
||||
CV_YUV2BGR_YUYV = CV_YUV2BGR_YUY2,
|
||||
CV_YUV2RGB_YUNV = CV_YUV2RGB_YUY2,
|
||||
CV_YUV2BGR_YUNV = CV_YUV2BGR_YUY2,
|
||||
|
||||
CV_YUV2RGBA_YUY2 = 119,
|
||||
CV_YUV2BGRA_YUY2 = 120,
|
||||
CV_YUV2RGBA_YVYU = 121,
|
||||
CV_YUV2BGRA_YVYU = 122,
|
||||
CV_YUV2RGBA_YUYV = CV_YUV2RGBA_YUY2,
|
||||
CV_YUV2BGRA_YUYV = CV_YUV2BGRA_YUY2,
|
||||
CV_YUV2RGBA_YUNV = CV_YUV2RGBA_YUY2,
|
||||
CV_YUV2BGRA_YUNV = CV_YUV2BGRA_YUY2,
|
||||
|
||||
CV_YUV2GRAY_UYVY = 123,
|
||||
CV_YUV2GRAY_YUY2 = 124,
|
||||
//CV_YUV2GRAY_VYUY = CV_YUV2GRAY_UYVY,
|
||||
CV_YUV2GRAY_Y422 = CV_YUV2GRAY_UYVY,
|
||||
CV_YUV2GRAY_UYNV = CV_YUV2GRAY_UYVY,
|
||||
CV_YUV2GRAY_YVYU = CV_YUV2GRAY_YUY2,
|
||||
CV_YUV2GRAY_YUYV = CV_YUV2GRAY_YUY2,
|
||||
CV_YUV2GRAY_YUNV = CV_YUV2GRAY_YUY2,
|
||||
|
||||
// alpha premultiplication
|
||||
CV_RGBA2mRGBA = 125,
|
||||
CV_mRGBA2RGBA = 126,
|
||||
|
||||
CV_RGB2YUV_I420 = 127,
|
||||
CV_BGR2YUV_I420 = 128,
|
||||
CV_RGB2YUV_IYUV = CV_RGB2YUV_I420,
|
||||
CV_BGR2YUV_IYUV = CV_BGR2YUV_I420,
|
||||
|
||||
CV_RGBA2YUV_I420 = 129,
|
||||
CV_BGRA2YUV_I420 = 130,
|
||||
CV_RGBA2YUV_IYUV = CV_RGBA2YUV_I420,
|
||||
CV_BGRA2YUV_IYUV = CV_BGRA2YUV_I420,
|
||||
CV_RGB2YUV_YV12 = 131,
|
||||
CV_BGR2YUV_YV12 = 132,
|
||||
CV_RGBA2YUV_YV12 = 133,
|
||||
CV_BGRA2YUV_YV12 = 134,
|
||||
|
||||
CV_COLORCVT_MAX = 135
|
||||
};
|
||||
|
||||
|
||||
/* Sub-pixel interpolation methods */
|
||||
enum
|
||||
{
|
||||
CV_INTER_NN =0,
|
||||
CV_INTER_LINEAR =1,
|
||||
CV_INTER_CUBIC =2,
|
||||
CV_INTER_AREA =3,
|
||||
CV_INTER_LANCZOS4 =4
|
||||
};
|
||||
|
||||
/* ... and other image warping flags */
|
||||
enum
|
||||
{
|
||||
CV_WARP_FILL_OUTLIERS =8,
|
||||
CV_WARP_INVERSE_MAP =16
|
||||
};
|
||||
|
||||
/* Shapes of a structuring element for morphological operations */
|
||||
enum
|
||||
{
|
||||
CV_SHAPE_RECT =0,
|
||||
CV_SHAPE_CROSS =1,
|
||||
CV_SHAPE_ELLIPSE =2,
|
||||
CV_SHAPE_CUSTOM =100
|
||||
};
|
||||
|
||||
/* Morphological operations */
|
||||
enum
|
||||
{
|
||||
CV_MOP_ERODE =0,
|
||||
CV_MOP_DILATE =1,
|
||||
CV_MOP_OPEN =2,
|
||||
CV_MOP_CLOSE =3,
|
||||
CV_MOP_GRADIENT =4,
|
||||
CV_MOP_TOPHAT =5,
|
||||
CV_MOP_BLACKHAT =6
|
||||
};
|
||||
|
||||
/* Spatial and central moments */
|
||||
typedef struct CvMoments
|
||||
{
|
||||
double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03; /* spatial moments */
|
||||
double mu20, mu11, mu02, mu30, mu21, mu12, mu03; /* central moments */
|
||||
double inv_sqrt_m00; /* m00 != 0 ? 1/sqrt(m00) : 0 */
|
||||
}
|
||||
CvMoments;
|
||||
|
||||
/* Hu invariants */
|
||||
typedef struct CvHuMoments
|
||||
{
|
||||
double hu1, hu2, hu3, hu4, hu5, hu6, hu7; /* Hu invariants */
|
||||
}
|
||||
CvHuMoments;
|
||||
|
||||
/* Template matching methods */
|
||||
enum
|
||||
{
|
||||
CV_TM_SQDIFF =0,
|
||||
CV_TM_SQDIFF_NORMED =1,
|
||||
CV_TM_CCORR =2,
|
||||
CV_TM_CCORR_NORMED =3,
|
||||
CV_TM_CCOEFF =4,
|
||||
CV_TM_CCOEFF_NORMED =5
|
||||
};
|
||||
|
||||
typedef float (CV_CDECL * CvDistanceFunction)( const float* a, const float* b, void* user_param );
|
||||
|
||||
/* Contour retrieval modes */
|
||||
enum
|
||||
{
|
||||
CV_RETR_EXTERNAL=0,
|
||||
CV_RETR_LIST=1,
|
||||
CV_RETR_CCOMP=2,
|
||||
CV_RETR_TREE=3,
|
||||
CV_RETR_FLOODFILL=4
|
||||
};
|
||||
|
||||
/* Contour approximation methods */
|
||||
enum
|
||||
{
|
||||
CV_CHAIN_CODE=0,
|
||||
CV_CHAIN_APPROX_NONE=1,
|
||||
CV_CHAIN_APPROX_SIMPLE=2,
|
||||
CV_CHAIN_APPROX_TC89_L1=3,
|
||||
CV_CHAIN_APPROX_TC89_KCOS=4,
|
||||
CV_LINK_RUNS=5
|
||||
};
|
||||
|
||||
/*
|
||||
Internal structure that is used for sequental retrieving contours from the image.
|
||||
It supports both hierarchical and plane variants of Suzuki algorithm.
|
||||
*/
|
||||
typedef struct _CvContourScanner* CvContourScanner;
|
||||
|
||||
/* Freeman chain reader state */
|
||||
typedef struct CvChainPtReader
|
||||
{
|
||||
CV_SEQ_READER_FIELDS()
|
||||
char code;
|
||||
CvPoint pt;
|
||||
schar deltas[8][2];
|
||||
}
|
||||
CvChainPtReader;
|
||||
|
||||
/* initializes 8-element array for fast access to 3x3 neighborhood of a pixel */
|
||||
#define CV_INIT_3X3_DELTAS( deltas, step, nch ) \
|
||||
((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \
|
||||
(deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \
|
||||
(deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \
|
||||
(deltas)[6] = (step), (deltas)[7] = (step) + (nch))
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
* Planar subdivisions *
|
||||
\****************************************************************************************/
|
||||
|
||||
typedef size_t CvSubdiv2DEdge;
|
||||
|
||||
#define CV_QUADEDGE2D_FIELDS() \
|
||||
int flags; \
|
||||
struct CvSubdiv2DPoint* pt[4]; \
|
||||
CvSubdiv2DEdge next[4];
|
||||
|
||||
#define CV_SUBDIV2D_POINT_FIELDS()\
|
||||
int flags; \
|
||||
CvSubdiv2DEdge first; \
|
||||
CvPoint2D32f pt; \
|
||||
int id;
|
||||
|
||||
#define CV_SUBDIV2D_VIRTUAL_POINT_FLAG (1 << 30)
|
||||
|
||||
typedef struct CvQuadEdge2D
|
||||
{
|
||||
CV_QUADEDGE2D_FIELDS()
|
||||
}
|
||||
CvQuadEdge2D;
|
||||
|
||||
typedef struct CvSubdiv2DPoint
|
||||
{
|
||||
CV_SUBDIV2D_POINT_FIELDS()
|
||||
}
|
||||
CvSubdiv2DPoint;
|
||||
|
||||
#define CV_SUBDIV2D_FIELDS() \
|
||||
CV_GRAPH_FIELDS() \
|
||||
int quad_edges; \
|
||||
int is_geometry_valid; \
|
||||
CvSubdiv2DEdge recent_edge; \
|
||||
CvPoint2D32f topleft; \
|
||||
CvPoint2D32f bottomright;
|
||||
|
||||
typedef struct CvSubdiv2D
|
||||
{
|
||||
CV_SUBDIV2D_FIELDS()
|
||||
}
|
||||
CvSubdiv2D;
|
||||
|
||||
|
||||
typedef enum CvSubdiv2DPointLocation
|
||||
{
|
||||
CV_PTLOC_ERROR = -2,
|
||||
CV_PTLOC_OUTSIDE_RECT = -1,
|
||||
CV_PTLOC_INSIDE = 0,
|
||||
CV_PTLOC_VERTEX = 1,
|
||||
CV_PTLOC_ON_EDGE = 2
|
||||
}
|
||||
CvSubdiv2DPointLocation;
|
||||
|
||||
typedef enum CvNextEdgeType
|
||||
{
|
||||
CV_NEXT_AROUND_ORG = 0x00,
|
||||
CV_NEXT_AROUND_DST = 0x22,
|
||||
CV_PREV_AROUND_ORG = 0x11,
|
||||
CV_PREV_AROUND_DST = 0x33,
|
||||
CV_NEXT_AROUND_LEFT = 0x13,
|
||||
CV_NEXT_AROUND_RIGHT = 0x31,
|
||||
CV_PREV_AROUND_LEFT = 0x20,
|
||||
CV_PREV_AROUND_RIGHT = 0x02
|
||||
}
|
||||
CvNextEdgeType;
|
||||
|
||||
/* get the next edge with the same origin point (counterwise) */
|
||||
#define CV_SUBDIV2D_NEXT_EDGE( edge ) (((CvQuadEdge2D*)((edge) & ~3))->next[(edge)&3])
|
||||
|
||||
|
||||
/* Contour approximation algorithms */
|
||||
enum
|
||||
{
|
||||
CV_POLY_APPROX_DP = 0
|
||||
};
|
||||
|
||||
/* Shape matching methods */
|
||||
enum
|
||||
{
|
||||
CV_CONTOURS_MATCH_I1 =1,
|
||||
CV_CONTOURS_MATCH_I2 =2,
|
||||
CV_CONTOURS_MATCH_I3 =3
|
||||
};
|
||||
|
||||
/* Shape orientation */
|
||||
enum
|
||||
{
|
||||
CV_CLOCKWISE =1,
|
||||
CV_COUNTER_CLOCKWISE =2
|
||||
};
|
||||
|
||||
|
||||
/* Convexity defect */
|
||||
typedef struct CvConvexityDefect
|
||||
{
|
||||
CvPoint* start; /* point of the contour where the defect begins */
|
||||
CvPoint* end; /* point of the contour where the defect ends */
|
||||
CvPoint* depth_point; /* the farthest from the convex hull point within the defect */
|
||||
float depth; /* distance between the farthest point and the convex hull */
|
||||
} CvConvexityDefect;
|
||||
|
||||
|
||||
/* Histogram comparison methods */
|
||||
enum
|
||||
{
|
||||
CV_COMP_CORREL =0,
|
||||
CV_COMP_CHISQR =1,
|
||||
CV_COMP_INTERSECT =2,
|
||||
CV_COMP_BHATTACHARYYA =3,
|
||||
CV_COMP_HELLINGER =CV_COMP_BHATTACHARYYA
|
||||
};
|
||||
|
||||
/* Mask size for distance transform */
|
||||
enum
|
||||
{
|
||||
CV_DIST_MASK_3 =3,
|
||||
CV_DIST_MASK_5 =5,
|
||||
CV_DIST_MASK_PRECISE =0
|
||||
};
|
||||
|
||||
/* Content of output label array: connected components or pixels */
|
||||
enum
|
||||
{
|
||||
CV_DIST_LABEL_CCOMP = 0,
|
||||
CV_DIST_LABEL_PIXEL = 1
|
||||
};
|
||||
|
||||
/* Distance types for Distance Transform and M-estimators */
|
||||
enum
|
||||
{
|
||||
CV_DIST_USER =-1, /* User defined distance */
|
||||
CV_DIST_L1 =1, /* distance = |x1-x2| + |y1-y2| */
|
||||
CV_DIST_L2 =2, /* the simple euclidean distance */
|
||||
CV_DIST_C =3, /* distance = max(|x1-x2|,|y1-y2|) */
|
||||
CV_DIST_L12 =4, /* L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1)) */
|
||||
CV_DIST_FAIR =5, /* distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998 */
|
||||
CV_DIST_WELSCH =6, /* distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846 */
|
||||
CV_DIST_HUBER =7 /* distance = |x|<c ? x^2/2 : c(|x|-c/2), c=1.345 */
|
||||
};
|
||||
|
||||
|
||||
/* Threshold types */
|
||||
enum
|
||||
{
|
||||
CV_THRESH_BINARY =0, /* value = value > threshold ? max_value : 0 */
|
||||
CV_THRESH_BINARY_INV =1, /* value = value > threshold ? 0 : max_value */
|
||||
CV_THRESH_TRUNC =2, /* value = value > threshold ? threshold : value */
|
||||
CV_THRESH_TOZERO =3, /* value = value > threshold ? value : 0 */
|
||||
CV_THRESH_TOZERO_INV =4, /* value = value > threshold ? 0 : value */
|
||||
CV_THRESH_MASK =7,
|
||||
CV_THRESH_OTSU =8 /* use Otsu algorithm to choose the optimal threshold value;
|
||||
combine the flag with one of the above CV_THRESH_* values */
|
||||
};
|
||||
|
||||
/* Adaptive threshold methods */
|
||||
enum
|
||||
{
|
||||
CV_ADAPTIVE_THRESH_MEAN_C =0,
|
||||
CV_ADAPTIVE_THRESH_GAUSSIAN_C =1
|
||||
};
|
||||
|
||||
/* FloodFill flags */
|
||||
enum
|
||||
{
|
||||
CV_FLOODFILL_FIXED_RANGE =(1 << 16),
|
||||
CV_FLOODFILL_MASK_ONLY =(1 << 17)
|
||||
};
|
||||
|
||||
|
||||
/* Canny edge detector flags */
|
||||
enum
|
||||
{
|
||||
CV_CANNY_L2_GRADIENT =(1 << 31)
|
||||
};
|
||||
|
||||
/* Variants of a Hough transform */
|
||||
enum
|
||||
{
|
||||
CV_HOUGH_STANDARD =0,
|
||||
CV_HOUGH_PROBABILISTIC =1,
|
||||
CV_HOUGH_MULTI_SCALE =2,
|
||||
CV_HOUGH_GRADIENT =3
|
||||
};
|
||||
|
||||
|
||||
/* Fast search data structures */
|
||||
struct CvFeatureTree;
|
||||
struct CvLSH;
|
||||
struct CvLSHOperations;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -24,8 +24,8 @@ else:
|
|||
env.Append(CFLAGS = '-DWEBCAM')
|
||||
env.Append(CPPPATH = '/usr/local/include/opencv4')
|
||||
else:
|
||||
libs += []
|
||||
cameras = ['cameras/camera_frame_stream.cc']
|
||||
|
||||
if arch == "Darwin":
|
||||
del libs[libs.index('OpenCL')]
|
||||
env = env.Clone()
|
||||
|
|
Loading…
Reference in New Issue