Commit 940eedfb authored by Andrey Kamaev's avatar Andrey Kamaev

Finalize core headers reorganization

parent c979de1e
...@@ -29,6 +29,11 @@ ...@@ -29,6 +29,11 @@
#include <sys/types.h> #include <sys/types.h>
#include <dirent.h> #include <dirent.h>
struct str_greater
{
bool operator() (const cv::String& a, const cv::String& b) { return a > b; }
};
class CameraWrapperConnector class CameraWrapperConnector
{ {
public: public:
...@@ -177,7 +182,7 @@ CameraActivity::ErrorCode CameraWrapperConnector::connectToLib() ...@@ -177,7 +182,7 @@ CameraActivity::ErrorCode CameraWrapperConnector::connectToLib()
std::vector<cv::String> listLibs; std::vector<cv::String> listLibs;
fillListWrapperLibs(folderPath, listLibs); fillListWrapperLibs(folderPath, listLibs);
std::sort(listLibs.begin(), listLibs.end(), std::greater<cv::String>()); std::sort(listLibs.begin(), listLibs.end(), str_greater());
void * libHandle=0; void * libHandle=0;
cv::String cur_path; cv::String cur_path;
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <set> #include <set>
#include <list> #include <list>
#include <numeric> #include <numeric>
#include <map>
#include "precomp.hpp" #include "precomp.hpp"
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "test_precomp.hpp" #include "test_precomp.hpp"
#include <limits> #include <limits>
#include <cstdio> #include <cstdio>
#include <map>
using namespace std; using namespace std;
using namespace cv; using namespace cv;
......
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
#include "opencv2/features2d.hpp" #include "opencv2/features2d.hpp"
#include "opencv2/objdetect.hpp" #include "opencv2/objdetect.hpp"
#include <ostream>
#ifdef __cplusplus #ifdef __cplusplus
/****************************************************************************************\ /****************************************************************************************\
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#include "precomp.hpp" #include "precomp.hpp"
#include "retinafilter.hpp" #include "retinafilter.hpp"
#include <cstdio> #include <cstdio>
#include <sstream>
namespace cv namespace cv
{ {
......
...@@ -57,18 +57,6 @@ ...@@ -57,18 +57,6 @@
#include "opencv2/core/mat.hpp" #include "opencv2/core/mat.hpp"
#include "opencv2/core/persistence.hpp" #include "opencv2/core/persistence.hpp"
#ifndef SKIP_INCLUDES
#include <limits.h>
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <complex>
#include <map>
#include <new>
#include <vector>
#include <sstream>
#endif // SKIP_INCLUDES
/*! \namespace cv /*! \namespace cv
Namespace where all the C++ OpenCV functionality resides Namespace where all the C++ OpenCV functionality resides
*/ */
...@@ -951,6 +939,42 @@ private: ...@@ -951,6 +939,42 @@ private:
/////////////////////////////// Formatted output of cv::Mat ///////////////////////////
class CV_EXPORTS Formatted
{
public:
virtual const char* next() = 0;
virtual void reset() = 0;
virtual ~Formatted();
};
class CV_EXPORTS Formatter
{
public:
enum { FMT_MATLAB = 0,
FMT_CSV = 1,
FMT_PYTHON = 2,
FMT_NUMPY = 3,
FMT_C = 4,
FMT_DEFAULT = FMT_MATLAB
};
virtual ~Formatter();
virtual Ptr<Formatted> format(const Mat& mtx) const = 0;
virtual void set32fPrecision(int p = 8) = 0;
virtual void set64fPrecision(int p = 16) = 0;
virtual void setMultiline(bool ml = true) = 0;
static Ptr<Formatter> get(int fmt = FMT_DEFAULT);
};
//////////////////////////////////////// Algorithm //////////////////////////////////// //////////////////////////////////////// Algorithm ////////////////////////////////////
class CV_EXPORTS Algorithm; class CV_EXPORTS Algorithm;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
// //
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., 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. // Third party copyrights are property of their respective owners.
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
...@@ -1888,7 +1889,6 @@ template<> CV_EXPORTS void Ptr<IplImage>::delete_obj(); ...@@ -1888,7 +1889,6 @@ template<> CV_EXPORTS void Ptr<IplImage>::delete_obj();
template<> CV_EXPORTS void Ptr<CvMatND>::delete_obj(); template<> CV_EXPORTS void Ptr<CvMatND>::delete_obj();
template<> CV_EXPORTS void Ptr<CvSparseMat>::delete_obj(); template<> CV_EXPORTS void Ptr<CvSparseMat>::delete_obj();
template<> CV_EXPORTS void Ptr<CvMemStorage>::delete_obj(); template<> CV_EXPORTS void Ptr<CvMemStorage>::delete_obj();
template<> CV_EXPORTS void Ptr<CvFileStorage>::delete_obj();
////////////// convenient wrappers for operating old-style dynamic structures ////////////// ////////////// convenient wrappers for operating old-style dynamic structures //////////////
...@@ -2228,7 +2228,7 @@ template<typename _Tp> inline ptrdiff_t operator - (const SeqIterator<_Tp>& a, ...@@ -2228,7 +2228,7 @@ template<typename _Tp> inline ptrdiff_t operator - (const SeqIterator<_Tp>& a,
const SeqIterator<_Tp>& b) const SeqIterator<_Tp>& b)
{ {
ptrdiff_t delta = a.index - b.index, n = a.seq->total; ptrdiff_t delta = a.index - b.index, n = a.seq->total;
if( std::abs(static_cast<long>(delta)) > n ) if( delta > n || delta < -n )
delta += delta < 0 ? n : -n; delta += delta < 0 ? n : -n;
return delta; return delta;
} }
......
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
#define CV_CPU_NEON 11 #define CV_CPU_NEON 11
#define CV_HARDWARE_MAX_FEATURE 255 #define CV_HARDWARE_MAX_FEATURE 255
// disable SSE/AVX/NEON headers for NVCC compiler // do not include SSE/AVX/NEON headers for NVCC compiler
#ifndef __CUDACC__ #ifndef __CUDACC__
#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2) #if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
......
This diff is collapsed.
...@@ -68,7 +68,9 @@ public: ...@@ -68,7 +68,9 @@ public:
typedef Vec<channel_type, channels> vec_type; typedef Vec<channel_type, channels> vec_type;
}; };
inline String::String(const std::string& str) : cstr_(0), len_(0) inline
String::String(const std::string& str)
: cstr_(0), len_(0)
{ {
if (!str.empty()) if (!str.empty())
{ {
...@@ -77,7 +79,9 @@ inline String::String(const std::string& str) : cstr_(0), len_(0) ...@@ -77,7 +79,9 @@ inline String::String(const std::string& str) : cstr_(0), len_(0)
} }
} }
inline String::String(const std::string& str, size_t pos, size_t len) : cstr_(0), len_(0) inline
String::String(const std::string& str, size_t pos, size_t len)
: cstr_(0), len_(0)
{ {
size_t strlen = str.size(); size_t strlen = str.size();
pos = max(pos, strlen); pos = max(pos, strlen);
...@@ -86,7 +90,8 @@ inline String::String(const std::string& str, size_t pos, size_t len) : cstr_(0) ...@@ -86,7 +90,8 @@ inline String::String(const std::string& str, size_t pos, size_t len) : cstr_(0)
memcpy(allocate(len), str.c_str() + pos, len); memcpy(allocate(len), str.c_str() + pos, len);
} }
inline String& String::operator=(const std::string& str) inline
String& String::operator = (const std::string& str)
{ {
deallocate(); deallocate();
if (!str.empty()) if (!str.empty())
...@@ -97,12 +102,14 @@ inline String& String::operator=(const std::string& str) ...@@ -97,12 +102,14 @@ inline String& String::operator=(const std::string& str)
return *this; return *this;
} }
inline String::operator std::string() const inline
String::operator std::string() const
{ {
return std::string(cstr_, len_); return std::string(cstr_, len_);
} }
inline String operator+ (const String& lhs, const std::string& rhs) inline
String operator + (const String& lhs, const std::string& rhs)
{ {
String s; String s;
size_t rhslen = rhs.size(); size_t rhslen = rhs.size();
...@@ -112,7 +119,8 @@ inline String operator+ (const String& lhs, const std::string& rhs) ...@@ -112,7 +119,8 @@ inline String operator+ (const String& lhs, const std::string& rhs)
return s; return s;
} }
inline String operator+ (const std::string& lhs, const String& rhs) inline
String operator + (const std::string& lhs, const String& rhs)
{ {
String s; String s;
size_t lhslen = lhs.size(); size_t lhslen = lhs.size();
...@@ -122,30 +130,119 @@ inline String operator+ (const std::string& lhs, const String& rhs) ...@@ -122,30 +130,119 @@ inline String operator+ (const std::string& lhs, const String& rhs)
return s; return s;
} }
inline std::ostream& operator << (std::ostream& os, const String& str) inline
{ FileNode::operator std::string() const
return os << str.c_str();
}
inline FileNode::operator std::string() const
{ {
String value; String value;
read(*this, value, value); read(*this, value, value);
return value; return value;
} }
template<> inline void operator >> (const FileNode& n, std::string& value) template<> inline
void operator >> (const FileNode& n, std::string& value)
{ {
String val; String val;
read(n, val, val); read(n, val, val);
value = val; value = val;
} }
template<> inline FileStorage& operator << (FileStorage& fs, const std::string& value) template<> inline
FileStorage& operator << (FileStorage& fs, const std::string& value)
{ {
return fs << cv::String(value); return fs << cv::String(value);
} }
static inline
std::ostream& operator << (std::ostream& os, const String& str)
{
return os << str.c_str();
}
static inline
std::ostream& operator << (std::ostream& out, Ptr<Formatted> fmtd)
{
fmtd->reset();
for(const char* str = fmtd->next(); str; str = fmtd->next())
out << str;
return out;
}
static inline
std::ostream& operator << (std::ostream& out, const Mat& mtx)
{
return out << Formatter::get()->format(mtx);
}
template<typename _Tp> static inline
std::ostream& operator << (std::ostream& out, const std::vector<Point_<_Tp> >& vec)
{
return out << Formatter::get()->format(Mat(vec));
}
template<typename _Tp> static inline
std::ostream& operator << (std::ostream& out, const std::vector<Point3_<_Tp> >& vec)
{
return out << Formatter::get()->format(Mat(vec));
}
template<typename _Tp, int m, int n> static inline
std::ostream& operator << (std::ostream& out, const Matx<_Tp, m, n>& matx)
{
return out << Formatter::get()->format(matx);
}
template<typename _Tp> static inline
std::ostream& operator << (std::ostream& out, const Point_<_Tp>& p)
{
out << "[" << p.x << ", " << p.y << "]";
return out;
}
template<typename _Tp> static inline
std::ostream& operator << (std::ostream& out, const Point3_<_Tp>& p)
{
out << "[" << p.x << ", " << p.y << ", " << p.z << "]";
return out;
}
template<typename _Tp, int n> static inline
std::ostream& operator << (std::ostream& out, const Vec<_Tp, n>& vec)
{
out << "[";
if(Vec<_Tp, n>::depth < CV_32F)
{
for (int i = 0; i < n - 1; ++i) {
out << (int)vec[i] << ", ";
}
out << (int)vec[n-1] << "]";
}
else
{
for (int i = 0; i < n - 1; ++i) {
out << vec[i] << ", ";
}
out << vec[n-1] << "]";
}
return out;
}
template<typename _Tp> static inline
std::ostream& operator << (std::ostream& out, const Size_<_Tp>& size)
{
return out << "[" << size.width << " x " << size.height << "]";
}
template<typename _Tp> static inline
std::ostream& operator << (std::ostream& out, const Rect_<_Tp>& rect)
{
return out << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]";
}
#endif // OPENCV_NOSTL #endif // OPENCV_NOSTL
} // cv } // cv
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
// //
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., 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. // Third party copyrights are property of their respective owners.
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
...@@ -40,12 +41,10 @@ ...@@ -40,12 +41,10 @@
// //
//M*/ //M*/
#ifndef __OPENCV_CORE_EIGEN_HPP__ #ifndef __OPENCV_CORE_EIGEN_HPP__
#define __OPENCV_CORE_EIGEN_HPP__ #define __OPENCV_CORE_EIGEN_HPP__
#ifdef __cplusplus
#include "opencv2/core/core_c.h"
#include "opencv2/core.hpp" #include "opencv2/core.hpp"
#if defined _MSC_VER && _MSC_VER >= 1200 #if defined _MSC_VER && _MSC_VER >= 1200
...@@ -57,7 +56,7 @@ ...@@ -57,7 +56,7 @@
namespace cv namespace cv
{ {
template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> static inline
void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, Mat& dst ) void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, Mat& dst )
{ {
if( !(src.Flags & Eigen::RowMajorBit) ) if( !(src.Flags & Eigen::RowMajorBit) )
...@@ -75,7 +74,7 @@ void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCo ...@@ -75,7 +74,7 @@ void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCo
} }
// Matx case // Matx case
template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> static inline
void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src,
Matx<_Tp, _rows, _cols>& dst ) Matx<_Tp, _rows, _cols>& dst )
{ {
...@@ -89,14 +88,14 @@ void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCo ...@@ -89,14 +88,14 @@ void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCo
} }
} }
template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> static inline
void cv2eigen( const Mat& src, void cv2eigen( const Mat& src,
Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst ) Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst )
{ {
CV_DbgAssert(src.rows == _rows && src.cols == _cols); CV_DbgAssert(src.rows == _rows && src.cols == _cols);
if( !(dst.Flags & Eigen::RowMajorBit) ) if( !(dst.Flags & Eigen::RowMajorBit) )
{ {
Mat _dst(src.cols, src.rows, DataType<_Tp>::type, const Mat _dst(src.cols, src.rows, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
if( src.type() == _dst.type() ) if( src.type() == _dst.type() )
transpose(src, _dst); transpose(src, _dst);
...@@ -107,46 +106,42 @@ void cv2eigen( const Mat& src, ...@@ -107,46 +106,42 @@ void cv2eigen( const Mat& src,
} }
else else
Mat(src.t()).convertTo(_dst, _dst.type()); Mat(src.t()).convertTo(_dst, _dst.type());
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
else else
{ {
Mat _dst(src.rows, src.cols, DataType<_Tp>::type, const Mat _dst(src.rows, src.cols, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
src.convertTo(_dst, _dst.type()); src.convertTo(_dst, _dst.type());
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
} }
// Matx case // Matx case
template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> static inline
void cv2eigen( const Matx<_Tp, _rows, _cols>& src, void cv2eigen( const Matx<_Tp, _rows, _cols>& src,
Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst ) Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst )
{ {
if( !(dst.Flags & Eigen::RowMajorBit) ) if( !(dst.Flags & Eigen::RowMajorBit) )
{ {
Mat _dst(_cols, _rows, DataType<_Tp>::type, const Mat _dst(_cols, _rows, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
transpose(src, _dst); transpose(src, _dst);
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
else else
{ {
Mat _dst(_rows, _cols, DataType<_Tp>::type, const Mat _dst(_rows, _cols, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
Mat(src).copyTo(_dst); Mat(src).copyTo(_dst);
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
} }
template<typename _Tp> template<typename _Tp> static inline
void cv2eigen( const Mat& src, void cv2eigen( const Mat& src,
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst ) Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
{ {
dst.resize(src.rows, src.cols); dst.resize(src.rows, src.cols);
if( !(dst.Flags & Eigen::RowMajorBit) ) if( !(dst.Flags & Eigen::RowMajorBit) )
{ {
Mat _dst(src.cols, src.rows, DataType<_Tp>::type, const Mat _dst(src.cols, src.rows, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
if( src.type() == _dst.type() ) if( src.type() == _dst.type() )
transpose(src, _dst); transpose(src, _dst);
...@@ -157,40 +152,36 @@ void cv2eigen( const Mat& src, ...@@ -157,40 +152,36 @@ void cv2eigen( const Mat& src,
} }
else else
Mat(src.t()).convertTo(_dst, _dst.type()); Mat(src.t()).convertTo(_dst, _dst.type());
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
else else
{ {
Mat _dst(src.rows, src.cols, DataType<_Tp>::type, const Mat _dst(src.rows, src.cols, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
src.convertTo(_dst, _dst.type()); src.convertTo(_dst, _dst.type());
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
} }
// Matx case // Matx case
template<typename _Tp, int _rows, int _cols> template<typename _Tp, int _rows, int _cols> static inline
void cv2eigen( const Matx<_Tp, _rows, _cols>& src, void cv2eigen( const Matx<_Tp, _rows, _cols>& src,
Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst ) Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst )
{ {
dst.resize(_rows, _cols); dst.resize(_rows, _cols);
if( !(dst.Flags & Eigen::RowMajorBit) ) if( !(dst.Flags & Eigen::RowMajorBit) )
{ {
Mat _dst(_cols, _rows, DataType<_Tp>::type, const Mat _dst(_cols, _rows, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
transpose(src, _dst); transpose(src, _dst);
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
else else
{ {
Mat _dst(_rows, _cols, DataType<_Tp>::type, const Mat _dst(_rows, _cols, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
Mat(src).copyTo(_dst); Mat(src).copyTo(_dst);
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
} }
template<typename _Tp> template<typename _Tp> static inline
void cv2eigen( const Mat& src, void cv2eigen( const Mat& src,
Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst ) Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst )
{ {
...@@ -199,25 +190,23 @@ void cv2eigen( const Mat& src, ...@@ -199,25 +190,23 @@ void cv2eigen( const Mat& src,
if( !(dst.Flags & Eigen::RowMajorBit) ) if( !(dst.Flags & Eigen::RowMajorBit) )
{ {
Mat _dst(src.cols, src.rows, DataType<_Tp>::type, const Mat _dst(src.cols, src.rows, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
if( src.type() == _dst.type() ) if( src.type() == _dst.type() )
transpose(src, _dst); transpose(src, _dst);
else else
Mat(src.t()).convertTo(_dst, _dst.type()); Mat(src.t()).convertTo(_dst, _dst.type());
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
else else
{ {
Mat _dst(src.rows, src.cols, DataType<_Tp>::type, const Mat _dst(src.rows, src.cols, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
src.convertTo(_dst, _dst.type()); src.convertTo(_dst, _dst.type());
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
} }
// Matx case // Matx case
template<typename _Tp, int _rows> template<typename _Tp, int _rows> static inline
void cv2eigen( const Matx<_Tp, _rows, 1>& src, void cv2eigen( const Matx<_Tp, _rows, 1>& src,
Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst ) Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst )
{ {
...@@ -225,22 +214,20 @@ void cv2eigen( const Matx<_Tp, _rows, 1>& src, ...@@ -225,22 +214,20 @@ void cv2eigen( const Matx<_Tp, _rows, 1>& src,
if( !(dst.Flags & Eigen::RowMajorBit) ) if( !(dst.Flags & Eigen::RowMajorBit) )
{ {
Mat _dst(1, _rows, DataType<_Tp>::type, const Mat _dst(1, _rows, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
transpose(src, _dst); transpose(src, _dst);
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
else else
{ {
Mat _dst(_rows, 1, DataType<_Tp>::type, const Mat _dst(_rows, 1, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
src.copyTo(_dst); src.copyTo(_dst);
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
} }
template<typename _Tp> template<typename _Tp> static inline
void cv2eigen( const Mat& src, void cv2eigen( const Mat& src,
Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst ) Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst )
{ {
...@@ -248,49 +235,41 @@ void cv2eigen( const Mat& src, ...@@ -248,49 +235,41 @@ void cv2eigen( const Mat& src,
dst.resize(src.cols); dst.resize(src.cols);
if( !(dst.Flags & Eigen::RowMajorBit) ) if( !(dst.Flags & Eigen::RowMajorBit) )
{ {
Mat _dst(src.cols, src.rows, DataType<_Tp>::type, const Mat _dst(src.cols, src.rows, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
if( src.type() == _dst.type() ) if( src.type() == _dst.type() )
transpose(src, _dst); transpose(src, _dst);
else else
Mat(src.t()).convertTo(_dst, _dst.type()); Mat(src.t()).convertTo(_dst, _dst.type());
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
else else
{ {
Mat _dst(src.rows, src.cols, DataType<_Tp>::type, const Mat _dst(src.rows, src.cols, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
src.convertTo(_dst, _dst.type()); src.convertTo(_dst, _dst.type());
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
} }
//Matx //Matx
template<typename _Tp, int _cols> template<typename _Tp, int _cols> static inline
void cv2eigen( const Matx<_Tp, 1, _cols>& src, void cv2eigen( const Matx<_Tp, 1, _cols>& src,
Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst ) Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst )
{ {
dst.resize(_cols); dst.resize(_cols);
if( !(dst.Flags & Eigen::RowMajorBit) ) if( !(dst.Flags & Eigen::RowMajorBit) )
{ {
Mat _dst(_cols, 1, DataType<_Tp>::type, const Mat _dst(_cols, 1, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
transpose(src, _dst); transpose(src, _dst);
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
else else
{ {
Mat _dst(1, _cols, DataType<_Tp>::type, const Mat _dst(1, _cols, DataType<_Tp>::type,
dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
Mat(src).copyTo(_dst); Mat(src).copyTo(_dst);
CV_DbgAssert(_dst.data == (uchar*)dst.data());
} }
} }
} // cv
}
#endif #endif
#endif
...@@ -47,11 +47,6 @@ ...@@ -47,11 +47,6 @@
# error mat.inl.hpp header must be compiled as C++ # error mat.inl.hpp header must be compiled as C++
#endif #endif
#ifndef SKIP_INCLUDES
#include <limits.h>
#include <string.h>
#endif // SKIP_INCLUDES
namespace cv namespace cv
{ {
......
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
#ifndef __OPENCV_OPENGL_INTEROP_HPP__ #ifndef __OPENCV_OPENGL_INTEROP_HPP__
#define __OPENCV_OPENGL_INTEROP_HPP__ #define __OPENCV_OPENGL_INTEROP_HPP__
#ifdef __cplusplus
#include "opencv2/core.hpp" #include "opencv2/core.hpp"
namespace cv { namespace ogl { namespace cv { namespace ogl {
...@@ -269,7 +267,7 @@ namespace cv { namespace gpu { ...@@ -269,7 +267,7 @@ namespace cv { namespace gpu {
//! set a CUDA device to use OpenGL interoperability //! set a CUDA device to use OpenGL interoperability
CV_EXPORTS void setGlDevice(int device = 0); CV_EXPORTS void setGlDevice(int device = 0);
}} }} // cv::gpu
namespace cv { namespace cv {
...@@ -278,6 +276,4 @@ template <> CV_EXPORTS void Ptr<cv::ogl::Texture2D::Impl>::delete_obj(); ...@@ -278,6 +276,4 @@ template <> CV_EXPORTS void Ptr<cv::ogl::Texture2D::Impl>::delete_obj();
} }
#endif // __cplusplus
#endif // __OPENCV_OPENGL_INTEROP_HPP__ #endif // __OPENCV_OPENGL_INTEROP_HPP__
...@@ -47,12 +47,7 @@ ...@@ -47,12 +47,7 @@
# error operations.hpp header must be compiled as C++ # error operations.hpp header must be compiled as C++
#endif #endif
#ifndef SKIP_INCLUDES #include <cstdio>
#include <string.h>
#include <limits.h>
#endif // SKIP_INCLUDES
#include <limits>
namespace cv namespace cv
{ {
...@@ -356,6 +351,7 @@ inline unsigned RNG::next() ...@@ -356,6 +351,7 @@ inline unsigned RNG::next()
} }
///////////////////////////////////////// LineIterator //////////////////////////////////////// ///////////////////////////////////////// LineIterator ////////////////////////////////////////
inline inline
...@@ -398,39 +394,8 @@ template<typename _Tp> static inline _Tp randu() ...@@ -398,39 +394,8 @@ template<typename _Tp> static inline _Tp randu()
} }
//////////////////////////////////////////////////////////////////////////////
class CV_EXPORTS Formatted
{
public:
virtual const char* next() = 0;
virtual void reset() = 0;
virtual ~Formatted();
};
class CV_EXPORTS Formatter
{
public:
enum { FMT_MATLAB = 0,
FMT_CSV = 1,
FMT_PYTHON = 2,
FMT_NUMPY = 3,
FMT_C = 4,
FMT_DEFAULT = FMT_MATLAB
};
virtual ~Formatter();
virtual Ptr<Formatted> format(const Mat& mtx) const = 0;
virtual void set32fPrecision(int p = 8) = 0;
virtual void set64fPrecision(int p = 16) = 0;
virtual void setMultiline(bool ml = true) = 0;
static Ptr<Formatter> get(int fmt = FMT_DEFAULT); ///////////////////////////////// Formatted output of cv::Mat /////////////////////////////////
};
static inline static inline
Ptr<Formatted> format(InputArray mtx, int fmt) Ptr<Formatted> format(InputArray mtx, int fmt)
...@@ -438,111 +403,53 @@ Ptr<Formatted> format(InputArray mtx, int fmt) ...@@ -438,111 +403,53 @@ Ptr<Formatted> format(InputArray mtx, int fmt)
return Formatter::get(fmt)->format(mtx.getMat()); return Formatter::get(fmt)->format(mtx.getMat());
} }
static inline static inline
std::ostream& operator << (std::ostream& out, Ptr<Formatted> fmtd) int print(Ptr<Formatted> fmtd, FILE* stream = stdout)
{ {
int written = 0;
fmtd->reset(); fmtd->reset();
for(const char* str = fmtd->next(); str; str = fmtd->next()) for(const char* str = fmtd->next(); str; str = fmtd->next())
out << str; written += fputs(str, stream);
return out;
return written;
} }
static inline static inline
std::ostream& operator << (std::ostream& out, const Mat& mtx) int print(const Mat& mtx, FILE* stream = stdout)
{ {
return out << Formatter::get()->format(mtx); return print(Formatter::get()->format(mtx), stream);
} }
template<typename _Tp> static inline template<typename _Tp> static inline
std::ostream& operator << (std::ostream& out, const std::vector<Point_<_Tp> >& vec) int print(const std::vector<Point_<_Tp> >& vec, FILE* stream = stdout)
{ {
return out << Formatter::get()->format(Mat(vec)); return print(Formatter::get()->format(Mat(vec)), stream);
} }
template<typename _Tp> static inline template<typename _Tp> static inline
std::ostream& operator << (std::ostream& out, const std::vector<Point3_<_Tp> >& vec) int print(const std::vector<Point3_<_Tp> >& vec, FILE* stream = stdout)
{ {
return out << Formatter::get()->format(Mat(vec)); return print(Formatter::get()->format(Mat(vec)), stream);
} }
template<typename _Tp, int m, int n> static inline
/** Writes a Matx to an output stream. int print(const Matx<_Tp, m, n>& matx, FILE* stream = stdout)
*/
template<typename _Tp, int m, int n> inline
std::ostream& operator << (std::ostream& out, const Matx<_Tp, m, n>& matx)
{ {
return out << Formatter::get()->format(matx); return print(Formatter::get()->format(matx), stream);
}
/** Writes a point to an output stream in Matlab notation
*/
template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const Point_<_Tp>& p)
{
out << "[" << p.x << ", " << p.y << "]";
return out;
}
/** Writes a point to an output stream in Matlab notation
*/
template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const Point3_<_Tp>& p)
{
out << "[" << p.x << ", " << p.y << ", " << p.z << "]";
return out;
}
/** Writes a Vec to an output stream. Format example : [10, 20, 30]
*/
template<typename _Tp, int n> inline std::ostream& operator<<(std::ostream& out, const Vec<_Tp, n>& vec)
{
out << "[";
if(Vec<_Tp, n>::depth < CV_32F)
{
for (int i = 0; i < n - 1; ++i) {
out << (int)vec[i] << ", ";
}
out << (int)vec[n-1] << "]";
}
else
{
for (int i = 0; i < n - 1; ++i) {
out << vec[i] << ", ";
}
out << vec[n-1] << "]";
}
return out;
}
/** Writes a Size_ to an output stream. Format example : [640 x 480]
*/
template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const Size_<_Tp>& size)
{
out << "[" << size.width << " x " << size.height << "]";
return out;
}
/** Writes a Rect_ to an output stream. Format example : [640 x 480 from (10, 20)]
*/
template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const Rect_<_Tp>& rect)
{
out << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]";
return out;
} }
////////////////////////////////////////// Algorithm ////////////////////////////////////////// ////////////////////////////////////////// Algorithm //////////////////////////////////////////
template<typename _Tp> inline Ptr<_Tp> Algorithm::create(const String& name) template<typename _Tp> inline
Ptr<_Tp> Algorithm::create(const String& name)
{ {
return _create(name).ptr<_Tp>(); return _create(name).ptr<_Tp>();
} }
template<typename _Tp> template<typename _Tp> inline
inline void Algorithm::set(const char* _name, const Ptr<_Tp>& value) void Algorithm::set(const char* _name, const Ptr<_Tp>& value)
{ {
Ptr<Algorithm> algo_ptr = value. template ptr<cv::Algorithm>(); Ptr<Algorithm> algo_ptr = value. template ptr<cv::Algorithm>();
if (algo_ptr.empty()) { if (algo_ptr.empty()) {
...@@ -551,14 +458,14 @@ inline void Algorithm::set(const char* _name, const Ptr<_Tp>& value) ...@@ -551,14 +458,14 @@ inline void Algorithm::set(const char* _name, const Ptr<_Tp>& value)
info()->set(this, _name, ParamType<Algorithm>::type, &algo_ptr); info()->set(this, _name, ParamType<Algorithm>::type, &algo_ptr);
} }
template<typename _Tp> template<typename _Tp> inline
inline void Algorithm::set(const String& _name, const Ptr<_Tp>& value) void Algorithm::set(const String& _name, const Ptr<_Tp>& value)
{ {
this->set<_Tp>(_name.c_str(), value); this->set<_Tp>(_name.c_str(), value);
} }
template<typename _Tp> template<typename _Tp> inline
inline void Algorithm::setAlgorithm(const char* _name, const Ptr<_Tp>& value) void Algorithm::setAlgorithm(const char* _name, const Ptr<_Tp>& value)
{ {
Ptr<Algorithm> algo_ptr = value. template ptr<cv::Algorithm>(); Ptr<Algorithm> algo_ptr = value. template ptr<cv::Algorithm>();
if (algo_ptr.empty()) { if (algo_ptr.empty()) {
...@@ -567,28 +474,31 @@ inline void Algorithm::setAlgorithm(const char* _name, const Ptr<_Tp>& value) ...@@ -567,28 +474,31 @@ inline void Algorithm::setAlgorithm(const char* _name, const Ptr<_Tp>& value)
info()->set(this, _name, ParamType<Algorithm>::type, &algo_ptr); info()->set(this, _name, ParamType<Algorithm>::type, &algo_ptr);
} }
template<typename _Tp> template<typename _Tp> inline
inline void Algorithm::setAlgorithm(const String& _name, const Ptr<_Tp>& value) void Algorithm::setAlgorithm(const String& _name, const Ptr<_Tp>& value)
{ {
this->set<_Tp>(_name.c_str(), value); this->set<_Tp>(_name.c_str(), value);
} }
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const String& _name) const template<typename _Tp> inline
typename ParamType<_Tp>::member_type Algorithm::get(const String& _name) const
{ {
typename ParamType<_Tp>::member_type value; typename ParamType<_Tp>::member_type value;
info()->get(this, _name.c_str(), ParamType<_Tp>::type, &value); info()->get(this, _name.c_str(), ParamType<_Tp>::type, &value);
return value; return value;
} }
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const char* _name) const template<typename _Tp> inline
typename ParamType<_Tp>::member_type Algorithm::get(const char* _name) const
{ {
typename ParamType<_Tp>::member_type value; typename ParamType<_Tp>::member_type value;
info()->get(this, _name, ParamType<_Tp>::type, &value); info()->get(this, _name, ParamType<_Tp>::type, &value);
return value; return value;
} }
template<typename _Tp, typename _Base> inline void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, template<typename _Tp, typename _Base> inline
Ptr<_Tp>& value, bool readOnly, Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&), void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, Ptr<_Tp>& value, bool readOnly,
Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&),
const String& help) const String& help)
{ {
//TODO: static assert: _Tp inherits from _Base //TODO: static assert: _Tp inherits from _Base
...@@ -596,8 +506,9 @@ template<typename _Tp, typename _Base> inline void AlgorithmInfo::addParam(Algor ...@@ -596,8 +506,9 @@ template<typename _Tp, typename _Base> inline void AlgorithmInfo::addParam(Algor
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help); (Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
} }
template<typename _Tp> inline void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, template<typename _Tp> inline
Ptr<_Tp>& value, bool readOnly, Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&), void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, Ptr<_Tp>& value, bool readOnly,
Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&),
const String& help) const String& help)
{ {
//TODO: static assert: _Tp inherits from Algorithm //TODO: static assert: _Tp inherits from Algorithm
...@@ -605,6 +516,8 @@ template<typename _Tp> inline void AlgorithmInfo::addParam(Algorithm& algo, cons ...@@ -605,6 +516,8 @@ template<typename _Tp> inline void AlgorithmInfo::addParam(Algorithm& algo, cons
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help); (Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
} }
}
} // cv
#endif #endif
...@@ -226,6 +226,8 @@ public: ...@@ -226,6 +226,8 @@ public:
int state; //!< the writer state int state; //!< the writer state
}; };
template<> CV_EXPORTS void Ptr<CvFileStorage>::delete_obj();
/*! /*!
File Storage Node class File Storage Node class
......
...@@ -171,7 +171,7 @@ namespace cv ...@@ -171,7 +171,7 @@ namespace cv
#define CV_TOGGLE_FLT(x) ((x)^((int)(x) < 0 ? 0x7fffffff : 0)) #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_TOGGLE_DBL(x) ((x)^((int64)(x) < 0 ? CV_BIG_INT(0x7fffffffffffffff) : 0))
static inline void* cvAlignPtr( const void* ptr, int align CV_DEFAULT(32) ) static inline void* cvAlignPtr( const void* ptr, int align = 32 )
{ {
CV_DbgAssert ( (align & (align-1)) == 0 ); CV_DbgAssert ( (align & (align-1)) == 0 );
return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) ); return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) );
...@@ -183,10 +183,12 @@ static inline int cvAlign( int size, int align ) ...@@ -183,10 +183,12 @@ static inline int cvAlign( int size, int align )
return (size + align - 1) & -align; return (size + align - 1) & -align;
} }
#ifdef IPL_DEPTH_8U
static inline cv::Size cvGetMatSize( const CvMat* mat ) static inline cv::Size cvGetMatSize( const CvMat* mat )
{ {
return cv::Size(mat->cols, mat->rows); return cv::Size(mat->cols, mat->rows);
} }
#endif
namespace cv namespace cv
{ {
......
...@@ -228,7 +228,12 @@ public: ...@@ -228,7 +228,12 @@ public:
}; };
template<int depth> class TypeDepth {};
template<int _depth> class TypeDepth
{
enum { depth = CV_USRTYPE1 };
typedef void value_type;
};
template<> class TypeDepth<CV_8U> template<> class TypeDepth<CV_8U>
{ {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
// //
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., 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. // Third party copyrights are property of their respective owners.
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
......
#include "precomp.hpp" #include "precomp.hpp"
#include <sstream>
namespace cv namespace cv
{ {
......
...@@ -55,7 +55,7 @@ namespace ...@@ -55,7 +55,7 @@ namespace
char buf[32]; // enough for double with precision up to 20 char buf[32]; // enough for double with precision up to 20
cv::Mat mtx; cv::Mat mtx;
int mcn; int mcn; // == mtx.channels()
bool singleLine; bool singleLine;
int state; int state;
...@@ -68,7 +68,6 @@ namespace ...@@ -68,7 +68,6 @@ namespace
char braces[5]; char braces[5];
void (FormattedImpl::*valueToStr)(); void (FormattedImpl::*valueToStr)();
void valueToStr8u() { sprintf(buf, "%3d", (int)mtx.ptr<uchar>(row, col)[cn]); } void valueToStr8u() { sprintf(buf, "%3d", (int)mtx.ptr<uchar>(row, col)[cn]); }
void valueToStr8s() { sprintf(buf, "%3d", (int)mtx.ptr<schar>(row, col)[cn]); } void valueToStr8s() { sprintf(buf, "%3d", (int)mtx.ptr<schar>(row, col)[cn]); }
void valueToStr16u() { sprintf(buf, "%d", (int)mtx.ptr<ushort>(row, col)[cn]); } void valueToStr16u() { sprintf(buf, "%d", (int)mtx.ptr<ushort>(row, col)[cn]); }
......
#include "test_precomp.hpp" #include "test_precomp.hpp"
#include <map>
using namespace cv; using namespace cv;
using namespace std; using namespace std;
......
...@@ -312,9 +312,9 @@ buildIndex_(void*& index, const Mat& data, const IndexParams& params, const Dist ...@@ -312,9 +312,9 @@ buildIndex_(void*& index, const Mat& data, const IndexParams& params, const Dist
{ {
typedef typename Distance::ElementType ElementType; typedef typename Distance::ElementType ElementType;
if(DataType<ElementType>::type != data.type()) if(DataType<ElementType>::type != data.type())
CV_Error_(CV_StsUnsupportedFormat, ("type=%d\n", data.type())); CV_Error_(Error::StsUnsupportedFormat, ("type=%d\n", data.type()));
if(!data.isContinuous()) if(!data.isContinuous())
CV_Error(CV_StsBadArg, "Only continuous arrays are supported"); CV_Error(Error::StsBadArg, "Only continuous arrays are supported");
::cvflann::Matrix<ElementType> dataset((ElementType*)data.data, data.rows, data.cols); ::cvflann::Matrix<ElementType> dataset((ElementType*)data.data, data.rows, data.cols);
IndexType* _index = new IndexType(dataset, get_params(params), dist); IndexType* _index = new IndexType(dataset, get_params(params), dist);
...@@ -400,7 +400,7 @@ void Index::build(InputArray _data, const IndexParams& params, flann_distance_t ...@@ -400,7 +400,7 @@ void Index::build(InputArray _data, const IndexParams& params, flann_distance_t
break; break;
#endif #endif
default: default:
CV_Error(CV_StsBadArg, "Unknown/unsupported distance type"); CV_Error(Error::StsBadArg, "Unknown/unsupported distance type");
} }
} }
...@@ -453,7 +453,7 @@ void Index::release() ...@@ -453,7 +453,7 @@ void Index::release()
break; break;
#endif #endif
default: default:
CV_Error(CV_StsBadArg, "Unknown/unsupported distance type"); CV_Error(Error::StsBadArg, "Unknown/unsupported distance type");
} }
index = 0; index = 0;
} }
...@@ -585,7 +585,7 @@ void Index::knnSearch(InputArray _query, OutputArray _indices, ...@@ -585,7 +585,7 @@ void Index::knnSearch(InputArray _query, OutputArray _indices,
break; break;
#endif #endif
default: default:
CV_Error(CV_StsBadArg, "Unknown/unsupported distance type"); CV_Error(Error::StsBadArg, "Unknown/unsupported distance type");
} }
} }
...@@ -599,7 +599,7 @@ int Index::radiusSearch(InputArray _query, OutputArray _indices, ...@@ -599,7 +599,7 @@ int Index::radiusSearch(InputArray _query, OutputArray _indices,
createIndicesDists( _indices, _dists, indices, dists, query.rows, maxResults, INT_MAX, dtype ); createIndicesDists( _indices, _dists, indices, dists, query.rows, maxResults, INT_MAX, dtype );
if( algo == FLANN_INDEX_LSH ) if( algo == FLANN_INDEX_LSH )
CV_Error( CV_StsNotImplemented, "LSH index does not support radiusSearch operation" ); CV_Error( Error::StsNotImplemented, "LSH index does not support radiusSearch operation" );
switch( distType ) switch( distType )
{ {
...@@ -623,7 +623,7 @@ int Index::radiusSearch(InputArray _query, OutputArray _indices, ...@@ -623,7 +623,7 @@ int Index::radiusSearch(InputArray _query, OutputArray _indices,
return runRadiusSearch< ::cvflann::KL_Divergence<float> >(index, query, indices, dists, radius, params); return runRadiusSearch< ::cvflann::KL_Divergence<float> >(index, query, indices, dists, radius, params);
#endif #endif
default: default:
CV_Error(CV_StsBadArg, "Unknown/unsupported distance type"); CV_Error(Error::StsBadArg, "Unknown/unsupported distance type");
} }
return -1; return -1;
} }
...@@ -658,7 +658,7 @@ void Index::save(const String& filename) const ...@@ -658,7 +658,7 @@ void Index::save(const String& filename) const
{ {
FILE* fout = fopen(filename.c_str(), "wb"); FILE* fout = fopen(filename.c_str(), "wb");
if (fout == NULL) if (fout == NULL)
CV_Error_( CV_StsError, ("Can not open file %s for writing FLANN index\n", filename.c_str()) ); CV_Error_( Error::StsError, ("Can not open file %s for writing FLANN index\n", filename.c_str()) );
switch( distType ) switch( distType )
{ {
...@@ -691,7 +691,7 @@ void Index::save(const String& filename) const ...@@ -691,7 +691,7 @@ void Index::save(const String& filename) const
default: default:
fclose(fout); fclose(fout);
fout = 0; fout = 0;
CV_Error(CV_StsBadArg, "Unknown/unsupported distance type"); CV_Error(Error::StsBadArg, "Unknown/unsupported distance type");
} }
if( fout ) if( fout )
fclose(fout); fclose(fout);
......
...@@ -2543,12 +2543,35 @@ JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump ...@@ -2543,12 +2543,35 @@ JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump
(JNIEnv *env, jclass, jlong self) (JNIEnv *env, jclass, jlong self)
{ {
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
std::stringstream s;
try { try {
LOGD("Mat::nDump()"); LOGD("Mat::nDump()");
s << *me; const int BUFSZ = 4096 - 32;
return env->NewStringUTF(s.str().c_str()); char buf[BUFSZ + 32];
String s;
Ptr<Formatted> fmtd = Formatter::get()->format(*me);
char* pos = buf;
for(const char* str = fmtd->next(); str; str = fmtd->next())
{
pos = strcpy(pos, str);
if(pos > buf + BUFSZ)
{
s = s + String(buf, pos - buf);
pos = buf;
}
}
if (pos > buf)
{
if (s.empty())
return env->NewStringUTF(buf);
s = s + String(buf, pos - buf);
}
return env->NewStringUTF(s.c_str());
} catch(cv::Exception e) { } catch(cv::Exception e) {
LOGE("Mat::nDump() catched cv::Exception: %s", e.what()); LOGE("Mat::nDump() catched cv::Exception: %s", e.what());
jclass je = env->FindClass("org/opencv/core/CvException"); jclass je = env->FindClass("org/opencv/core/CvException");
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "opencv2/core.hpp" #include "opencv2/core.hpp"
#include "opencv2/core/gpumat.hpp" #include "opencv2/core/gpumat.hpp"
#include <ostream>
namespace cv { namespace softcascade { namespace cv { namespace softcascade {
......
...@@ -165,8 +165,7 @@ void cv::softcascade::write(cv::FileStorage& fs, const cv::String&, const Channe ...@@ -165,8 +165,7 @@ void cv::softcascade::write(cv::FileStorage& fs, const cv::String&, const Channe
std::ostream& cv::softcascade::operator<<(std::ostream& out, const ChannelFeature& m) std::ostream& cv::softcascade::operator<<(std::ostream& out, const ChannelFeature& m)
{ {
out << m.channel << " " << m.bb; return out << m.channel << " " << "[" << m.bb.width << " x " << m.bb.height << " from (" << m.bb.x << ", " << m.bb.y << ")]";
return out;
} }
ChannelFeature::~ChannelFeature(){} ChannelFeature::~ChannelFeature(){}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment