Commit ebac3a02 authored by Andrey Kamaev's avatar Andrey Kamaev

Fix backward compatibility of opencv_core

parent d566c6bc
...@@ -2388,7 +2388,7 @@ public: ...@@ -2388,7 +2388,7 @@ public:
PCA(InputArray data, InputArray mean, int flags, double retainedVariance); PCA(InputArray data, InputArray mean, int flags, double retainedVariance);
//! operator that performs PCA. The previously stored data, if any, is released //! operator that performs PCA. The previously stored data, if any, is released
PCA& operator()(InputArray data, InputArray mean, int flags, int maxComponents=0); PCA& operator()(InputArray data, InputArray mean, int flags, int maxComponents=0);
PCA& operator()(InputArray data, InputArray mean, int flags, double retainedVariance); PCA& computeVar(InputArray data, InputArray mean, int flags, double retainedVariance);
//! projects vector from the original space to the principal components subspace //! projects vector from the original space to the principal components subspace
Mat project(InputArray vec) const; Mat project(InputArray vec) const;
//! projects vector from the original space to the principal components subspace //! projects vector from the original space to the principal components subspace
...@@ -2406,7 +2406,7 @@ public: ...@@ -2406,7 +2406,7 @@ public:
CV_EXPORTS_W void PCACompute(InputArray data, CV_OUT InputOutputArray mean, CV_EXPORTS_W void PCACompute(InputArray data, CV_OUT InputOutputArray mean,
OutputArray eigenvectors, int maxComponents=0); OutputArray eigenvectors, int maxComponents=0);
CV_EXPORTS_W void PCACompute(InputArray data, CV_OUT InputOutputArray mean, CV_EXPORTS_W void PCAComputeVar(InputArray data, CV_OUT InputOutputArray mean,
OutputArray eigenvectors, double retainedVariance); OutputArray eigenvectors, double retainedVariance);
CV_EXPORTS_W void PCAProject(InputArray data, InputArray mean, CV_EXPORTS_W void PCAProject(InputArray data, InputArray mean,
...@@ -4562,51 +4562,113 @@ template<> struct ParamType<uint64> ...@@ -4562,51 +4562,113 @@ template<> struct ParamType<uint64>
}; };
// The CommandLineParser class is designed for command line arguments parsing /*!
"\nThe CommandLineParser class is designed for command line arguments parsing\n"
"Keys map: \n"
"Before you start to work with CommandLineParser you have to create a map for keys.\n"
" It will look like this\n"
" const char* keys =\n"
" {\n"
" { s| string| 123asd |string parameter}\n"
" { d| digit | 100 |digit parameter }\n"
" { c|noCamera|false |without camera }\n"
" { 1| |some text|help }\n"
" { 2| |333 |another help }\n"
" };\n"
"Usage syntax: \n"
" \"{\" - start of parameter string.\n"
" \"}\" - end of parameter string\n"
" \"|\" - separator between short name, full name, default value and help\n"
"Supported syntax: \n"
" --key1=arg1 <If a key with '--' must has an argument\n"
" you have to assign it through '=' sign.> \n"
"<If the key with '--' doesn't have any argument, it means that it is a bool key>\n"
" -key2=arg2 <If a key with '-' must has an argument \n"
" you have to assign it through '=' sign.> \n"
"If the key with '-' doesn't have any argument, it means that it is a bool key\n"
" key3 <This key can't has any parameter> \n"
"Usage: \n"
" Imagine that the input parameters are next:\n"
" -s=string_value --digit=250 --noCamera lena.jpg 10000\n"
" CommandLineParser parser(argc, argv, keys) - create a parser object\n"
" parser.get<string>(\"s\" or \"string\") will return you first parameter value\n"
" parser.get<string>(\"s\", false or \"string\", false) will return you first parameter value\n"
" without spaces in end and begin\n"
" parser.get<int>(\"d\" or \"digit\") will return you second parameter value.\n"
" It also works with 'unsigned int', 'double', and 'float' types>\n"
" parser.get<bool>(\"c\" or \"noCamera\") will return you true .\n"
" If you enter this key in commandline>\n"
" It return you false otherwise.\n"
" parser.get<string>(\"1\") will return you the first argument without parameter (lena.jpg) \n"
" parser.get<int>(\"2\") will return you the second argument without parameter (10000)\n"
" It also works with 'unsigned int', 'double', and 'float' types \n"
*/
class CV_EXPORTS CommandLineParser class CV_EXPORTS CommandLineParser
{ {
public: public:
CommandLineParser(int argc, const char* const argv[], const char* key_map);
CommandLineParser(int argc, const char* const argv[], const string& key_map);
CommandLineParser(const CommandLineParser& parser);
CommandLineParser& operator = (const CommandLineParser& parser);
string getPathToApplication() const; //! the default constructor
CommandLineParser(int argc, const char* const argv[], const char* key_map);
template <typename T> //! get parameter, you can choose: delete spaces in end and begin or not
T get(const string& name, bool space_delete = true) const template<typename _Tp>
_Tp get(const std::string& name, bool space_delete=true)
{ {
T val = T(); if (!has(name))
getByName(name, space_delete, ParamType<T>::type, (void*)&val); {
return val; return _Tp();
}
std::string str = getString(name);
return analyzeValue<_Tp>(str, space_delete);
} }
template <typename T> //! print short name, full name, current value and help for all params
T get(int index, bool space_delete = true) const void printParams();
protected:
std::map<std::string, std::vector<std::string> > data;
std::string getString(const std::string& name);
bool has(const std::string& keys);
template<typename _Tp>
_Tp analyzeValue(const std::string& str, bool space_delete=false);
template<typename _Tp>
static _Tp getData(const std::string& str)
{ {
T val = T(); _Tp res;
getByIndex(index, space_delete, ParamType<T>::type, (void*)&val); std::stringstream s1(str);
return val; s1 >> res;
return res;
} }
bool has(const string& keys);
bool check() const;
void about(const string& message); template<typename _Tp>
_Tp fromStringNumber(const std::string& str);//the default conversion function for numbers
void printMessage() const; };
void printErrors() const;
void printParams();
protected: template<> CV_EXPORTS
string getString(const string& name); bool CommandLineParser::get<bool>(const std::string& name, bool space_delete);
void getByName(const string& name, bool space_delete, int type, void* dst) const;
void getByIndex(int index, bool space_delete, int type, void* dst) const; template<> CV_EXPORTS
std::string CommandLineParser::analyzeValue<std::string>(const std::string& str, bool space_delete);
template<> CV_EXPORTS
int CommandLineParser::analyzeValue<int>(const std::string& str, bool space_delete);
template<> CV_EXPORTS
unsigned int CommandLineParser::analyzeValue<unsigned int>(const std::string& str, bool space_delete);
template<> CV_EXPORTS
uint64 CommandLineParser::analyzeValue<uint64>(const std::string& str, bool space_delete);
template<> CV_EXPORTS
float CommandLineParser::analyzeValue<float>(const std::string& str, bool space_delete);
template<> CV_EXPORTS
double CommandLineParser::analyzeValue<double>(const std::string& str, bool space_delete);
struct Impl;
Impl* impl;
};
/////////////////////////////// Parallel Primitives ////////////////////////////////// /////////////////////////////// Parallel Primitives //////////////////////////////////
......
...@@ -123,7 +123,7 @@ namespace cv ...@@ -123,7 +123,7 @@ namespace cv
typedef PtrStep<int> PtrStepi; typedef PtrStep<int> PtrStepi;
#if defined __GNUC__ #if defined __GNUC__
#define __CV_GPU_DEPR_BEFORE__ #define __CV_GPU_DEPR_BEFORE__
#define __CV_GPU_DEPR_AFTER__ __attribute__ ((deprecated)) #define __CV_GPU_DEPR_AFTER__ __attribute__ ((deprecated))
#elif defined(__MSVC__) //|| defined(__CUDACC__) #elif defined(__MSVC__) //|| defined(__CUDACC__)
...@@ -140,7 +140,7 @@ namespace cv ...@@ -140,7 +140,7 @@ namespace cv
DevMem2D_() {} DevMem2D_() {}
DevMem2D_(int rows_, int cols_, T* data_, size_t step_) : PtrStepSz<T>(rows_, cols_, data_, step_) {} DevMem2D_(int rows_, int cols_, T* data_, size_t step_) : PtrStepSz<T>(rows_, cols_, data_, step_) {}
template <typename U> template <typename U>
explicit __CV_GPU_DEPR_BEFORE__ DevMem2D_(const DevMem2D_<U>& d) : PtrStepSz<T>(d.rows, d.cols, (T*)d.data, d.step) {} explicit __CV_GPU_DEPR_BEFORE__ DevMem2D_(const DevMem2D_<U>& d) : PtrStepSz<T>(d.rows, d.cols, (T*)d.data, d.step) {}
} __CV_GPU_DEPR_AFTER__ ; } __CV_GPU_DEPR_AFTER__ ;
...@@ -149,6 +149,31 @@ namespace cv ...@@ -149,6 +149,31 @@ namespace cv
typedef DevMem2D_<float> DevMem2Df; typedef DevMem2D_<float> DevMem2Df;
typedef DevMem2D_<int> DevMem2Di; 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_DEPR_BEFORE__ //#undef __CV_GPU_DEPR_BEFORE__
//#undef __CV_GPU_DEPR_AFTER__ //#undef __CV_GPU_DEPR_AFTER__
......
/*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 GpuMaterials 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"
...@@ -74,21 +74,6 @@ void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCo ...@@ -74,21 +74,6 @@ void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCo
} }
} }
// Matx case
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,
Matx<_Tp, _rows, _cols>& dst )
{
if( !(src.Flags & Eigen::RowMajorBit) )
{
dst = Matx<_Tp, _cols, _rows>(static_cast<const _Tp*>(src.data())).t();
}
else
{
dst = Matx<_Tp, _rows, _cols>(static_cast<const _Tp*>(src.data()));
}
}
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>
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 )
......
...@@ -114,8 +114,6 @@ namespace cv { namespace gpu ...@@ -114,8 +114,6 @@ namespace cv { namespace gpu
int multiProcessorCount() const { return multi_processor_count_; } int multiProcessorCount() const { return multi_processor_count_; }
size_t sharedMemPerBlock() const { return sharedMemPerBlock_; }
size_t freeMemory() const; size_t freeMemory() const;
size_t totalMemory() const; size_t totalMemory() const;
...@@ -137,7 +135,6 @@ namespace cv { namespace gpu ...@@ -137,7 +135,6 @@ namespace cv { namespace gpu
int multi_processor_count_; int multi_processor_count_;
int majorVersion_; int majorVersion_;
int minorVersion_; int minorVersion_;
size_t sharedMemPerBlock_;
}; };
CV_EXPORTS void printCudaDeviceInfo(int device); CV_EXPORTS void printCudaDeviceInfo(int device);
...@@ -272,7 +269,8 @@ namespace cv { namespace gpu ...@@ -272,7 +269,8 @@ namespace cv { namespace gpu
template <typename _Tp> operator PtrStep<_Tp>() const; template <typename _Tp> operator PtrStep<_Tp>() const;
// Deprecated function // Deprecated function
__CV_GPU_DEPR_BEFORE__ template <typename _Tp> operator DevMem2D_<_Tp>() const __CV_GPU_DEPR_AFTER__; __CV_GPU_DEPR_BEFORE__ template <typename _Tp> operator DevMem2D_<_Tp>() const __CV_GPU_DEPR_AFTER__;
__CV_GPU_DEPR_BEFORE__ template <typename _Tp> operator PtrStep_<_Tp>() const __CV_GPU_DEPR_AFTER__;
#undef __CV_GPU_DEPR_BEFORE__ #undef __CV_GPU_DEPR_BEFORE__
#undef __CV_GPU_DEPR_AFTER__ #undef __CV_GPU_DEPR_AFTER__
...@@ -499,7 +497,7 @@ namespace cv { namespace gpu ...@@ -499,7 +497,7 @@ namespace cv { namespace gpu
CV_DbgAssert((unsigned)y < (unsigned)rows); CV_DbgAssert((unsigned)y < (unsigned)rows);
return data + step * y; return data + step * y;
} }
inline GpuMat& GpuMat::operator = (Scalar s) inline GpuMat& GpuMat::operator = (Scalar s)
{ {
setTo(s); setTo(s);
...@@ -521,6 +519,11 @@ namespace cv { namespace gpu ...@@ -521,6 +519,11 @@ namespace cv { namespace gpu
return DevMem2D_<T>(rows, cols, (T*)data, step); 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));
}
inline GpuMat createContinuous(int rows, int cols, int type) inline GpuMat createContinuous(int rows, int cols, int type)
{ {
GpuMat m; GpuMat m;
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#define CV_MAJOR_VERSION 2 #define CV_MAJOR_VERSION 2
#define CV_MINOR_VERSION 4 #define CV_MINOR_VERSION 4
#define CV_SUBMINOR_VERSION 9 #define CV_SUBMINOR_VERSION 2
#define CVAUX_STR_EXP(__A) #__A #define CVAUX_STR_EXP(__A) #__A
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A) #define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
......
This diff is collapsed.
This diff is collapsed.
...@@ -2900,7 +2900,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComp ...@@ -2900,7 +2900,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComp
return *this; return *this;
} }
PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, double retainedVariance) PCA& PCA::computeVar(InputArray _data, InputArray __mean, int flags, double retainedVariance)
{ {
Mat data = _data.getMat(), _mean = __mean.getMat(); Mat data = _data.getMat(), _mean = __mean.getMat();
int covar_flags = CV_COVAR_SCALE; int covar_flags = CV_COVAR_SCALE;
...@@ -3073,7 +3073,7 @@ void cv::PCACompute(InputArray data, InputOutputArray mean, ...@@ -3073,7 +3073,7 @@ void cv::PCACompute(InputArray data, InputOutputArray mean,
pca.eigenvectors.copyTo(eigenvectors); pca.eigenvectors.copyTo(eigenvectors);
} }
void cv::PCACompute(InputArray data, InputOutputArray mean, void cv::PCAComputeVar(InputArray data, InputOutputArray mean,
OutputArray eigenvectors, double retainedVariance) OutputArray eigenvectors, double retainedVariance)
{ {
PCA pca; PCA pca;
......
...@@ -312,6 +312,7 @@ int cv::getNumThreads(void) ...@@ -312,6 +312,7 @@ int cv::getNumThreads(void)
void cv::setNumThreads( int threads ) void cv::setNumThreads( int threads )
{ {
(void)threads;
#ifdef HAVE_PARALLEL_FRAMEWORK #ifdef HAVE_PARALLEL_FRAMEWORK
numThreads = threads; numThreads = threads;
#endif #endif
......
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