Move C++ basic structures to separate header and inverse dependency from C API

cv::Complex, cv::Point_ and cv::Point3_ are moved.
pull/747/head
Andrey Kamaev 12 years ago
parent 19f8f85c51
commit 13b31b0804
  1. 6
      modules/calib3d/src/calibinit.cpp
  2. 127
      modules/core/include/opencv2/core.hpp
  3. 91
      modules/core/include/opencv2/core/operations.hpp
  4. 251
      modules/core/include/opencv2/core/types.hpp
  5. 28
      modules/core/include/opencv2/core/types_c.h
  6. 4
      modules/imgproc/src/contours.cpp
  7. 2
      modules/legacy/src/3dtracker.cpp
  8. 4
      modules/legacy/src/_vectrack.h
  9. 2
      modules/legacy/src/calibfilter.cpp
  10. 2
      modules/legacy/src/epilines.cpp
  11. 4
      modules/legacy/src/lcm.cpp
  12. 4
      modules/legacy/src/morphcontours.cpp
  13. 6
      modules/legacy/src/segment.cpp
  14. 20
      modules/legacy/src/vecfacetracking.cpp
  15. 4
      modules/legacy/test/test_pyrsegmentation.cpp
  16. 2
      modules/ml/test/test_mltests2.cpp
  17. 4
      modules/objdetect/src/datamatrix.cpp
  18. 2
      samples/c/find_obj.cpp
  19. 2
      samples/cpp/letter_recog.cpp

@ -1095,7 +1095,7 @@ icvOrderQuad(CvCBQuad *quad, CvCBCorner *corner, int common)
static int static int
icvCleanFoundConnectedQuads( int quad_count, CvCBQuad **quad_group, CvSize pattern_size ) icvCleanFoundConnectedQuads( int quad_count, CvCBQuad **quad_group, CvSize pattern_size )
{ {
CvPoint2D32f center = {0,0}; CvPoint2D32f center;
int i, j, k; int i, j, k;
// number of quads this pattern should contain // number of quads this pattern should contain
int count = ((pattern_size.width + 1)*(pattern_size.height + 1) + 1)/2; int count = ((pattern_size.width + 1)*(pattern_size.height + 1) + 1)/2;
@ -1111,7 +1111,7 @@ icvCleanFoundConnectedQuads( int quad_count, CvCBQuad **quad_group, CvSize patte
for( i = 0; i < quad_count; i++ ) for( i = 0; i < quad_count; i++ )
{ {
CvPoint2D32f ci = {0,0}; CvPoint2D32f ci;
CvCBQuad* q = quad_group[i]; CvCBQuad* q = quad_group[i];
for( j = 0; j < 4; j++ ) for( j = 0; j < 4; j++ )
@ -1856,7 +1856,7 @@ cvDrawChessboardCorners( CvArr* _image, CvSize pattern_size,
else else
{ {
int x, y; int x, y;
CvPoint prev_pt = {0, 0}; CvPoint prev_pt;
const int line_max = 7; const int line_max = 7;
static const CvScalar line_colors[line_max] = static const CvScalar line_colors[line_max] =
{ {

@ -53,6 +53,7 @@
#ifdef __cplusplus #ifdef __cplusplus
#include "opencv2/core/cvstd.hpp" #include "opencv2/core/cvstd.hpp"
#include "opencv2/core/types.hpp"
#ifndef SKIP_INCLUDES #ifndef SKIP_INCLUDES
#include <limits.h> #include <limits.h>
@ -523,125 +524,6 @@ typedef Vec<double, 4> Vec4d;
typedef Vec<double, 6> Vec6d; typedef Vec<double, 6> Vec6d;
//////////////////////////////// Complex //////////////////////////////
/*!
A complex number class.
The template class is similar and compatible with std::complex, however it provides slightly
more convenient access to the real and imaginary parts using through the simple field access, as opposite
to std::complex::real() and std::complex::imag().
*/
template<typename _Tp> class CV_EXPORTS Complex
{
public:
//! constructors
Complex();
Complex( _Tp _re, _Tp _im=0 );
Complex( const std::complex<_Tp>& c );
//! conversion to another data type
template<typename T2> operator Complex<T2>() const;
//! conjugation
Complex conj() const;
//! conversion to std::complex
operator std::complex<_Tp>() const;
_Tp re, im; //< the real and the imaginary parts
};
/*!
\typedef
*/
typedef Complex<float> Complexf;
typedef Complex<double> Complexd;
//////////////////////////////// Point_ ////////////////////////////////
/*!
template 2D point class.
The class defines a point in 2D space. Data type of the point coordinates is specified
as a template parameter. There are a few shorter aliases available for user convenience.
See cv::Point, cv::Point2i, cv::Point2f and cv::Point2d.
*/
template<typename _Tp> class CV_EXPORTS Point_
{
public:
typedef _Tp value_type;
// various constructors
Point_();
Point_(_Tp _x, _Tp _y);
Point_(const Point_& pt);
Point_(const CvPoint& pt);
Point_(const CvPoint2D32f& pt);
Point_(const Size_<_Tp>& sz);
Point_(const Vec<_Tp, 2>& v);
Point_& operator = (const Point_& pt);
//! conversion to another data type
template<typename _Tp2> operator Point_<_Tp2>() const;
//! conversion to the old-style C structures
operator CvPoint() const;
operator CvPoint2D32f() const;
operator Vec<_Tp, 2>() const;
//! dot product
_Tp dot(const Point_& pt) const;
//! dot product computed in double-precision arithmetics
double ddot(const Point_& pt) const;
//! cross-product
double cross(const Point_& pt) const;
//! checks whether the point is inside the specified rectangle
bool inside(const Rect_<_Tp>& r) const;
_Tp x, y; //< the point coordinates
};
/*!
template 3D point class.
The class defines a point in 3D space. Data type of the point coordinates is specified
as a template parameter.
\see cv::Point3i, cv::Point3f and cv::Point3d
*/
template<typename _Tp> class CV_EXPORTS Point3_
{
public:
typedef _Tp value_type;
// various constructors
Point3_();
Point3_(_Tp _x, _Tp _y, _Tp _z);
Point3_(const Point3_& pt);
explicit Point3_(const Point_<_Tp>& pt);
Point3_(const CvPoint3D32f& pt);
Point3_(const Vec<_Tp, 3>& v);
Point3_& operator = (const Point3_& pt);
//! conversion to another data type
template<typename _Tp2> operator Point3_<_Tp2>() const;
//! conversion to the old-style CvPoint...
operator CvPoint3D32f() const;
//! conversion to cv::Vec<>
operator Vec<_Tp, 3>() const;
//! dot product
_Tp dot(const Point3_& pt) const;
//! dot product computed in double-precision arithmetics
double ddot(const Point3_& pt) const;
//! cross product of the 2 3D points
Point3_ cross(const Point3_& pt) const;
_Tp x, y, z; //< the point coordinates
};
//////////////////////////////// Size_ //////////////////////////////// //////////////////////////////// Size_ ////////////////////////////////
/*! /*!
@ -726,17 +608,10 @@ public:
shorter aliases for the most popular cv::Point_<>, cv::Size_<> and cv::Rect_<> specializations shorter aliases for the most popular cv::Point_<>, cv::Size_<> and cv::Rect_<> specializations
*/ */
typedef Point_<int> Point2i;
typedef Point2i Point;
typedef Size_<int> Size2i; typedef Size_<int> Size2i;
typedef Size2i Size; typedef Size2i Size;
typedef Rect_<int> Rect; typedef Rect_<int> Rect;
typedef Point_<float> Point2f;
typedef Point_<double> Point2d;
typedef Size_<float> Size2f; typedef Size_<float> Size2f;
typedef Point3_<int> Point3i;
typedef Point3_<float> Point3f;
typedef Point3_<double> Point3d;
/*! /*!

@ -98,85 +98,6 @@
namespace cv namespace cv
{ {
/////////////// saturate_cast (used in image & signal processing) ///////////////////
template<typename _Tp> static inline _Tp saturate_cast(uchar v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(schar v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(ushort v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(short v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(unsigned v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(int v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(float v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(double v) { return _Tp(v); }
template<> inline uchar saturate_cast<uchar>(schar v)
{ return (uchar)std::max((int)v, 0); }
template<> inline uchar saturate_cast<uchar>(ushort v)
{ return (uchar)std::min((unsigned)v, (unsigned)UCHAR_MAX); }
template<> inline uchar saturate_cast<uchar>(int v)
{ return (uchar)((unsigned)v <= UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0); }
template<> inline uchar saturate_cast<uchar>(short v)
{ return saturate_cast<uchar>((int)v); }
template<> inline uchar saturate_cast<uchar>(unsigned v)
{ return (uchar)std::min(v, (unsigned)UCHAR_MAX); }
template<> inline uchar saturate_cast<uchar>(float v)
{ int iv = cvRound(v); return saturate_cast<uchar>(iv); }
template<> inline uchar saturate_cast<uchar>(double v)
{ int iv = cvRound(v); return saturate_cast<uchar>(iv); }
template<> inline schar saturate_cast<schar>(uchar v)
{ return (schar)std::min((int)v, SCHAR_MAX); }
template<> inline schar saturate_cast<schar>(ushort v)
{ return (schar)std::min((unsigned)v, (unsigned)SCHAR_MAX); }
template<> inline schar saturate_cast<schar>(int v)
{
return (schar)((unsigned)(v-SCHAR_MIN) <= (unsigned)UCHAR_MAX ?
v : v > 0 ? SCHAR_MAX : SCHAR_MIN);
}
template<> inline schar saturate_cast<schar>(short v)
{ return saturate_cast<schar>((int)v); }
template<> inline schar saturate_cast<schar>(unsigned v)
{ return (schar)std::min(v, (unsigned)SCHAR_MAX); }
template<> inline schar saturate_cast<schar>(float v)
{ int iv = cvRound(v); return saturate_cast<schar>(iv); }
template<> inline schar saturate_cast<schar>(double v)
{ int iv = cvRound(v); return saturate_cast<schar>(iv); }
template<> inline ushort saturate_cast<ushort>(schar v)
{ return (ushort)std::max((int)v, 0); }
template<> inline ushort saturate_cast<ushort>(short v)
{ return (ushort)std::max((int)v, 0); }
template<> inline ushort saturate_cast<ushort>(int v)
{ return (ushort)((unsigned)v <= (unsigned)USHRT_MAX ? v : v > 0 ? USHRT_MAX : 0); }
template<> inline ushort saturate_cast<ushort>(unsigned v)
{ return (ushort)std::min(v, (unsigned)USHRT_MAX); }
template<> inline ushort saturate_cast<ushort>(float v)
{ int iv = cvRound(v); return saturate_cast<ushort>(iv); }
template<> inline ushort saturate_cast<ushort>(double v)
{ int iv = cvRound(v); return saturate_cast<ushort>(iv); }
template<> inline short saturate_cast<short>(ushort v)
{ return (short)std::min((int)v, SHRT_MAX); }
template<> inline short saturate_cast<short>(int v)
{
return (short)((unsigned)(v - SHRT_MIN) <= (unsigned)USHRT_MAX ?
v : v > 0 ? SHRT_MAX : SHRT_MIN);
}
template<> inline short saturate_cast<short>(unsigned v)
{ return (short)std::min(v, (unsigned)SHRT_MAX); }
template<> inline short saturate_cast<short>(float v)
{ int iv = cvRound(v); return saturate_cast<short>(iv); }
template<> inline short saturate_cast<short>(double v)
{ int iv = cvRound(v); return saturate_cast<short>(iv); }
template<> inline int saturate_cast<int>(float v) { return cvRound(v); }
template<> inline int saturate_cast<int>(double v) { return cvRound(v); }
// we intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.
template<> inline unsigned saturate_cast<unsigned>(float v){ return cvRound(v); }
template<> inline unsigned saturate_cast<unsigned>(double v) { return cvRound(v); }
inline int fast_abs(uchar v) { return v; } inline int fast_abs(uchar v) { return v; }
inline int fast_abs(schar v) { return std::abs((int)v); } inline int fast_abs(schar v) { return std::abs((int)v); }
inline int fast_abs(ushort v) { return v; } inline int fast_abs(ushort v) { return v; }
@ -1605,9 +1526,6 @@ Complex<_Tp> operator /= (const Complex<_Tp>& a, _Tp b)
template<typename _Tp> inline Point_<_Tp>::Point_() : x(0), y(0) {} template<typename _Tp> inline Point_<_Tp>::Point_() : x(0), y(0) {}
template<typename _Tp> inline Point_<_Tp>::Point_(_Tp _x, _Tp _y) : x(_x), y(_y) {} template<typename _Tp> inline Point_<_Tp>::Point_(_Tp _x, _Tp _y) : x(_x), y(_y) {}
template<typename _Tp> inline Point_<_Tp>::Point_(const Point_& pt) : x(pt.x), y(pt.y) {} template<typename _Tp> inline Point_<_Tp>::Point_(const Point_& pt) : x(pt.x), y(pt.y) {}
template<typename _Tp> inline Point_<_Tp>::Point_(const CvPoint& pt) : x((_Tp)pt.x), y((_Tp)pt.y) {}
template<typename _Tp> inline Point_<_Tp>::Point_(const CvPoint2D32f& pt)
: x(saturate_cast<_Tp>(pt.x)), y(saturate_cast<_Tp>(pt.y)) {}
template<typename _Tp> inline Point_<_Tp>::Point_(const Size_<_Tp>& sz) : x(sz.width), y(sz.height) {} template<typename _Tp> inline Point_<_Tp>::Point_(const Size_<_Tp>& sz) : x(sz.width), y(sz.height) {}
template<typename _Tp> inline Point_<_Tp>::Point_(const Vec<_Tp,2>& v) : x(v[0]), y(v[1]) {} template<typename _Tp> inline Point_<_Tp>::Point_(const Vec<_Tp,2>& v) : x(v[0]), y(v[1]) {}
template<typename _Tp> inline Point_<_Tp>& Point_<_Tp>::operator = (const Point_& pt) template<typename _Tp> inline Point_<_Tp>& Point_<_Tp>::operator = (const Point_& pt)
@ -1615,10 +1533,6 @@ template<typename _Tp> inline Point_<_Tp>& Point_<_Tp>::operator = (const Point_
template<typename _Tp> template<typename _Tp2> inline Point_<_Tp>::operator Point_<_Tp2>() const template<typename _Tp> template<typename _Tp2> inline Point_<_Tp>::operator Point_<_Tp2>() const
{ return Point_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y)); } { return Point_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y)); }
template<typename _Tp> inline Point_<_Tp>::operator CvPoint() const
{ return cvPoint(saturate_cast<int>(x), saturate_cast<int>(y)); }
template<typename _Tp> inline Point_<_Tp>::operator CvPoint2D32f() const
{ return cvPoint2D32f((float)x, (float)y); }
template<typename _Tp> inline Point_<_Tp>::operator Vec<_Tp, 2>() const template<typename _Tp> inline Point_<_Tp>::operator Vec<_Tp, 2>() const
{ return Vec<_Tp, 2>(x, y); } { return Vec<_Tp, 2>(x, y); }
@ -1712,16 +1626,11 @@ template<typename _Tp> inline Point3_<_Tp>::Point3_() : x(0), y(0), z(0) {}
template<typename _Tp> inline Point3_<_Tp>::Point3_(_Tp _x, _Tp _y, _Tp _z) : x(_x), y(_y), z(_z) {} template<typename _Tp> inline Point3_<_Tp>::Point3_(_Tp _x, _Tp _y, _Tp _z) : x(_x), y(_y), z(_z) {}
template<typename _Tp> inline Point3_<_Tp>::Point3_(const Point3_& pt) : x(pt.x), y(pt.y), z(pt.z) {} template<typename _Tp> inline Point3_<_Tp>::Point3_(const Point3_& pt) : x(pt.x), y(pt.y), z(pt.z) {}
template<typename _Tp> inline Point3_<_Tp>::Point3_(const Point_<_Tp>& pt) : x(pt.x), y(pt.y), z(_Tp()) {} template<typename _Tp> inline Point3_<_Tp>::Point3_(const Point_<_Tp>& pt) : x(pt.x), y(pt.y), z(_Tp()) {}
template<typename _Tp> inline Point3_<_Tp>::Point3_(const CvPoint3D32f& pt) :
x(saturate_cast<_Tp>(pt.x)), y(saturate_cast<_Tp>(pt.y)), z(saturate_cast<_Tp>(pt.z)) {}
template<typename _Tp> inline Point3_<_Tp>::Point3_(const Vec<_Tp, 3>& v) : x(v[0]), y(v[1]), z(v[2]) {} template<typename _Tp> inline Point3_<_Tp>::Point3_(const Vec<_Tp, 3>& v) : x(v[0]), y(v[1]), z(v[2]) {}
template<typename _Tp> template<typename _Tp2> inline Point3_<_Tp>::operator Point3_<_Tp2>() const template<typename _Tp> template<typename _Tp2> inline Point3_<_Tp>::operator Point3_<_Tp2>() const
{ return Point3_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(z)); } { return Point3_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(z)); }
template<typename _Tp> inline Point3_<_Tp>::operator CvPoint3D32f() const
{ return cvPoint3D32f((float)x, (float)y, (float)z); }
template<typename _Tp> inline Point3_<_Tp>::operator Vec<_Tp, 3>() const template<typename _Tp> inline Point3_<_Tp>::operator Vec<_Tp, 3>() const
{ return Vec<_Tp, 3>(x, y, z); } { return Vec<_Tp, 3>(x, y, z); }

@ -0,0 +1,251 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_CORE_TYPES_HPP__
#define __OPENCV_CORE_TYPES_HPP__
#include <climits>
#ifndef OPENCV_NOSTL
# include <complex>
#endif
#include "opencv2/core/cvdef.h"
#include "opencv2/core/cvstd.hpp"
namespace cv
{
template<typename _Tp> class CV_EXPORTS Size_;
template<typename _Tp> class CV_EXPORTS Point_;
template<typename _Tp> class CV_EXPORTS Rect_;
template<typename _Tp, int cn> class CV_EXPORTS Vec;
//template<typename _Tp, int m, int n> class CV_EXPORTS Matx;
/////////////// saturate_cast (used in image & signal processing) ///////////////////
template<typename _Tp> static inline _Tp saturate_cast(uchar v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(schar v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(ushort v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(short v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(unsigned v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(int v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(float v) { return _Tp(v); }
template<typename _Tp> static inline _Tp saturate_cast(double v) { return _Tp(v); }
template<> inline uchar saturate_cast<uchar>(schar v) { return (uchar)std::max((int)v, 0); }
template<> inline uchar saturate_cast<uchar>(ushort v) { return (uchar)std::min((unsigned)v, (unsigned)UCHAR_MAX); }
template<> inline uchar saturate_cast<uchar>(int v) { return (uchar)((unsigned)v <= UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0); }
template<> inline uchar saturate_cast<uchar>(short v) { return saturate_cast<uchar>((int)v); }
template<> inline uchar saturate_cast<uchar>(unsigned v) { return (uchar)std::min(v, (unsigned)UCHAR_MAX); }
template<> inline uchar saturate_cast<uchar>(float v) { int iv = cvRound(v); return saturate_cast<uchar>(iv); }
template<> inline uchar saturate_cast<uchar>(double v) { int iv = cvRound(v); return saturate_cast<uchar>(iv); }
template<> inline schar saturate_cast<schar>(uchar v) { return (schar)std::min((int)v, SCHAR_MAX); }
template<> inline schar saturate_cast<schar>(ushort v) { return (schar)std::min((unsigned)v, (unsigned)SCHAR_MAX); }
template<> inline schar saturate_cast<schar>(int v) { return (schar)((unsigned)(v-SCHAR_MIN) <= (unsigned)UCHAR_MAX ? v : v > 0 ? SCHAR_MAX : SCHAR_MIN); }
template<> inline schar saturate_cast<schar>(short v) { return saturate_cast<schar>((int)v); }
template<> inline schar saturate_cast<schar>(unsigned v) { return (schar)std::min(v, (unsigned)SCHAR_MAX); }
template<> inline schar saturate_cast<schar>(float v) { int iv = cvRound(v); return saturate_cast<schar>(iv); }
template<> inline schar saturate_cast<schar>(double v) { int iv = cvRound(v); return saturate_cast<schar>(iv); }
template<> inline ushort saturate_cast<ushort>(schar v) { return (ushort)std::max((int)v, 0); }
template<> inline ushort saturate_cast<ushort>(short v) { return (ushort)std::max((int)v, 0); }
template<> inline ushort saturate_cast<ushort>(int v) { return (ushort)((unsigned)v <= (unsigned)USHRT_MAX ? v : v > 0 ? USHRT_MAX : 0); }
template<> inline ushort saturate_cast<ushort>(unsigned v) { return (ushort)std::min(v, (unsigned)USHRT_MAX); }
template<> inline ushort saturate_cast<ushort>(float v) { int iv = cvRound(v); return saturate_cast<ushort>(iv); }
template<> inline ushort saturate_cast<ushort>(double v) { int iv = cvRound(v); return saturate_cast<ushort>(iv); }
template<> inline short saturate_cast<short>(ushort v) { return (short)std::min((int)v, SHRT_MAX); }
template<> inline short saturate_cast<short>(int v) { return (short)((unsigned)(v - SHRT_MIN) <= (unsigned)USHRT_MAX ? v : v > 0 ? SHRT_MAX : SHRT_MIN); }
template<> inline short saturate_cast<short>(unsigned v) { return (short)std::min(v, (unsigned)SHRT_MAX); }
template<> inline short saturate_cast<short>(float v) { int iv = cvRound(v); return saturate_cast<short>(iv); }
template<> inline short saturate_cast<short>(double v) { int iv = cvRound(v); return saturate_cast<short>(iv); }
template<> inline int saturate_cast<int>(float v) { return cvRound(v); }
template<> inline int saturate_cast<int>(double v) { return cvRound(v); }
// we intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.
template<> inline unsigned saturate_cast<unsigned>(float v) { return cvRound(v); }
template<> inline unsigned saturate_cast<unsigned>(double v) { return cvRound(v); }
//////////////////////////////// Complex //////////////////////////////
/*!
A complex number class.
The template class is similar and compatible with std::complex, however it provides slightly
more convenient access to the real and imaginary parts using through the simple field access, as opposite
to std::complex::real() and std::complex::imag().
*/
template<typename _Tp> class CV_EXPORTS Complex
{
public:
//! constructors
Complex();
Complex( _Tp _re, _Tp _im=0 );
//! conversion to another data type
template<typename T2> operator Complex<T2>() const;
//! conjugation
Complex conj() const;
_Tp re, im; //< the real and the imaginary parts
#ifndef OPENCV_NOSTL
Complex( const std::complex<_Tp>& c );
operator std::complex<_Tp>() const;
#endif
};
/*!
\typedef
*/
typedef Complex<float> Complexf;
typedef Complex<double> Complexd;
//////////////////////////////// Point_ ////////////////////////////////
/*!
template 2D point class.
The class defines a point in 2D space. Data type of the point coordinates is specified
as a template parameter. There are a few shorter aliases available for user convenience.
See cv::Point, cv::Point2i, cv::Point2f and cv::Point2d.
*/
template<typename _Tp> class CV_EXPORTS Point_
{
public:
typedef _Tp value_type;
// various constructors
Point_();
Point_(_Tp _x, _Tp _y);
Point_(const Point_& pt);
Point_(const Size_<_Tp>& sz);
Point_(const Vec<_Tp, 2>& v);
Point_& operator = (const Point_& pt);
//! conversion to another data type
template<typename _Tp2> operator Point_<_Tp2>() const;
//! conversion to the old-style C structures
operator Vec<_Tp, 2>() const;
//! dot product
_Tp dot(const Point_& pt) const;
//! dot product computed in double-precision arithmetics
double ddot(const Point_& pt) const;
//! cross-product
double cross(const Point_& pt) const;
//! checks whether the point is inside the specified rectangle
bool inside(const Rect_<_Tp>& r) const;
_Tp x, y; //< the point coordinates
};
/*!
\typedef
*/
typedef Point_<int> Point2i;
typedef Point_<float> Point2f;
typedef Point_<double> Point2d;
typedef Point2i Point;
//////////////////////////////// Point3_ ////////////////////////////////
/*!
template 3D point class.
The class defines a point in 3D space. Data type of the point coordinates is specified
as a template parameter.
\see cv::Point3i, cv::Point3f and cv::Point3d
*/
template<typename _Tp> class CV_EXPORTS Point3_
{
public:
typedef _Tp value_type;
// various constructors
Point3_();
Point3_(_Tp _x, _Tp _y, _Tp _z);
Point3_(const Point3_& pt);
explicit Point3_(const Point_<_Tp>& pt);
Point3_(const Vec<_Tp, 3>& v);
Point3_& operator = (const Point3_& pt);
//! conversion to another data type
template<typename _Tp2> operator Point3_<_Tp2>() const;
//! conversion to cv::Vec<>
operator Vec<_Tp, 3>() const;
//! dot product
_Tp dot(const Point3_& pt) const;
//! dot product computed in double-precision arithmetics
double ddot(const Point3_& pt) const;
//! cross product of the 2 3D points
Point3_ cross(const Point3_& pt) const;
_Tp x, y, z; //< the point coordinates
};
/*!
\typedef
*/
typedef Point3_<int> Point3i;
typedef Point3_<float> Point3f;
typedef Point3_<double> Point3d;
} // cv
#endif //__OPENCV_CORE_TYPES_HPP__

@ -92,6 +92,10 @@
# define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL # define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL
#endif #endif
#ifdef __cplusplus
# include "opencv2/core/types.hpp"
#endif
/* CvArr* is used to pass arbitrary /* CvArr* is used to pass arbitrary
* array-like data structures * array-like data structures
* into functions where the particular * into functions where the particular
@ -749,6 +753,14 @@ typedef struct CvPoint
{ {
int x; int x;
int y; int y;
#ifdef __cplusplus
CvPoint(int _x = 0, int _y = 0): x(_x), y(_y) {}
template<typename _Tp>
CvPoint(const cv::Point_<_Tp>& pt): x((int)pt.x), y((int)pt.y) {}
template<typename _Tp>
operator cv::Point_<_Tp>() const { return cv::Point_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y)); }
#endif
} }
CvPoint; CvPoint;
@ -768,6 +780,14 @@ typedef struct CvPoint2D32f
{ {
float x; float x;
float y; float y;
#ifdef __cplusplus
CvPoint2D32f(float _x = 0, float _y = 0): x(_x), y(_y) {}
template<typename _Tp>
CvPoint2D32f(const cv::Point_<_Tp>& pt): x((float)pt.x), y((float)pt.y) {}
template<typename _Tp>
operator cv::Point_<_Tp>() const { return cv::Point_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y)); }
#endif
} }
CvPoint2D32f; CvPoint2D32f;
@ -804,6 +824,14 @@ typedef struct CvPoint3D32f
float x; float x;
float y; float y;
float z; float z;
#ifdef __cplusplus
CvPoint3D32f(float _x = 0, float _y = 0, float _z = 0): x(_x), y(_y), z(_z) {}
template<typename _Tp>
CvPoint3D32f(const cv::Point3_<_Tp>& pt): x((float)pt.x), y((float)pt.y), z((float)pt.z) {}
template<typename _Tp>
operator cv::Point3_<_Tp>() const { return cv::Point3_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y), cv::saturate_cast<_Tp>(z)); }
#endif
} }
CvPoint3D32f; CvPoint3D32f;

@ -48,7 +48,7 @@
(deltas)[6] = (step), (deltas)[7] = (step) + (nch)) (deltas)[6] = (step), (deltas)[7] = (step) + (nch))
static const CvPoint icvCodeDeltas[8] = static const CvPoint icvCodeDeltas[8] =
{ {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}, {0, 1}, {1, 1} }; { CvPoint(1, 0), CvPoint(1, -1), CvPoint(0, -1), CvPoint(-1, -1), CvPoint(-1, 0), CvPoint(-1, 1), CvPoint(0, 1), CvPoint(1, 1) };
CV_IMPL void CV_IMPL void
cvStartReadChainPoints( CvChain * chain, CvChainPtReader * reader ) cvStartReadChainPoints( CvChain * chain, CvChainPtReader * reader )
@ -78,7 +78,7 @@ cvReadChainPoint( CvChainPtReader * reader )
{ {
schar *ptr; schar *ptr;
int code; int code;
CvPoint pt = { 0, 0 }; CvPoint pt;
if( !reader ) if( !reader )
CV_Error( CV_StsNullPtr, "" ); CV_Error( CV_StsNullPtr, "" );

@ -321,7 +321,7 @@ static void DrawEtalon(IplImage *img, CvPoint2D32f *corners,
const int r = 4; const int r = 4;
int i; int i;
int x, y; int x, y;
CvPoint prev_pt = { 0, 0 }; CvPoint prev_pt;
static const CvScalar rgb_colors[] = { static const CvScalar rgb_colors[] = {
{{0,0,255}}, {{0,0,255}},
{{0,128,255}}, {{0,128,255}},

@ -87,8 +87,8 @@ int PointInRect(const CvPoint& p, const CvRect& r)
inline inline
int RectInRect(const CvRect& r1, const CvRect& r2) int RectInRect(const CvRect& r1, const CvRect& r2)
{ {
CvPoint plt = {r1.x, r1.y}; CvPoint plt(r1.x, r1.y);
CvPoint prb = {r1.x + r1.width, r1.y + r1.height}; CvPoint prb(r1.x + r1.width, r1.y + r1.height);
return (PointInRect(plt, r2) && PointInRect(prb, r2)); return (PointInRect(plt, r2) && PointInRect(prb, r2));
} }

@ -558,7 +558,7 @@ void CvCalibFilter::DrawPoints( CvMat** dstarr )
const int colorCount = sizeof(line_colors)/sizeof(line_colors[0]); const int colorCount = sizeof(line_colors)/sizeof(line_colors[0]);
const int r = 4; const int r = 4;
CvScalar color = line_colors[0]; CvScalar color = line_colors[0];
CvPoint prev_pt = { 0, 0}; CvPoint prev_pt;
for( j = 0; j < count; j++ ) for( j = 0; j < count; j++ )
{ {

@ -1826,7 +1826,7 @@ void icvGetCutPiece( CvVect64d areaLineCoef1,CvVect64d areaLineCoef2,
/* Collect all candidate point */ /* Collect all candidate point */
CvPoint2D64d candPoints[8]; CvPoint2D64d candPoints[8];
CvPoint2D64d midPoint = {0, 0}; CvPoint2D64d midPoint;
int numPoints = 0; int numPoints = 0;
int res; int res;
int i; int i;

@ -694,7 +694,7 @@ void _cvProjectionPointToSegment(CvPoint2D32f* PointO,
float* dist) float* dist)
{ {
float scal_AO_AB, scal_AB_AB; float scal_AO_AB, scal_AB_AB;
CvPoint2D32f VectorAB = {PointB->x - PointA->x, PointB->y - PointA->y}; CvPoint2D32f VectorAB(PointB->x - PointA->x, PointB->y - PointA->y);
scal_AB_AB = VectorAB.x*VectorAB.x + VectorAB.y*VectorAB.y; scal_AB_AB = VectorAB.x*VectorAB.x + VectorAB.y*VectorAB.y;
if(scal_AB_AB < LCM_CONST_ZERO) if(scal_AB_AB < LCM_CONST_ZERO)
{ {
@ -704,7 +704,7 @@ void _cvProjectionPointToSegment(CvPoint2D32f* PointO,
return; return;
} }
CvPoint2D32f VectorAO = {PointO->x - PointA->x, PointO->y - PointA->y}; CvPoint2D32f VectorAO(PointO->x - PointA->x, PointO->y - PointA->y);
scal_AO_AB = VectorAO.x*VectorAB.x + VectorAO.y*VectorAB.y; scal_AO_AB = VectorAO.x*VectorAB.x + VectorAO.y*VectorAB.y;
if(dist) if(dist)

@ -78,7 +78,7 @@ void _cvWorkEast (int i, int j, _CvWork** W, CvPoint2D32f* edges1, CvPoint2D
void _cvWorkSouthEast(int i, int j, _CvWork** W, CvPoint2D32f* edges1, CvPoint2D32f* edges2); void _cvWorkSouthEast(int i, int j, _CvWork** W, CvPoint2D32f* edges1, CvPoint2D32f* edges2);
void _cvWorkSouth (int i, int j, _CvWork** W, CvPoint2D32f* edges1, CvPoint2D32f* edges2); void _cvWorkSouth (int i, int j, _CvWork** W, CvPoint2D32f* edges1, CvPoint2D32f* edges2);
static CvPoint2D32f null_edge = {0,0}; static CvPoint2D32f null_edge;
double _cvStretchingWork(CvPoint2D32f* P1, double _cvStretchingWork(CvPoint2D32f* P1,
CvPoint2D32f* P2) CvPoint2D32f* P2)
@ -106,7 +106,7 @@ double _cvBendingWork( CvPoint2D32f* B0,
CvPoint* K*/) CvPoint* K*/)
{ {
CvPoint2D32f Q0, Q1, Q2; CvPoint2D32f Q0, Q1, Q2;
CvPoint2D32f Q1_nm = { 0, 0 }, Q2_nm = { 0, 0 }; CvPoint2D32f Q1_nm, Q2_nm;
double d0, d1, d2, des, t_zero; double d0, d1, d2, des, t_zero;
double k_zero, k_nonmon; double k_zero, k_nonmon;
CvPoint2D32f center; CvPoint2D32f center;

@ -328,8 +328,8 @@ static void color_derv( const CvArr* srcArr, CvArr* dstArr, int thresh )
} }
#endif #endif
const CvPoint icvCodeDeltas[8] = static const CvPoint icvCodeDeltas[8] =
{ {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}, {0, 1}, {1, 1} }; { CvPoint(1, 0), CvPoint(1, -1), CvPoint(0, -1), CvPoint(-1, -1), CvPoint(-1, 0), CvPoint(-1, 1), CvPoint(0, 1), CvPoint(1, 1) };
static CvSeq* static CvSeq*
icvGetComponent( uchar* img, int step, CvRect rect, icvGetComponent( uchar* img, int step, CvRect rect,
@ -366,7 +366,7 @@ icvGetComponent( uchar* img, int step, CvRect rect,
CvSeqWriter writer; CvSeqWriter writer;
char *i0, *i1, *i3, *i4 = 0; char *i0, *i1, *i3, *i4 = 0;
int prev_s = -1, s, s_end; int prev_s = -1, s, s_end;
CvPoint pt = { x, y }; CvPoint pt(x, y);
if( !(prev == 0 && p == 2) ) /* if not external contour */ if( !(prev == 0 && p == 2) ) /* if not external contour */
{ {

@ -749,11 +749,11 @@ int ChoiceTrackingFace2(CvFaceTracker* pTF, const int nElements, const CvFaceEle
face[element[0]] = *(new_face[element[0]]); face[element[0]] = *(new_face[element[0]]);
face[element[1]] = *(new_face[element[1]]); face[element[1]] = *(new_face[element[1]]);
// 3 element find by template // 3 element find by template
CvPoint templ_v01 = {pTF->ptTempl[element[1]].x - pTF->ptTempl[element[0]].x, pTF->ptTempl[element[1]].y - pTF->ptTempl[element[0]].y}; CvPoint templ_v01(pTF->ptTempl[element[1]].x - pTF->ptTempl[element[0]].x, pTF->ptTempl[element[1]].y - pTF->ptTempl[element[0]].y);
CvPoint templ_v02 = {pTF->ptTempl[element[2]].x - pTF->ptTempl[element[0]].x, pTF->ptTempl[element[2]].y - pTF->ptTempl[element[0]].y}; CvPoint templ_v02(pTF->ptTempl[element[2]].x - pTF->ptTempl[element[0]].x, pTF->ptTempl[element[2]].y - pTF->ptTempl[element[0]].y);
CvPoint prev_v01 = {pTF->face[element[1]].ptCenter.x - pTF->face[element[0]].ptCenter.x, pTF->face[element[1]].ptCenter.y - pTF->face[element[0]].ptCenter.y}; CvPoint prev_v01(pTF->face[element[1]].ptCenter.x - pTF->face[element[0]].ptCenter.x, pTF->face[element[1]].ptCenter.y - pTF->face[element[0]].ptCenter.y);
CvPoint prev_v02 = {pTF->face[element[2]].ptCenter.x - pTF->face[element[0]].ptCenter.x, pTF->face[element[2]].ptCenter.y - pTF->face[element[0]].ptCenter.y}; CvPoint prev_v02(pTF->face[element[2]].ptCenter.x - pTF->face[element[0]].ptCenter.x, pTF->face[element[2]].ptCenter.y - pTF->face[element[0]].ptCenter.y);
CvPoint new_v01 = {new_face[element[1]]->ptCenter.x - new_face[element[0]]->ptCenter.x, new_face[element[1]]->ptCenter.y - new_face[element[0]]->ptCenter.y}; CvPoint new_v01(new_face[element[1]]->ptCenter.x - new_face[element[0]]->ptCenter.x, new_face[element[1]]->ptCenter.y - new_face[element[0]]->ptCenter.y);
double templ_d01 = sqrt((double)templ_v01.x*templ_v01.x + templ_v01.y*templ_v01.y); double templ_d01 = sqrt((double)templ_v01.x*templ_v01.x + templ_v01.y*templ_v01.y);
double templ_d02 = sqrt((double)templ_v02.x*templ_v02.x + templ_v02.y*templ_v02.y); double templ_d02 = sqrt((double)templ_v02.x*templ_v02.x + templ_v02.y*templ_v02.y);
double prev_d01 = sqrt((double)prev_v01.x*prev_v01.x + prev_v01.y*prev_v01.y); double prev_d01 = sqrt((double)prev_v01.x*prev_v01.x + prev_v01.y*prev_v01.y);
@ -767,7 +767,7 @@ int ChoiceTrackingFace2(CvFaceTracker* pTF, const int nElements, const CvFaceEle
double y = double(new_v01.x) * sin_a + double(new_v01.y) * cos_a; double y = double(new_v01.x) * sin_a + double(new_v01.y) * cos_a;
x = x * new_d02 / new_d01; x = x * new_d02 / new_d01;
y = y * new_d02 / new_d01; y = y * new_d02 / new_d01;
CvPoint new_v02 = {int(x + 0.5), int(y + 0.5)}; CvPoint new_v02(int(x + 0.5), int(y + 0.5));
face[element[2]].iColor = 0; face[element[2]].iColor = 0;
face[element[2]].iEnergy = 0; face[element[2]].iEnergy = 0;
face[element[2]].nRectsInThis = 0; face[element[2]].nRectsInThis = 0;
@ -818,10 +818,10 @@ inline int GetEnergy(CvTrackingRect** ppNew, const CvTrackingRect* pPrev, CvPoin
inline int GetEnergy2(CvTrackingRect** ppNew, const CvTrackingRect* pPrev, CvPoint* ptTempl, CvRect* rTempl, int* element) inline int GetEnergy2(CvTrackingRect** ppNew, const CvTrackingRect* pPrev, CvPoint* ptTempl, CvRect* rTempl, int* element)
{ {
CvPoint new_v = {ppNew[element[0]]->ptCenter.x - ppNew[element[1]]->ptCenter.x, CvPoint new_v(ppNew[element[0]]->ptCenter.x - ppNew[element[1]]->ptCenter.x,
ppNew[element[0]]->ptCenter.y - ppNew[element[1]]->ptCenter.y}; ppNew[element[0]]->ptCenter.y - ppNew[element[1]]->ptCenter.y);
CvPoint prev_v = {pPrev[element[0]].ptCenter.x - pPrev[element[1]].ptCenter.x, CvPoint prev_v(pPrev[element[0]].ptCenter.x - pPrev[element[1]].ptCenter.x,
pPrev[element[0]].ptCenter.y - pPrev[element[1]].ptCenter.y}; pPrev[element[0]].ptCenter.y - pPrev[element[1]].ptCenter.y);
double new_d = sqrt((double)new_v.x*new_v.x + new_v.y*new_v.y); double new_d = sqrt((double)new_v.x*new_v.x + new_v.y*new_v.y);
double prev_d = sqrt((double)prev_v.x*prev_v.x + prev_v.y*prev_v.y); double prev_d = sqrt((double)prev_v.x*prev_v.x + prev_v.y*prev_v.y);
double dx = ptTempl[element[0]].x - ptTempl[element[1]].x; double dx = ptTempl[element[0]].x - ptTempl[element[1]].x;

@ -66,8 +66,8 @@ void CV_PyrSegmentationTest::run( int /*start_from*/ )
int code = cvtest::TS::OK; int code = cvtest::TS::OK;
CvPoint _cp[] ={{33,33}, {43,33}, {43,43}, {33,43}}; CvPoint _cp[] ={ CvPoint(33,33), CvPoint(43,33), CvPoint(43,43), CvPoint(33,43)};
CvPoint _cp2[] ={{50,50}, {70,50}, {70,70}, {50,70}}; CvPoint _cp2[] ={CvPoint(50,50), CvPoint(70,50), CvPoint(70,70), CvPoint(50,70)};
CvPoint* cp = _cp; CvPoint* cp = _cp;
CvPoint* cp2 = _cp2; CvPoint* cp2 = _cp2;
CvConnectedComp *dst_comp[3]; CvConnectedComp *dst_comp[3];

@ -397,7 +397,7 @@ float ann_calc_error( CvANN_MLP* ann, CvMLData* _data, map<int, int>& cls_map, i
int si = sidx ? sidx[i] : i; int si = sidx ? sidx[i] : i;
cvGetRow( &predictors, &sample, si ); cvGetRow( &predictors, &sample, si );
ann->predict( &sample, &_output ); ann->predict( &sample, &_output );
CvPoint best_cls = {0,0}; CvPoint best_cls;
cvMinMaxLoc( &_output, 0, 0, 0, &best_cls, 0 ); cvMinMaxLoc( &_output, 0, 0, 0, &best_cls, 0 );
int r = cvRound(responses->data.fl[si*r_step]); int r = cvRound(responses->data.fl[si*r_step]);
CV_DbgAssert( fabs(responses->data.fl[si*r_step]-r) < FLT_EPSILON ); CV_DbgAssert( fabs(responses->data.fl[si*r_step]-r) < FLT_EPSILON );

@ -43,7 +43,7 @@ unsigned char ccblk[256] = { 34,17,2,17,19,19,2,17,36,36,2,36,19,19,2,17,51,51,2
36,19,19,2,32,66,66,2,66,19,19,2,66,36,36,2,36,19,19,2,66,51,51,2,51,19,19,2,51,36,36,2,36,19,19,2,32,49,49,2,49, 36,19,19,2,32,66,66,2,66,19,19,2,66,36,36,2,36,19,19,2,66,51,51,2,51,19,19,2,51,36,36,2,36,19,19,2,32,49,49,2,49,
19,19,2,49,36,36,2,36,19,19,2,49,51,51,2,51,19,19,2,51,36,36,2,36,19,19,2,49,66,66,2,66,19,19,2,66,36,36,2,36,19, 19,19,2,49,36,36,2,36,19,19,2,49,51,51,2,51,19,19,2,51,36,36,2,36,19,19,2,49,66,66,2,66,19,19,2,66,36,36,2,36,19,
19,2,66,51,51,2,51,19,19,2,51,36,36,2,36,19,19,2,34 }; 19,2,66,51,51,2,51,19,19,2,51,36,36,2,36,19,19,2,34 };
static const CvPoint pickup[64] = { {7,6},{8,6},{7,5},{8,5},{1,5},{7,4},{8,4},{1,4},{1,8},{2,8},{1,7},{2,7},{3,7}, static const int pickup[64][2] = { {7,6},{8,6},{7,5},{8,5},{1,5},{7,4},{8,4},{1,4},{1,8},{2,8},{1,7},{2,7},{3,7},
{1,6},{2,6},{3,6},{3,2},{4,2},{3,1},{4,1},{5,1},{3,8},{4,8},{5,8},{6,1},{7,1},{6,8},{7,8},{8,8},{6,7},{7,7},{8,7}, {1,6},{2,6},{3,6},{3,2},{4,2},{3,1},{4,1},{5,1},{3,8},{4,8},{5,8},{6,1},{7,1},{6,8},{7,8},{8,8},{6,7},{7,7},{8,7},
{4,7},{5,7},{4,6},{5,6},{6,6},{4,5},{5,5},{6,5},{2,5},{3,5},{2,4},{3,4},{4,4},{2,3},{3,3},{4,3},{8,3},{1,3},{8,2}, {4,7},{5,7},{4,6},{5,6},{6,6},{4,5},{5,5},{6,5},{2,5},{3,5},{2,4},{3,4},{4,4},{2,3},{3,3},{4,3},{8,3},{1,3},{8,2},
{1,2},{2,2},{8,1},{1,1},{2,1},{5,4},{6,4},{5,3},{6,3},{7,3},{5,2},{6,2},{7,2} }; {1,2},{2,2},{8,1},{1,1},{2,1},{5,4},{6,4},{5,3},{6,3},{7,3},{5,2},{6,2},{7,2} };
@ -255,7 +255,7 @@ static int decode(Sampler &sa, code &cc)
sum += sa.getpixel(1 + (i & 7), 1 + (i >> 3)); sum += sa.getpixel(1 + (i & 7), 1 + (i >> 3));
uchar mean = (uchar)(sum / 64); uchar mean = (uchar)(sum / 64);
for (int i = 0; i < 64; i++) { for (int i = 0; i < 64; i++) {
b = (b << 1) + (sa.getpixel(pickup[i].x, pickup[i].y) <= mean); b = (b << 1) + (sa.getpixel(pickup[i][0], pickup[i][1]) <= mean);
if ((i & 7) == 7) { if ((i & 7) == 7) {
binary[i >> 3] = b; binary[i >> 3] = b;
b = 0; b = 0;

@ -262,7 +262,7 @@ int main(int argc, char** argv)
printf( "Extraction time = %gms\n", tt/(cvGetTickFrequency()*1000.)); printf( "Extraction time = %gms\n", tt/(cvGetTickFrequency()*1000.));
CvPoint src_corners[4] = {{0,0}, {object->width,0}, {object->width, object->height}, {0, object->height}}; CvPoint src_corners[4] = {CvPoint(0,0), CvPoint(object->width,0), CvPoint(object->width, object->height), CvPoint(0, object->height)};
CvPoint dst_corners[4]; CvPoint dst_corners[4];
IplImage* correspond = cvCreateImage( cvSize(image->width, object->height+image->height), 8, 1 ); IplImage* correspond = cvCreateImage( cvSize(image->width, object->height+image->height), 8, 1 );
cvSetImageROI( correspond, cvRect( 0, 0, object->width, object->height ) ); cvSetImageROI( correspond, cvRect( 0, 0, object->width, object->height ) );

@ -463,7 +463,7 @@ int build_mlp_classifier( char* data_filename,
int best_class; int best_class;
CvMat sample; CvMat sample;
cvGetRow( data, &sample, i ); cvGetRow( data, &sample, i );
CvPoint max_loc = {0,0}; CvPoint max_loc;
mlp.predict( &sample, mlp_response ); mlp.predict( &sample, mlp_response );
cvMinMaxLoc( mlp_response, 0, 0, 0, &max_loc, 0 ); cvMinMaxLoc( mlp_response, 0, 0, 0, &max_loc, 0 );
best_class = max_loc.x + 'A'; best_class = max_loc.x + 'A';

Loading…
Cancel
Save