# ocv_create_module(SKIP_LINK)
macro(ocv_create_module)
add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES})
+ if(NOT the_module STREQUAL opencv_ts)
+ set_target_properties(${the_module} PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL)
+ endif()
if(NOT "${ARGN}" STREQUAL "SKIP_LINK")
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
)
endif()
- set_target_properties(${the_module} PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL)
-
if(BUILD_SHARED_LIBS)
if(MSVC)
set_target_properties(${the_module} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
LIST(APPEND ${_out_compile_flags} "-fPIC")
ENDIF()
+ GET_TARGET_PROPERTY(_target_definitions ${_PCH_current_target} COMPILE_DEFINITIONS)
+ if(_target_definitions)
+ foreach(_def ${_target_definitions})
+ LIST(APPEND ${_out_compile_flags} "-D${_def}")
+ endforeach()
+ endif()
+
ELSE()
## TODO ... ? or does it work out of the box
ENDIF()
:param argv:
:param keys:
- .. ocv:function:: template<typename T> T CommandLineParser::get<T>(const std::string& name, bool space_delete = true)
+ .. ocv:function:: template<typename T> T CommandLineParser::get<T>(const cv::String& name, bool space_delete = true)
:param name:
:param space_delete:
:param index:
:param space_delete:
- .. ocv:function:: bool CommandLineParser::has(const std::string& name)
+ .. ocv:function:: bool CommandLineParser::has(const cv::String& name)
:param name:
.. ocv:function:: void CommandLineParser::printErrors()
- .. ocv:function:: std::string CommandLineParser::getPathToApplication()
+ .. ocv:function:: cv::String CommandLineParser::getPathToApplication()
The sample below demonstrates how to use CommandLineParser:
int N = parser.get<int>("N");
double fps = parser.get<double>("fps");
- std::string path = parser.get<std::string>("path");
+ cv::String path = parser.get<cv::String>("path");
use_time_stamp = parser.has("timestamp");
- std::string img1 = parser.get<string>(0);
- std::string img2 = parser.get<string>(1);
+ cv::String img1 = parser.get<string>(0);
+ cv::String img2 = parser.get<string>(1);
int repeat = parser.get<int>(2);
::
- const std::string keys =
+ const cv::String keys =
"{help h usage ? | | print this message }"
"{@image1 | | image1 for compare }"
"{@image2 | | image2 for compare }"
-------------------
Returns full configuration time cmake output.
-.. ocv:function:: const std::string& getBuildInformation()
+.. ocv:function:: const cv::String& getBuildInformation()
Returned value is raw cmake output including version control system revision, compiler version, compiler flags, enabled modules and third party libraries, etc. Output format depends on target architecture.
// first method: use (type) operator on FileNode.
int frameCount = (int)fs2["frameCount"];
- std::string date;
+ cv::String date;
// second method: use FileNode::operator >>
fs2["calibrationDate"] >> date;
:returns: The node content as double.
-FileNode::operator std::string
+FileNode::operator cv::String
------------------------------
Returns the node content as text string.
-.. ocv:function:: FileNode::operator std::string() const
+.. ocv:function:: FileNode::operator cv::String() const
:returns: The node content as a text string.
Full constructor. Normally the constuctor is not called explicitly.
Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used.
*/
- Exception(int _code, const std::string& _err, const std::string& _func, const std::string& _file, int _line);
+ Exception(int _code, const cv::String& _err, const cv::String& _func, const cv::String& _file, int _line);
virtual ~Exception() throw();
/*!
virtual const char *what() const throw();
void formatMessage();
- std::string msg; ///< the formatted error message
+ cv::String msg; ///< the formatted error message
int code; ///< error code @see CVStatus
- std::string err; ///< error description
- std::string func; ///< function name. Available only when the compiler supports __func__ macro
- std::string file; ///< source file name where the error has occured
+ cv::String err; ///< error description
+ cv::String func; ///< function name. Available only when the compiler supports __func__ macro
+ cv::String file; ///< source file name where the error has occured
int line; ///< line number in the source file where the error has occured
};
};
//! renders text string in the image
-CV_EXPORTS_W void putText( Mat& img, const std::string& text, Point org,
+CV_EXPORTS_W void putText( Mat& img, const cv::String& text, Point org,
int fontFace, double fontScale, Scalar color,
int thickness=1, int lineType=8,
bool bottomLeftOrigin=false );
//! returns bounding box of the text string
-CV_EXPORTS_W Size getTextSize(const std::string& text, int fontFace,
+CV_EXPORTS_W Size getTextSize(const cv::String& text, int fontFace,
double fontScale, int thickness,
CV_OUT int* baseLine);
FileStorage fs("test.yml", FileStorage::READ);
int test_int = (int)fs["test_int"];
double test_real = (double)fs["test_real"];
- std::string test_string = (std::string)fs["test_string"];
+ cv::String test_string = (cv::String)fs["test_string"];
Mat M;
fs["test_mat"] >> M;
int tl1 = (int)tl[1];
double tl2 = (double)tl[2];
int tl3 = (int)tl[3];
- std::string tl4 = (std::string)tl[4];
+ cv::String tl4 = (cv::String)tl[4];
CV_Assert(tl[5].type() == FileNode::MAP && tl[5].size() == 3);
int month = (int)tl[5]["month"];
//! the default constructor
CV_WRAP FileStorage();
//! the full constructor that opens file storage for reading or writing
- CV_WRAP FileStorage(const std::string& source, int flags, const std::string& encoding=std::string());
+ CV_WRAP FileStorage(const cv::String& source, int flags, const cv::String& encoding=cv::String());
//! the constructor that takes pointer to the C FileStorage structure
FileStorage(CvFileStorage* fs);
//! the destructor. calls release()
virtual ~FileStorage();
//! opens file storage for reading or writing. The previous storage is closed with release()
- CV_WRAP virtual bool open(const std::string& filename, int flags, const std::string& encoding=std::string());
+ CV_WRAP virtual bool open(const cv::String& filename, int flags, const cv::String& encoding=cv::String());
//! returns true if the object is associated with currently opened file.
CV_WRAP virtual bool isOpened() const;
//! closes the file and releases all the memory buffers
CV_WRAP virtual void release();
//! closes the file, releases all the memory buffers and returns the text string
- CV_WRAP virtual std::string releaseAndGetString();
+ CV_WRAP virtual cv::String releaseAndGetString();
//! returns the first element of the top-level mapping
CV_WRAP FileNode getFirstTopLevelNode() const;
//! returns the top-level mapping. YAML supports multiple streams
CV_WRAP FileNode root(int streamidx=0) const;
//! returns the specified element of the top-level mapping
- FileNode operator[](const std::string& nodename) const;
+ FileNode operator[](const cv::String& nodename) const;
//! returns the specified element of the top-level mapping
CV_WRAP FileNode operator[](const char* nodename) const;
//! returns pointer to the underlying C FileStorage structure
const CvFileStorage* operator *() const { return fs; }
//! writes one or more numbers of the specified format to the currently written structure
- void writeRaw( const std::string& fmt, const uchar* vec, size_t len );
+ void writeRaw( const cv::String& fmt, const uchar* vec, size_t len );
//! writes the registered C structure (CvMat, CvMatND, CvSeq). See cvWrite()
- void writeObj( const std::string& name, const void* obj );
+ void writeObj( const cv::String& name, const void* obj );
//! returns the normalized object name for the specified file name
- static std::string getDefaultObjectName(const std::string& filename);
+ static cv::String getDefaultObjectName(const cv::String& filename);
Ptr<CvFileStorage> fs; //!< the underlying C FileStorage structure
- std::string elname; //!< the currently written element
+ cv::String elname; //!< the currently written element
std::vector<char> structs; //!< the stack of written structures
int state; //!< the writer state
};
//! the copy constructor
FileNode(const FileNode& node);
//! returns element of a mapping node
- FileNode operator[](const std::string& nodename) const;
+ FileNode operator[](const cv::String& nodename) const;
//! returns element of a mapping node
CV_WRAP FileNode operator[](const char* nodename) const;
//! returns element of a sequence node
//! returns true if the node has a name
CV_WRAP bool isNamed() const;
//! returns the node name or an empty string if the node is nameless
- CV_WRAP std::string name() const;
+ CV_WRAP cv::String name() const;
//! returns the number of elements in the node, if it is a sequence or mapping, or 1 otherwise.
CV_WRAP size_t size() const;
//! returns the node content as an integer. If the node stores floating-point number, it is rounded.
FileNodeIterator end() const;
//! reads node elements to the buffer with the specified format
- void readRaw( const std::string& fmt, uchar* vec, size_t len ) const;
+ void readRaw( const cv::String& fmt, uchar* vec, size_t len ) const;
//! reads the registered object and returns pointer to it
void* readObj() const;
FileNodeIterator& operator -= (int ofs);
//! reads the next maxCount elements (or less, if the sequence/mapping last element occurs earlier) to the buffer with the specified format
- FileNodeIterator& readRaw( const std::string& fmt, uchar* vec,
+ FileNodeIterator& readRaw( const cv::String& fmt, uchar* vec,
size_t maxCount=(size_t)INT_MAX );
const CvFileStorage* fs;
public:
Algorithm();
virtual ~Algorithm();
- std::string name() const;
+ cv::String name() const;
- template<typename _Tp> typename ParamType<_Tp>::member_type get(const std::string& name) const;
+ template<typename _Tp> typename ParamType<_Tp>::member_type get(const cv::String& name) const;
template<typename _Tp> typename ParamType<_Tp>::member_type get(const char* name) const;
- CV_WRAP int getInt(const std::string& name) const;
- CV_WRAP double getDouble(const std::string& name) const;
- CV_WRAP bool getBool(const std::string& name) const;
- CV_WRAP std::string getString(const std::string& name) const;
- CV_WRAP Mat getMat(const std::string& name) const;
- CV_WRAP std::vector<Mat> getMatVector(const std::string& name) const;
- CV_WRAP Ptr<Algorithm> getAlgorithm(const std::string& name) const;
-
- void set(const std::string& name, int value);
- void set(const std::string& name, double value);
- void set(const std::string& name, bool value);
- void set(const std::string& name, const std::string& value);
- void set(const std::string& name, const Mat& value);
- void set(const std::string& name, const std::vector<Mat>& value);
- void set(const std::string& name, const Ptr<Algorithm>& value);
- template<typename _Tp> void set(const std::string& name, const Ptr<_Tp>& value);
-
- CV_WRAP void setInt(const std::string& name, int value);
- CV_WRAP void setDouble(const std::string& name, double value);
- CV_WRAP void setBool(const std::string& name, bool value);
- CV_WRAP void setString(const std::string& name, const std::string& value);
- CV_WRAP void setMat(const std::string& name, const Mat& value);
- CV_WRAP void setMatVector(const std::string& name, const std::vector<Mat>& value);
- CV_WRAP void setAlgorithm(const std::string& name, const Ptr<Algorithm>& value);
- template<typename _Tp> void setAlgorithm(const std::string& name, const Ptr<_Tp>& value);
+ CV_WRAP int getInt(const cv::String& name) const;
+ CV_WRAP double getDouble(const cv::String& name) const;
+ CV_WRAP bool getBool(const cv::String& name) const;
+ CV_WRAP cv::String getString(const cv::String& name) const;
+ CV_WRAP Mat getMat(const cv::String& name) const;
+ CV_WRAP std::vector<Mat> getMatVector(const cv::String& name) const;
+ CV_WRAP Ptr<Algorithm> getAlgorithm(const cv::String& name) const;
+
+ void set(const cv::String& name, int value);
+ void set(const cv::String& name, double value);
+ void set(const cv::String& name, bool value);
+ void set(const cv::String& name, const cv::String& value);
+ void set(const cv::String& name, const Mat& value);
+ void set(const cv::String& name, const std::vector<Mat>& value);
+ void set(const cv::String& name, const Ptr<Algorithm>& value);
+ template<typename _Tp> void set(const cv::String& name, const Ptr<_Tp>& value);
+
+ CV_WRAP void setInt(const cv::String& name, int value);
+ CV_WRAP void setDouble(const cv::String& name, double value);
+ CV_WRAP void setBool(const cv::String& name, bool value);
+ CV_WRAP void setString(const cv::String& name, const cv::String& value);
+ CV_WRAP void setMat(const cv::String& name, const Mat& value);
+ CV_WRAP void setMatVector(const cv::String& name, const std::vector<Mat>& value);
+ CV_WRAP void setAlgorithm(const cv::String& name, const Ptr<Algorithm>& value);
+ template<typename _Tp> void setAlgorithm(const cv::String& name, const Ptr<_Tp>& value);
void set(const char* name, int value);
void set(const char* name, double value);
void set(const char* name, bool value);
- void set(const char* name, const std::string& value);
+ void set(const char* name, const cv::String& value);
void set(const char* name, const Mat& value);
void set(const char* name, const std::vector<Mat>& value);
void set(const char* name, const Ptr<Algorithm>& value);
void setInt(const char* name, int value);
void setDouble(const char* name, double value);
void setBool(const char* name, bool value);
- void setString(const char* name, const std::string& value);
+ void setString(const char* name, const cv::String& value);
void setMat(const char* name, const Mat& value);
void setMatVector(const char* name, const std::vector<Mat>& value);
void setAlgorithm(const char* name, const Ptr<Algorithm>& value);
template<typename _Tp> void setAlgorithm(const char* name, const Ptr<_Tp>& value);
- CV_WRAP std::string paramHelp(const std::string& name) const;
+ CV_WRAP cv::String paramHelp(const cv::String& name) const;
int paramType(const char* name) const;
- CV_WRAP int paramType(const std::string& name) const;
- CV_WRAP void getParams(CV_OUT std::vector<std::string>& names) const;
+ CV_WRAP int paramType(const cv::String& name) const;
+ CV_WRAP void getParams(CV_OUT std::vector<cv::String>& names) const;
virtual void write(FileStorage& fs) const;
typedef int (Algorithm::*Getter)() const;
typedef void (Algorithm::*Setter)(int);
- CV_WRAP static void getList(CV_OUT std::vector<std::string>& algorithms);
- CV_WRAP static Ptr<Algorithm> _create(const std::string& name);
- template<typename _Tp> static Ptr<_Tp> create(const std::string& name);
+ CV_WRAP static void getList(CV_OUT std::vector<cv::String>& algorithms);
+ CV_WRAP static Ptr<Algorithm> _create(const cv::String& name);
+ template<typename _Tp> static Ptr<_Tp> create(const cv::String& name);
virtual AlgorithmInfo* info() const /* TODO: make it = 0;*/ { return 0; }
};
{
public:
friend class Algorithm;
- AlgorithmInfo(const std::string& name, Algorithm::Constructor create);
+ AlgorithmInfo(const cv::String& name, Algorithm::Constructor create);
~AlgorithmInfo();
void get(const Algorithm* algo, const char* name, int argType, void* value) const;
void addParam_(Algorithm& algo, const char* name, int argType,
void* value, bool readOnly,
Algorithm::Getter getter, Algorithm::Setter setter,
- const std::string& help=std::string());
- std::string paramHelp(const char* name) const;
+ const cv::String& help=cv::String());
+ cv::String paramHelp(const char* name) const;
int paramType(const char* name) const;
- void getParams(std::vector<std::string>& names) const;
+ void getParams(std::vector<cv::String>& names) const;
void write(const Algorithm* algo, FileStorage& fs) const;
void read(Algorithm* algo, const FileNode& fn) const;
- std::string name() const;
+ cv::String name() const;
void addParam(Algorithm& algo, const char* name,
int& value, bool readOnly=false,
int (Algorithm::*getter)()=0,
void (Algorithm::*setter)(int)=0,
- const std::string& help=std::string());
+ const cv::String& help=cv::String());
void addParam(Algorithm& algo, const char* name,
bool& value, bool readOnly=false,
int (Algorithm::*getter)()=0,
void (Algorithm::*setter)(int)=0,
- const std::string& help=std::string());
+ const cv::String& help=cv::String());
void addParam(Algorithm& algo, const char* name,
double& value, bool readOnly=false,
double (Algorithm::*getter)()=0,
void (Algorithm::*setter)(double)=0,
- const std::string& help=std::string());
+ const cv::String& help=cv::String());
void addParam(Algorithm& algo, const char* name,
- std::string& value, bool readOnly=false,
- std::string (Algorithm::*getter)()=0,
- void (Algorithm::*setter)(const std::string&)=0,
- const std::string& help=std::string());
+ cv::String& value, bool readOnly=false,
+ cv::String (Algorithm::*getter)()=0,
+ void (Algorithm::*setter)(const cv::String&)=0,
+ const cv::String& help=cv::String());
void addParam(Algorithm& algo, const char* name,
Mat& value, bool readOnly=false,
Mat (Algorithm::*getter)()=0,
void (Algorithm::*setter)(const Mat&)=0,
- const std::string& help=std::string());
+ const cv::String& help=cv::String());
void addParam(Algorithm& algo, const char* name,
std::vector<Mat>& value, bool readOnly=false,
std::vector<Mat> (Algorithm::*getter)()=0,
void (Algorithm::*setter)(const std::vector<Mat>&)=0,
- const std::string& help=std::string());
+ const cv::String& help=cv::String());
void addParam(Algorithm& algo, const char* name,
Ptr<Algorithm>& value, bool readOnly=false,
Ptr<Algorithm> (Algorithm::*getter)()=0,
void (Algorithm::*setter)(const Ptr<Algorithm>&)=0,
- const std::string& help=std::string());
+ const cv::String& help=cv::String());
void addParam(Algorithm& algo, const char* name,
float& value, bool readOnly=false,
float (Algorithm::*getter)()=0,
void (Algorithm::*setter)(float)=0,
- const std::string& help=std::string());
+ const cv::String& help=cv::String());
void addParam(Algorithm& algo, const char* name,
unsigned int& value, bool readOnly=false,
unsigned int (Algorithm::*getter)()=0,
void (Algorithm::*setter)(unsigned int)=0,
- const std::string& help=std::string());
+ const cv::String& help=cv::String());
void addParam(Algorithm& algo, const char* name,
uint64& value, bool readOnly=false,
uint64 (Algorithm::*getter)()=0,
void (Algorithm::*setter)(uint64)=0,
- const std::string& help=std::string());
+ const cv::String& help=cv::String());
void addParam(Algorithm& algo, const char* name,
uchar& value, bool readOnly=false,
uchar (Algorithm::*getter)()=0,
void (Algorithm::*setter)(uchar)=0,
- const std::string& help=std::string());
+ const cv::String& help=cv::String());
template<typename _Tp, typename _Base> void addParam(Algorithm& algo, const char* name,
Ptr<_Tp>& value, bool readOnly=false,
Ptr<_Tp> (Algorithm::*getter)()=0,
void (Algorithm::*setter)(const Ptr<_Tp>&)=0,
- const std::string& help=std::string());
+ const cv::String& help=cv::String());
template<typename _Tp> void addParam(Algorithm& algo, const char* name,
Ptr<_Tp>& value, bool readOnly=false,
Ptr<_Tp> (Algorithm::*getter)()=0,
void (Algorithm::*setter)(const Ptr<_Tp>&)=0,
- const std::string& help=std::string());
+ const cv::String& help=cv::String());
protected:
AlgorithmInfoData* data;
void set(Algorithm* algo, const char* name, int argType,
Param(int _type, bool _readonly, int _offset,
Algorithm::Getter _getter=0,
Algorithm::Setter _setter=0,
- const std::string& _help=std::string());
+ const cv::String& _help=cv::String());
int type;
int offset;
bool readonly;
Algorithm::Getter getter;
Algorithm::Setter setter;
- std::string help;
+ cv::String help;
};
template<> struct ParamType<bool>
enum { type = Param::REAL };
};
-template<> struct ParamType<std::string>
+template<> struct ParamType<cv::String>
{
- typedef const std::string& const_param_type;
- typedef std::string member_type;
+ typedef const cv::String& const_param_type;
+ typedef cv::String member_type;
enum { type = Param::STRING };
};
// Creates DeviceInfo object for the given GPU
DeviceInfo(int device_id) : device_id_(device_id) { query(); }
- std::string name() const { return name_; }
+ cv::String name() const { return name_; }
// Return compute capability versions
int majorVersion() const { return majorVersion_; }
int device_id_;
- std::string name_;
+ cv::String name_;
int multi_processor_count_;
int majorVersion_;
int minorVersion_;
//////////////////////////////////////// XML & YAML I/O ////////////////////////////////////
-CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, int value );
-CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, float value );
-CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, double value );
-CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, const std::string& value );
+CV_EXPORTS_W void write( FileStorage& fs, const cv::String& name, int value );
+CV_EXPORTS_W void write( FileStorage& fs, const cv::String& name, float value );
+CV_EXPORTS_W void write( FileStorage& fs, const cv::String& name, double value );
+CV_EXPORTS_W void write( FileStorage& fs, const cv::String& name, const cv::String& value );
template<typename _Tp> inline void write(FileStorage& fs, const _Tp& value)
-{ write(fs, std::string(), value); }
+{ write(fs, cv::String(), value); }
CV_EXPORTS void writeScalar( FileStorage& fs, int value );
CV_EXPORTS void writeScalar( FileStorage& fs, float value );
CV_EXPORTS void writeScalar( FileStorage& fs, double value );
-CV_EXPORTS void writeScalar( FileStorage& fs, const std::string& value );
+CV_EXPORTS void writeScalar( FileStorage& fs, const cv::String& value );
template<> inline void write( FileStorage& fs, const int& value )
{
writeScalar(fs, value);
}
-template<> inline void write( FileStorage& fs, const std::string& value )
+template<> inline void write( FileStorage& fs, const cv::String& value )
{
writeScalar(fs, value);
}
class CV_EXPORTS WriteStructContext
{
public:
- WriteStructContext(FileStorage& _fs, const std::string& name,
- int flags, const std::string& typeName=std::string());
+ WriteStructContext(FileStorage& _fs, const cv::String& name,
+ int flags, const cv::String& typeName=cv::String());
~WriteStructContext();
FileStorage* fs;
};
-template<typename _Tp> inline void write(FileStorage& fs, const std::string& name, const Point_<_Tp>& pt )
+template<typename _Tp> inline void write(FileStorage& fs, const cv::String& name, const Point_<_Tp>& pt )
{
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
write(fs, pt.x);
write(fs, pt.y);
}
-template<typename _Tp> inline void write(FileStorage& fs, const std::string& name, const Point3_<_Tp>& pt )
+template<typename _Tp> inline void write(FileStorage& fs, const cv::String& name, const Point3_<_Tp>& pt )
{
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
write(fs, pt.x);
write(fs, pt.z);
}
-template<typename _Tp> inline void write(FileStorage& fs, const std::string& name, const Size_<_Tp>& sz )
+template<typename _Tp> inline void write(FileStorage& fs, const cv::String& name, const Size_<_Tp>& sz )
{
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
write(fs, sz.width);
write(fs, sz.height);
}
-template<typename _Tp> inline void write(FileStorage& fs, const std::string& name, const Complex<_Tp>& c )
+template<typename _Tp> inline void write(FileStorage& fs, const cv::String& name, const Complex<_Tp>& c )
{
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
write(fs, c.re);
write(fs, c.im);
}
-template<typename _Tp> inline void write(FileStorage& fs, const std::string& name, const Rect_<_Tp>& r )
+template<typename _Tp> inline void write(FileStorage& fs, const cv::String& name, const Rect_<_Tp>& r )
{
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
write(fs, r.x);
write(fs, r.height);
}
-template<typename _Tp, int cn> inline void write(FileStorage& fs, const std::string& name, const Vec<_Tp, cn>& v )
+template<typename _Tp, int cn> inline void write(FileStorage& fs, const cv::String& name, const Vec<_Tp, cn>& v )
{
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
for(int i = 0; i < cn; i++)
write(fs, v.val[i]);
}
-template<typename _Tp> inline void write(FileStorage& fs, const std::string& name, const Scalar_<_Tp>& s )
+template<typename _Tp> inline void write(FileStorage& fs, const cv::String& name, const Scalar_<_Tp>& s )
{
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
write(fs, s.val[0]);
write(fs, s.val[3]);
}
-inline void write(FileStorage& fs, const std::string& name, const Range& r )
+inline void write(FileStorage& fs, const cv::String& name, const Range& r )
{
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
write(fs, r.start);
{
int _fmt = DataType<_Tp>::fmt;
char fmt[] = { (char)((_fmt>>8)+'1'), (char)_fmt, '\0' };
- fs->writeRaw( std::string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, vec.size()*sizeof(_Tp) );
+ fs->writeRaw( cv::String(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, vec.size()*sizeof(_Tp) );
}
FileStorage* fs;
};
w(vec);
}
-template<typename _Tp> static inline void write( FileStorage& fs, const std::string& name,
+template<typename _Tp> static inline void write( FileStorage& fs, const cv::String& name,
const std::vector<_Tp>& vec )
{
WriteStructContext ws(fs, name, CV_NODE_SEQ+(DataType<_Tp>::fmt != 0 ? CV_NODE_FLOW : 0));
write(fs, vec);
}
-CV_EXPORTS_W void write( FileStorage& fs, const std::string& name, const Mat& value );
-CV_EXPORTS void write( FileStorage& fs, const std::string& name, const SparseMat& value );
+CV_EXPORTS_W void write( FileStorage& fs, const cv::String& name, const Mat& value );
+CV_EXPORTS void write( FileStorage& fs, const cv::String& name, const SparseMat& value );
template<typename _Tp> static inline FileStorage& operator << (FileStorage& fs, const _Tp& value)
{
return fs;
}
-CV_EXPORTS FileStorage& operator << (FileStorage& fs, const std::string& str);
+CV_EXPORTS FileStorage& operator << (FileStorage& fs, const cv::String& str);
static inline FileStorage& operator << (FileStorage& fs, const char* str)
-{ return (fs << std::string(str)); }
+{ return (fs << cv::String(str)); }
inline FileNode::FileNode() : fs(0), node(0) {}
inline FileNode::FileNode(const CvFileStorage* _fs, const CvFileNode* _node)
read(*this, value, 0.);
return value;
}
-inline FileNode::operator std::string() const
+inline FileNode::operator cv::String() const
{
- std::string value;
+ cv::String value;
read(*this, value, value);
return value;
}
size_t remaining1 = remaining/cn;
count = count < remaining1 ? count : remaining1;
vec.resize(count);
- it->readRaw( std::string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, count*sizeof(_Tp) );
+ it->readRaw( cv::String(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, count*sizeof(_Tp) );
}
FileNodeIterator* it;
};
{
FileStorage fs(_fs);
fs.fs.addref();
- ((const _ClsName*)ptr)->write(fs, std::string(name));
+ ((const _ClsName*)ptr)->write(fs, cv::String(name));
}
}
}
-template<typename _Tp> inline Ptr<_Tp> Algorithm::create(const std::string& name)
+template<typename _Tp> inline Ptr<_Tp> Algorithm::create(const cv::String& name)
{
return _create(name).ptr<_Tp>();
}
}
template<typename _Tp>
-inline void Algorithm::set(const std::string& _name, const Ptr<_Tp>& value)
+inline void Algorithm::set(const cv::String& _name, const Ptr<_Tp>& value)
{
this->set<_Tp>(_name.c_str(), value);
}
}
template<typename _Tp>
-inline void Algorithm::setAlgorithm(const std::string& _name, const Ptr<_Tp>& value)
+inline void Algorithm::setAlgorithm(const cv::String& _name, const Ptr<_Tp>& value)
{
this->set<_Tp>(_name.c_str(), value);
}
-template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const std::string& _name) const
+template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const cv::String& _name) const
{
typename ParamType<_Tp>::member_type value;
info()->get(this, _name.c_str(), ParamType<_Tp>::type, &value);
template<typename _Tp, typename _Base> inline void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
Ptr<_Tp>& value, bool readOnly, Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&),
- const std::string& help)
+ const cv::String& help)
{
//TODO: static assert: _Tp inherits from _Base
addParam_(algo, parameter, ParamType<_Base>::type, &value, readOnly,
template<typename _Tp> inline void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
Ptr<_Tp>& value, bool readOnly, Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&),
- const std::string& help)
+ const cv::String& help)
{
//TODO: static assert: _Tp inherits from Algorithm
addParam_(algo, parameter, ParamType<Algorithm>::type, &value, readOnly,
};
-template<typename _ValueTp> inline const _ValueTp* findstr(const sorted_vector<std::string, _ValueTp>& vec,
+template<typename _ValueTp> inline const _ValueTp* findstr(const sorted_vector<cv::String, _ValueTp>& vec,
const char* key)
{
if( !key )
Param::Param(int _type, bool _readonly, int _offset,
Algorithm::Getter _getter, Algorithm::Setter _setter,
- const std::string& _help)
+ const cv::String& _help)
{
type = _type;
readonly = _readonly;
struct CV_EXPORTS AlgorithmInfoData
{
- sorted_vector<std::string, Param> params;
- std::string _name;
+ sorted_vector<cv::String, Param> params;
+ cv::String _name;
};
-static sorted_vector<std::string, Algorithm::Constructor>& alglist()
+static sorted_vector<cv::String, Algorithm::Constructor>& alglist()
{
- static sorted_vector<std::string, Algorithm::Constructor> alglist_var;
+ static sorted_vector<cv::String, Algorithm::Constructor> alglist_var;
return alglist_var;
}
-void Algorithm::getList(std::vector<std::string>& algorithms)
+void Algorithm::getList(std::vector<cv::String>& algorithms)
{
alglist().get_keys(algorithms);
}
-Ptr<Algorithm> Algorithm::_create(const std::string& name)
+Ptr<Algorithm> Algorithm::_create(const cv::String& name)
{
Algorithm::Constructor c = 0;
if( !alglist().find(name, c) )
{
}
-std::string Algorithm::name() const
+cv::String Algorithm::name() const
{
return info()->name();
}
-void Algorithm::set(const std::string& parameter, int value)
+void Algorithm::set(const cv::String& parameter, int value)
{
info()->set(this, parameter.c_str(), ParamType<int>::type, &value);
}
-void Algorithm::set(const std::string& parameter, double value)
+void Algorithm::set(const cv::String& parameter, double value)
{
info()->set(this, parameter.c_str(), ParamType<double>::type, &value);
}
-void Algorithm::set(const std::string& parameter, bool value)
+void Algorithm::set(const cv::String& parameter, bool value)
{
info()->set(this, parameter.c_str(), ParamType<bool>::type, &value);
}
-void Algorithm::set(const std::string& parameter, const std::string& value)
+void Algorithm::set(const cv::String& parameter, const cv::String& value)
{
- info()->set(this, parameter.c_str(), ParamType<std::string>::type, &value);
+ info()->set(this, parameter.c_str(), ParamType<cv::String>::type, &value);
}
-void Algorithm::set(const std::string& parameter, const Mat& value)
+void Algorithm::set(const cv::String& parameter, const Mat& value)
{
info()->set(this, parameter.c_str(), ParamType<Mat>::type, &value);
}
-void Algorithm::set(const std::string& parameter, const std::vector<Mat>& value)
+void Algorithm::set(const cv::String& parameter, const std::vector<Mat>& value)
{
info()->set(this, parameter.c_str(), ParamType<std::vector<Mat> >::type, &value);
}
-void Algorithm::set(const std::string& parameter, const Ptr<Algorithm>& value)
+void Algorithm::set(const cv::String& parameter, const Ptr<Algorithm>& value)
{
info()->set(this, parameter.c_str(), ParamType<Algorithm>::type, &value);
}
info()->set(this, parameter, ParamType<bool>::type, &value);
}
-void Algorithm::set(const char* parameter, const std::string& value)
+void Algorithm::set(const char* parameter, const cv::String& value)
{
- info()->set(this, parameter, ParamType<std::string>::type, &value);
+ info()->set(this, parameter, ParamType<cv::String>::type, &value);
}
void Algorithm::set(const char* parameter, const Mat& value)
}
-void Algorithm::setInt(const std::string& parameter, int value)
+void Algorithm::setInt(const cv::String& parameter, int value)
{
info()->set(this, parameter.c_str(), ParamType<int>::type, &value);
}
-void Algorithm::setDouble(const std::string& parameter, double value)
+void Algorithm::setDouble(const cv::String& parameter, double value)
{
info()->set(this, parameter.c_str(), ParamType<double>::type, &value);
}
-void Algorithm::setBool(const std::string& parameter, bool value)
+void Algorithm::setBool(const cv::String& parameter, bool value)
{
info()->set(this, parameter.c_str(), ParamType<bool>::type, &value);
}
-void Algorithm::setString(const std::string& parameter, const std::string& value)
+void Algorithm::setString(const cv::String& parameter, const cv::String& value)
{
- info()->set(this, parameter.c_str(), ParamType<std::string>::type, &value);
+ info()->set(this, parameter.c_str(), ParamType<cv::String>::type, &value);
}
-void Algorithm::setMat(const std::string& parameter, const Mat& value)
+void Algorithm::setMat(const cv::String& parameter, const Mat& value)
{
info()->set(this, parameter.c_str(), ParamType<Mat>::type, &value);
}
-void Algorithm::setMatVector(const std::string& parameter, const std::vector<Mat>& value)
+void Algorithm::setMatVector(const cv::String& parameter, const std::vector<Mat>& value)
{
info()->set(this, parameter.c_str(), ParamType<std::vector<Mat> >::type, &value);
}
-void Algorithm::setAlgorithm(const std::string& parameter, const Ptr<Algorithm>& value)
+void Algorithm::setAlgorithm(const cv::String& parameter, const Ptr<Algorithm>& value)
{
info()->set(this, parameter.c_str(), ParamType<Algorithm>::type, &value);
}
info()->set(this, parameter, ParamType<bool>::type, &value);
}
-void Algorithm::setString(const char* parameter, const std::string& value)
+void Algorithm::setString(const char* parameter, const cv::String& value)
{
- info()->set(this, parameter, ParamType<std::string>::type, &value);
+ info()->set(this, parameter, ParamType<cv::String>::type, &value);
}
void Algorithm::setMat(const char* parameter, const Mat& value)
-int Algorithm::getInt(const std::string& parameter) const
+int Algorithm::getInt(const cv::String& parameter) const
{
return get<int>(parameter);
}
-double Algorithm::getDouble(const std::string& parameter) const
+double Algorithm::getDouble(const cv::String& parameter) const
{
return get<double>(parameter);
}
-bool Algorithm::getBool(const std::string& parameter) const
+bool Algorithm::getBool(const cv::String& parameter) const
{
return get<bool>(parameter);
}
-std::string Algorithm::getString(const std::string& parameter) const
+cv::String Algorithm::getString(const cv::String& parameter) const
{
- return get<std::string>(parameter);
+ return get<cv::String>(parameter);
}
-Mat Algorithm::getMat(const std::string& parameter) const
+Mat Algorithm::getMat(const cv::String& parameter) const
{
return get<Mat>(parameter);
}
-std::vector<Mat> Algorithm::getMatVector(const std::string& parameter) const
+std::vector<Mat> Algorithm::getMatVector(const cv::String& parameter) const
{
return get<std::vector<Mat> >(parameter);
}
-Ptr<Algorithm> Algorithm::getAlgorithm(const std::string& parameter) const
+Ptr<Algorithm> Algorithm::getAlgorithm(const cv::String& parameter) const
{
return get<Algorithm>(parameter);
}
-std::string Algorithm::paramHelp(const std::string& parameter) const
+cv::String Algorithm::paramHelp(const cv::String& parameter) const
{
return info()->paramHelp(parameter.c_str());
}
-int Algorithm::paramType(const std::string& parameter) const
+int Algorithm::paramType(const cv::String& parameter) const
{
return info()->paramType(parameter.c_str());
}
return info()->paramType(parameter);
}
-void Algorithm::getParams(std::vector<std::string>& names) const
+void Algorithm::getParams(std::vector<cv::String>& names) const
{
info()->getParams(names);
}
}
-AlgorithmInfo::AlgorithmInfo(const std::string& _name, Algorithm::Constructor create)
+AlgorithmInfo::AlgorithmInfo(const cv::String& _name, Algorithm::Constructor create)
{
data = new AlgorithmInfoData;
data->_name = _name;
for( i = 0; i < nparams; i++ )
{
const Param& p = data->params.vec[i].second;
- const std::string& pname = data->params.vec[i].first;
+ const cv::String& pname = data->params.vec[i].first;
if( p.type == Param::INT )
cv::write(fs, pname, algo->get<int>(pname));
else if( p.type == Param::BOOLEAN )
else if( p.type == Param::REAL )
cv::write(fs, pname, algo->get<double>(pname));
else if( p.type == Param::STRING )
- cv::write(fs, pname, algo->get<std::string>(pname));
+ cv::write(fs, pname, algo->get<cv::String>(pname));
else if( p.type == Param::MAT )
cv::write(fs, pname, algo->get<Mat>(pname));
else if( p.type == Param::MAT_VECTOR )
cv::write(fs, pname, algo->getInt(pname));
else
{
- std::string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
+ cv::String msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
CV_Error( CV_StsUnsupportedFormat, msg.c_str());
}
}
for( i = 0; i < nparams; i++ )
{
const Param& p = data->params.vec[i].second;
- const std::string& pname = data->params.vec[i].first;
+ const cv::String& pname = data->params.vec[i].first;
const FileNode n = fn[pname];
if( n.empty() )
continue;
}
else if( p.type == Param::STRING )
{
- std::string val = (std::string)n;
+ cv::String val = (cv::String)n;
info->set(algo, pname.c_str(), p.type, &val, true);
}
else if( p.type == Param::MAT )
}
else if( p.type == Param::ALGORITHM )
{
- Ptr<Algorithm> nestedAlgo = Algorithm::_create((std::string)n["name"]);
+ Ptr<Algorithm> nestedAlgo = Algorithm::_create((cv::String)n["name"]);
CV_Assert( !nestedAlgo.empty() );
nestedAlgo->read(n);
info->set(algo, pname.c_str(), p.type, &nestedAlgo, true);
}
else
{
- std::string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
+ cv::String msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
CV_Error( CV_StsUnsupportedFormat, msg.c_str());
}
}
}
-std::string AlgorithmInfo::name() const
+cv::String AlgorithmInfo::name() const
{
return data->_name;
}
int (Algorithm::*get_int)() const;
bool (Algorithm::*get_bool)() const;
double (Algorithm::*get_double)() const;
- std::string (Algorithm::*get_string)() const;
+ cv::String (Algorithm::*get_string)() const;
Mat (Algorithm::*get_mat)() const;
std::vector<Mat> (Algorithm::*get_mat_vector)() const;
Ptr<Algorithm> (Algorithm::*get_algo)() const;
void (Algorithm::*set_int)(int);
void (Algorithm::*set_bool)(bool);
void (Algorithm::*set_double)(double);
- void (Algorithm::*set_string)(const std::string&);
+ void (Algorithm::*set_string)(const cv::String&);
void (Algorithm::*set_mat)(const Mat&);
void (Algorithm::*set_mat_vector)(const std::vector<Mat>&);
void (Algorithm::*set_algo)(const Ptr<Algorithm>&);
void (Algorithm::*set_uchar)(uchar);
};
-static std::string getNameOfType(int argType);
+static cv::String getNameOfType(int argType);
-static std::string getNameOfType(int argType)
+static cv::String getNameOfType(int argType)
{
switch(argType)
{
return "";
}
-static std::string getErrorMessageForWrongArgumentInSetter(std::string algoName, std::string paramName, int paramType, int argType)
+static cv::String getErrorMessageForWrongArgumentInSetter(cv::String algoName, cv::String paramName, int paramType, int argType)
{
- std::string message = std::string("Argument error: the setter")
+ cv::String message = cv::String("Argument error: the setter")
+ " method was called for the parameter '" + paramName + "' of the algorithm '" + algoName
+"', the parameter has " + getNameOfType(paramType) + " type, ";
if (paramType == Param::INT || paramType == Param::BOOLEAN || paramType == Param::REAL
|| paramType == Param::FLOAT || paramType == Param::UNSIGNED_INT || paramType == Param::UINT64 || paramType == Param::UCHAR)
{
- message += "so it should be set by integer, unsigned integer, uint64, unsigned char, boolean, float or double value, ";
+ message = message + "so it should be set by integer, unsigned integer, uint64, unsigned char, boolean, float or double value, ";
}
- message += "but the setter was called with " + getNameOfType(argType) + " value";
+ message = message + "but the setter was called with " + getNameOfType(argType) + " value";
return message;
}
-static std::string getErrorMessageForWrongArgumentInGetter(std::string algoName, std::string paramName, int paramType, int argType)
+static cv::String getErrorMessageForWrongArgumentInGetter(cv::String algoName, cv::String paramName, int paramType, int argType)
{
- std::string message = std::string("Argument error: the getter")
+ cv::String message = cv::String("Argument error: the getter")
+ " method was called for the parameter '" + paramName + "' of the algorithm '" + algoName
+"', the parameter has " + getNameOfType(paramType) + " type, ";
if (paramType == Param::BOOLEAN)
{
- message += "so it should be get as integer, unsigned integer, uint64, boolean, unsigned char, float or double value, ";
+ message = message + "so it should be get as integer, unsigned integer, uint64, boolean, unsigned char, float or double value, ";
}
else if (paramType == Param::INT || paramType == Param::UNSIGNED_INT || paramType == Param::UINT64 || paramType == Param::UCHAR)
{
- message += "so it should be get as integer, unsigned integer, uint64, unsigned char, float or double value, ";
+ message = message + "so it should be get as integer, unsigned integer, uint64, unsigned char, float or double value, ";
}
- message += "but the getter was called to get a " + getNameOfType(argType) + " value";
+ message = message + "but the getter was called to get a " + getNameOfType(argType) + " value";
return message;
}
if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN
|| p->type == Param::UNSIGNED_INT || p->type == Param::UINT64 || p->type == Param::FLOAT || argType == Param::UCHAR) )
{
- std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
{
if( p->type != Param::STRING )
{
- std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
- const std::string& val = *(const std::string*)value;
+ const cv::String& val = *(const cv::String*)value;
if( p->setter )
(algo->*f.set_string)(val);
else
- *(std::string*)((uchar*)algo + p->offset) = val;
+ *(cv::String*)((uchar*)algo + p->offset) = val;
}
else if( argType == Param::MAT )
{
if( p->type != Param::MAT )
{
- std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
{
if( p->type != Param::MAT_VECTOR )
{
- std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
{
if( p->type != Param::ALGORITHM )
{
- std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
{
if (!( argType == Param::INT || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
{
- std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
int val = p->getter ? (algo->*f.get_int)() : *(int*)((uchar*)algo + p->offset);
{
if (!( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
{
- std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
bool val = p->getter ? (algo->*f.get_bool)() : *(bool*)((uchar*)algo + p->offset);
{
if(!( argType == Param::REAL || argType == Param::FLOAT))
{
- std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
double val = p->getter ? (algo->*f.get_double)() : *(double*)((uchar*)algo + p->offset);
{
if(!( argType == Param::REAL || argType == Param::FLOAT))
{
- std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
float val = p->getter ? (algo->*f.get_float)() : *(float*)((uchar*)algo + p->offset);
{
if (!( argType == Param::INT || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
{
- std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
unsigned int val = p->getter ? (algo->*f.get_uint)() : *(unsigned int*)((uchar*)algo + p->offset);
{
if (!( argType == Param::INT || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
{
- std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
uint64 val = p->getter ? (algo->*f.get_uint64)() : *(uint64*)((uchar*)algo + p->offset);
{
if (!( argType == Param::INT || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
{
- std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
uchar val = p->getter ? (algo->*f.get_uchar)() : *(uchar*)((uchar*)algo + p->offset);
{
if( p->type != Param::STRING )
{
- std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
- *(std::string*)value = p->getter ? (algo->*f.get_string)() :
- *(std::string*)((uchar*)algo + p->offset);
+ *(cv::String*)value = p->getter ? (algo->*f.get_string)() :
+ *(cv::String*)((uchar*)algo + p->offset);
}
else if( argType == Param::MAT )
{
if( p->type != Param::MAT )
{
- std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
{
if( p->type != Param::MAT_VECTOR )
{
- std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
{
if( p->type != Param::ALGORITHM )
{
- std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
}
else
{
- std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+ cv::String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);
}
}
}
-std::string AlgorithmInfo::paramHelp(const char* parameter) const
+cv::String AlgorithmInfo::paramHelp(const char* parameter) const
{
const Param* p = findstr(data->params, parameter);
if( !p )
}
-void AlgorithmInfo::getParams(std::vector<std::string>& names) const
+void AlgorithmInfo::getParams(std::vector<cv::String>& names) const
{
data->params.get_keys(names);
}
void AlgorithmInfo::addParam_(Algorithm& algo, const char* parameter, int argType,
void* value, bool readOnly,
Algorithm::Getter getter, Algorithm::Setter setter,
- const std::string& help)
+ const cv::String& help)
{
CV_Assert( argType == Param::INT || argType == Param::BOOLEAN ||
argType == Param::REAL || argType == Param::STRING ||
argType == Param::ALGORITHM
|| argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64
|| argType == Param::UCHAR);
- data->params.add(std::string(parameter), Param(argType, readOnly,
+ data->params.add(cv::String(parameter), Param(argType, readOnly,
(int)((size_t)value - (size_t)(void*)&algo),
getter, setter, help));
}
int& value, bool readOnly,
int (Algorithm::*getter)(),
void (Algorithm::*setter)(int),
- const std::string& help)
+ const cv::String& help)
{
addParam_(algo, parameter, ParamType<int>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
bool& value, bool readOnly,
int (Algorithm::*getter)(),
void (Algorithm::*setter)(int),
- const std::string& help)
+ const cv::String& help)
{
addParam_(algo, parameter, ParamType<bool>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
double& value, bool readOnly,
double (Algorithm::*getter)(),
void (Algorithm::*setter)(double),
- const std::string& help)
+ const cv::String& help)
{
addParam_(algo, parameter, ParamType<double>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
- std::string& value, bool readOnly,
- std::string (Algorithm::*getter)(),
- void (Algorithm::*setter)(const std::string&),
- const std::string& help)
+ cv::String& value, bool readOnly,
+ cv::String (Algorithm::*getter)(),
+ void (Algorithm::*setter)(const cv::String&),
+ const cv::String& help)
{
- addParam_(algo, parameter, ParamType<std::string>::type, &value, readOnly,
+ addParam_(algo, parameter, ParamType<cv::String>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
Mat& value, bool readOnly,
Mat (Algorithm::*getter)(),
void (Algorithm::*setter)(const Mat&),
- const std::string& help)
+ const cv::String& help)
{
addParam_(algo, parameter, ParamType<Mat>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
std::vector<Mat>& value, bool readOnly,
std::vector<Mat> (Algorithm::*getter)(),
void (Algorithm::*setter)(const std::vector<Mat>&),
- const std::string& help)
+ const cv::String& help)
{
addParam_(algo, parameter, ParamType<std::vector<Mat> >::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
Ptr<Algorithm>& value, bool readOnly,
Ptr<Algorithm> (Algorithm::*getter)(),
void (Algorithm::*setter)(const Ptr<Algorithm>&),
- const std::string& help)
+ const cv::String& help)
{
addParam_(algo, parameter, ParamType<Algorithm>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
float& value, bool readOnly,
float (Algorithm::*getter)(),
void (Algorithm::*setter)(float),
- const std::string& help)
+ const cv::String& help)
{
addParam_(algo, parameter, ParamType<float>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
unsigned int& value, bool readOnly,
unsigned int (Algorithm::*getter)(),
void (Algorithm::*setter)(unsigned int),
- const std::string& help)
+ const cv::String& help)
{
addParam_(algo, parameter, ParamType<unsigned int>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
uint64& value, bool readOnly,
uint64 (Algorithm::*getter)(),
void (Algorithm::*setter)(uint64),
- const std::string& help)
+ const cv::String& help)
{
addParam_(algo, parameter, ParamType<uint64>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
uchar& value, bool readOnly,
uchar (Algorithm::*getter)(),
void (Algorithm::*setter)(uchar),
- const std::string& help)
+ const cv::String& help)
{
addParam_(algo, parameter, ParamType<uchar>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
-
#include "precomp.hpp"
-#include <iostream>
-
namespace cv
{
struct CommandLineParserParams
{
public:
- std::string help_message;
- std::string def_value;
- std::vector<std::string> keys;
+ cv::String help_message;
+ cv::String def_value;
+ std::vector<cv::String> keys;
int number;
};
struct CommandLineParser::Impl
{
bool error;
- std::string error_message;
- std::string about_message;
+ cv::String error_message;
+ cv::String about_message;
- std::string path_to_app;
- std::string app_name;
+ cv::String path_to_app;
+ cv::String app_name;
std::vector<CommandLineParserParams> data;
- std::vector<std::string> split_range_string(const std::string& str, char fs, char ss) const;
- std::vector<std::string> split_string(const std::string& str, char symbol = ' ', bool create_empty_item = false) const;
- std::string cat_string(const std::string& str) const;
+ std::vector<cv::String> split_range_string(const cv::String& str, char fs, char ss) const;
+ std::vector<cv::String> split_string(const cv::String& str, char symbol = ' ', bool create_empty_item = false) const;
+ cv::String cat_string(const cv::String& str) const;
- void apply_params(const std::string& key, const std::string& value);
- void apply_params(int i, std::string value);
+ void apply_params(const cv::String& key, const cv::String& value);
+ void apply_params(int i, cv::String value);
void sort_params();
int refcount;
};
-static std::string get_type_name(int type)
+static cv::String get_type_name(int type)
{
if( type == Param::INT )
return "int";
return "unknown";
}
-static void from_str(const std::string& str, int type, void* dst)
+static void from_str(const cv::String& str, int type, void* dst)
{
- std::stringstream ss(str);
+ std::stringstream ss(str.c_str());
if( type == Param::INT )
ss >> *(int*)dst;
else if( type == Param::UNSIGNED_INT )
else if( type == Param::REAL )
ss >> *(double*)dst;
else if( type == Param::STRING )
- *(std::string*)dst = str;
+ *(cv::String*)dst = str;
else
throw cv::Exception(CV_StsBadArg, "unknown/unsupported parameter type", "", __FILE__, __LINE__);
if (ss.fail())
{
- std::string err_msg = "can not convert: [" + str +
+ cv::String err_msg = "can not convert: [" + str +
+ "] to [" + get_type_name(type) + "]";
throw cv::Exception(CV_StsBadArg, err_msg, "", __FILE__, __LINE__);
}
}
-void CommandLineParser::getByName(const std::string& name, bool space_delete, int type, void* dst) const
+void CommandLineParser::getByName(const cv::String& name, bool space_delete, int type, void* dst) const
{
try
{
{
if (name.compare(impl->data[i].keys[j]) == 0)
{
- std::string v = impl->data[i].def_value;
+ cv::String v = impl->data[i].def_value;
if (space_delete)
v = impl->cat_string(v);
from_str(v, type, dst);
}
}
impl->error = true;
- impl->error_message += "Unknown parametes " + name + "\n";
+ impl->error_message = impl->error_message + "Unknown parametes " + name + "\n";
}
catch (std::exception& e)
{
impl->error = true;
- impl->error_message += "Exception: " + std::string(e.what()) + "\n";
+ impl->error_message = impl->error_message + "Exception: " + cv::String(e.what()) + "\n";
}
}
{
if (impl->data[i].number == index)
{
- std::string v = impl->data[i].def_value;
+ cv::String v = impl->data[i].def_value;
if (space_delete == true) v = impl->cat_string(v);
from_str(v, type, dst);
return;
}
}
impl->error = true;
- impl->error_message += "Unknown parametes #" + format("%d", index) + "\n";
+ impl->error_message = impl->error_message + "Unknown parametes #" + format("%d", index) + "\n";
}
catch(std::exception & e)
{
impl->error = true;
- impl->error_message += "Exception: " + std::string(e.what()) + "\n";
+ impl->error_message = impl->error_message + "Exception: " + cv::String(e.what()) + "\n";
}
}
return true;
}
-CommandLineParser::CommandLineParser(int argc, const char* const argv[], const std::string& keys)
+CommandLineParser::CommandLineParser(int argc, const char* const argv[], const cv::String& keys)
{
impl = new Impl;
impl->refcount = 1;
// path to application
- size_t pos_s = std::string(argv[0]).find_last_of("/\\");
- if (pos_s == std::string::npos)
+ size_t pos_s = cv::String(argv[0]).find_last_of("/\\");
+ if (pos_s == cv::String::npos)
{
impl->path_to_app = "";
- impl->app_name = std::string(argv[0]);
+ impl->app_name = cv::String(argv[0]);
}
else
{
- impl->path_to_app = std::string(argv[0]).substr(0, pos_s);
- impl->app_name = std::string(argv[0]).substr(pos_s + 1, std::string(argv[0]).length() - pos_s);
+ impl->path_to_app = cv::String(argv[0]).substr(0, pos_s);
+ impl->app_name = cv::String(argv[0]).substr(pos_s + 1, cv::String(argv[0]).length() - pos_s);
}
impl->error = false;
impl->error_message = "";
// parse keys
- std::vector<std::string> k = impl->split_range_string(keys, '{', '}');
+ std::vector<cv::String> k = impl->split_range_string(keys, '{', '}');
int jj = 0;
for (size_t i = 0; i < k.size(); i++)
{
- std::vector<std::string> l = impl->split_string(k[i], '|', true);
+ std::vector<cv::String> l = impl->split_string(k[i], '|', true);
CommandLineParserParams p;
p.keys = impl->split_string(l[0]);
p.def_value = l[1];
jj = 0;
for (int i = 1; i < argc; i++)
{
- std::string s = std::string(argv[i]);
+ cv::String s = cv::String(argv[i]);
- if (s.find('=') != std::string::npos && s.find('=') < s.length())
+ if (s.find('=') != cv::String::npos && s.find('=') < s.length())
{
- std::vector<std::string> k_v = impl->split_string(s, '=', true);
+ std::vector<cv::String> k_v = impl->split_string(s, '=', true);
for (int h = 0; h < 2; h++)
{
if (k_v[0][0] == '-')
return *this;
}
-void CommandLineParser::about(const std::string& message)
+void CommandLineParser::about(const cv::String& message)
{
impl->about_message = message;
}
-void CommandLineParser::Impl::apply_params(const std::string& key, const std::string& value)
+void CommandLineParser::Impl::apply_params(const cv::String& key, const cv::String& value)
{
for (size_t i = 0; i < data.size(); i++)
{
}
}
-void CommandLineParser::Impl::apply_params(int i, std::string value)
+void CommandLineParser::Impl::apply_params(int i, cv::String value)
{
for (size_t j = 0; j < data.size(); j++)
{
{
for (size_t i = 0; i < data.size(); i++)
{
- sort(data[i].keys.begin(), data[i].keys.end());
+ std::sort(data[i].keys.begin(), data[i].keys.end());
}
std::sort (data.begin(), data.end(), cmp_params);
}
-std::string CommandLineParser::Impl::cat_string(const std::string& str) const
+cv::String CommandLineParser::Impl::cat_string(const cv::String& str) const
{
int left = 0, right = (int)str.length();
while( left <= right && str[left] == ' ' )
left++;
while( right > left && str[right-1] == ' ' )
right--;
- return left >= right ? std::string("") : str.substr(left, right-left);
+ return left >= right ? cv::String("") : str.substr(left, right-left);
}
-std::string CommandLineParser::getPathToApplication() const
+cv::String CommandLineParser::getPathToApplication() const
{
return impl->path_to_app;
}
-bool CommandLineParser::has(const std::string& name) const
+bool CommandLineParser::has(const cv::String& name) const
{
for (size_t i = 0; i < impl->data.size(); i++)
{
for (size_t j = 0; j < impl->data[i].keys.size(); j++)
{
- if (name.compare(impl->data[i].keys[j]) == 0 && std::string("true").compare(impl->data[i].def_value) == 0)
+ if (name.compare(impl->data[i].keys[j]) == 0 && cv::String("true").compare(impl->data[i].def_value) == 0)
{
return true;
}
{
if (impl->error)
{
- std::cout << std::endl << "ERRORS:" << std::endl << impl->error_message << std::endl;
+ printf("\nERRORS:\n%s\n", impl->error_message.c_str());
+ fflush(stdout);
}
}
void CommandLineParser::printMessage() const
{
if (impl->about_message != "")
- std::cout << impl->about_message << std::endl;
+ printf("%s\n", impl->about_message.c_str());
- std::cout << "Usage: " << impl->app_name << " [params] ";
+ printf("Usage: %s [params] ", impl->app_name.c_str());
for (size_t i = 0; i < impl->data.size(); i++)
{
if (impl->data[i].number > -1)
{
- std::string name = impl->data[i].keys[0].substr(1, impl->data[i].keys[0].length() - 1);
- std::cout << name << " ";
+ cv::String name = impl->data[i].keys[0].substr(1, impl->data[i].keys[0].length() - 1);
+ printf("%s ", name.c_str());
}
}
- std::cout << std::endl << std::endl;
+ printf("\n\n");
for (size_t i = 0; i < impl->data.size(); i++)
{
if (impl->data[i].number == -1)
{
- std::cout << "\t";
+ printf("\t");
for (size_t j = 0; j < impl->data[i].keys.size(); j++)
{
- std::string k = impl->data[i].keys[j];
+ cv::String k = impl->data[i].keys[j];
if (k.length() > 1)
{
- std::cout << "--";
+ printf("--");
}
else
{
- std::cout << "-";
+ printf("-");
}
- std::cout << k;
+ printf("%s", k.c_str());
if (j != impl->data[i].keys.size() - 1)
{
- std::cout << ", ";
+ printf(", ");
}
}
- std::string dv = impl->cat_string(impl->data[i].def_value);
+ cv::String dv = impl->cat_string(impl->data[i].def_value);
if (dv.compare("") != 0)
{
- std::cout << " (value:" << dv << ")";
+ printf(" (value:%s)", dv.c_str());
}
- std::cout << std::endl << "\t\t" << impl->data[i].help_message << std::endl;
+ printf("\n\t\t%s\n", impl->data[i].help_message.c_str());
}
}
- std::cout << std::endl;
+ printf("\n");
for (size_t i = 0; i < impl->data.size(); i++)
{
if (impl->data[i].number != -1)
{
- std::cout << "\t";
- std::string k = impl->data[i].keys[0];
+ printf("\t");
+ cv::String k = impl->data[i].keys[0];
k = k.substr(1, k.length() - 1);
- std::cout << k;
+ printf("%s", k.c_str());
- std::string dv = impl->cat_string(impl->data[i].def_value);
+ cv::String dv = impl->cat_string(impl->data[i].def_value);
if (dv.compare("") != 0)
{
- std::cout << " (value:" << dv << ")";
+ printf(" (value:%s)", dv.c_str());
}
- std::cout << std::endl << "\t\t" << impl->data[i].help_message << std::endl;
+ printf("\n\t\t%s\n", impl->data[i].help_message.c_str());
}
}
}
-std::vector<std::string> CommandLineParser::Impl::split_range_string(const std::string& _str, char fs, char ss) const
+std::vector<cv::String> CommandLineParser::Impl::split_range_string(const cv::String& _str, char fs, char ss) const
{
- std::string str = _str;
- std::vector<std::string> vec;
- std::string word = "";
+ cv::String str = _str;
+ std::vector<cv::String> vec;
+ cv::String word = "";
bool begin = false;
while (!str.empty())
if (begin == true)
{
throw cv::Exception(CV_StsParseError,
- std::string("error in split_range_string(")
+ cv::String("error in split_range_string(")
+ str
- + std::string(", ")
- + std::string(1, fs)
- + std::string(", ")
- + std::string(1, ss)
- + std::string(")"),
+ + cv::String(", ")
+ + cv::String(1, fs)
+ + cv::String(", ")
+ + cv::String(1, ss)
+ + cv::String(")"),
"", __FILE__, __LINE__
);
}
if (begin == false)
{
throw cv::Exception(CV_StsParseError,
- std::string("error in split_range_string(")
+ cv::String("error in split_range_string(")
+ str
- + std::string(", ")
- + std::string(1, fs)
- + std::string(", ")
- + std::string(1, ss)
- + std::string(")"),
+ + cv::String(", ")
+ + cv::String(1, fs)
+ + cv::String(", ")
+ + cv::String(1, ss)
+ + cv::String(")"),
"", __FILE__, __LINE__
);
}
if (begin == true)
{
- word += str[0];
+ word = word + str[0];
}
str = str.substr(1, str.length() - 1);
}
if (begin == true)
{
throw cv::Exception(CV_StsParseError,
- std::string("error in split_range_string(")
+ cv::String("error in split_range_string(")
+ str
- + std::string(", ")
- + std::string(1, fs)
- + std::string(", ")
- + std::string(1, ss)
- + std::string(")"),
+ + cv::String(", ")
+ + cv::String(1, fs)
+ + cv::String(", ")
+ + cv::String(1, ss)
+ + cv::String(")"),
"", __FILE__, __LINE__
);
}
return vec;
}
-std::vector<std::string> CommandLineParser::Impl::split_string(const std::string& _str, char symbol, bool create_empty_item) const
+std::vector<cv::String> CommandLineParser::Impl::split_string(const cv::String& _str, char symbol, bool create_empty_item) const
{
- std::string str = _str;
- std::vector<std::string> vec;
- std::string word = "";
+ cv::String str = _str;
+ std::vector<cv::String> vec;
+ cv::String word = "";
while (!str.empty())
{
}
else
{
- word += str[0];
+ word = word + str[0];
}
str = str.substr(1, str.length() - 1);
}
}
-void putText( Mat& img, const std::string& text, Point org,
+void putText( Mat& img, const cv::String& text, Point org,
int fontFace, double fontScale, Scalar color,
int thickness, int line_type, bool bottomLeftOrigin )
}
}
-Size getTextSize( const std::string& text, int fontFace, double fontScale, int thickness, int* _base_line)
+Size getTextSize( const cv::String& text, int fontFace, double fontScale, int thickness, int* _base_line)
{
Size size;
double view_x = 0;
image = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR);
// prepend a '_' for the Unix C symbol mangling convention
- std::string symbolName = "_";
- symbolName += std::string(name);
+ cv::String symbolName = "_";
+ symbolName += cv::String(name);
NSSymbol symbol = image ? NSLookupSymbolInImage(image, &symbolName[0], NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : 0;
void* func = (void*) CV_GL_GET_PROC_ADDRESS(name);
if (!func)
{
- std::ostringstream msg;
- msg << "Can't load OpenGL extension [" << name << "]";
- CV_Error(CV_OpenGlApiCallError, msg.str());
+ CV_Error(CV_OpenGlApiCallError, cv::format("Can't load OpenGL extension [%s]", name) );
}
return func;
}
{
DIR* dir = new DIR;
dir->ent.d_name = 0;
- dir->handle = ::FindFirstFileA((std::string(path) + "\\*").c_str(), &dir->data);
+ dir->handle = ::FindFirstFileA((cv::String(path) + "\\*").c_str(), &dir->data);
if(dir->handle == INVALID_HANDLE_VALUE)
{
/*closedir will do all cleanup*/
const char native_separator = '/';
#endif
-static bool isDir(const std::string& path, DIR* dir)
+static bool isDir(const cv::String& path, DIR* dir)
{
#if defined WIN32 || defined _WIN32 || defined WINCE
DWORD attributes;
return *wild == 0;
}
-static void glob_rec(const std::string& directory, const std::string& wildchart, std::vector<std::string>& result, bool recursive)
+static void glob_rec(const cv::String& directory, const cv::String& wildchart, std::vector<cv::String>& result, bool recursive)
{
DIR *dir;
struct dirent *ent;
+
if ((dir = opendir (directory.c_str())) != 0)
{
/* find all the files and directories within directory */
if((name[0] == 0) || (name[0] == '.' && name[1] == 0) || (name[0] == '.' && name[1] == '.' && name[2] == 0))
continue;
- std::string path = directory + native_separator + name;
+ cv::String path = directory + native_separator + name;
if (isDir(path, dir))
{
else CV_Error(CV_StsObjectNotFound, cv::format("could not open directory: %s", directory.c_str()));
}
-void cv::glob(std::string pattern, std::vector<std::string>& result, bool recursive)
+void cv::glob(cv::String pattern, std::vector<cv::String>& result, bool recursive)
{
result.clear();
- std::string path, wildchart;
+ cv::String path, wildchart;
if (isDir(pattern, 0))
{
- printf("WE ARE HERE: %s\n", pattern.c_str());
if(strchr(dir_separators, pattern[pattern.size() - 1]) != 0)
{
path = pattern.substr(0, pattern.size() - 1);
else
{
size_t pos = pattern.find_last_of(dir_separators);
- if (pos == std::string::npos)
+ if (pos == cv::String::npos)
{
wildchart = pattern;
path = ".";
bool hasEqualOrGreaterBin(int major, int minor) const;
private:
- static void fromStr(const std::string& set_as_str, std::vector<int>& arr);
+ static void fromStr(const cv::String& set_as_str, std::vector<int>& arr);
std::vector<int> bin;
std::vector<int> ptx;
return !bin.empty() && (bin.back() >= major * 10 + minor);
}
- void CudaArch::fromStr(const std::string& set_as_str, std::vector<int>& arr)
+ void CudaArch::fromStr(const cv::String& set_as_str, std::vector<int>& arr)
{
- if (set_as_str.find_first_not_of(" ") == std::string::npos)
+ if (set_as_str.find_first_not_of(" ") == cv::String::npos)
return;
std::istringstream stream(set_as_str);
return ptr;
}
-std::string cv::FileStorage::getDefaultObjectName(const std::string& _filename)
+cv::String cv::FileStorage::getDefaultObjectName(const cv::String& _filename)
{
static const char* stubname = "unnamed";
const char* filename = _filename.c_str();
name = name_buf;
if( strcmp( name, "_" ) == 0 )
strcpy( name, stubname );
- return std::string(name);
+ return cv::String(name);
}
typedef struct CvGenericHash
static void
-icvClose( CvFileStorage* fs, std::string* out )
+icvClose( CvFileStorage* fs, cv::String* out )
{
if( out )
out->clear();
if( fs->outbuf && out )
{
- out->resize(fs->outbuf->size());
- std::copy(fs->outbuf->begin(), fs->outbuf->end(), out->begin());
+ *out = cv::String(fs->outbuf->begin(), fs->outbuf->end());
}
}
if( !fs )
CV_Error( CV_StsError, "Could not open the file storage. Check the path and permissions" );
- std::string name = _name ? std::string(_name) : cv::FileStorage::getDefaultObjectName(filename);
+ cv::String name = _name ? cv::String(_name) : cv::FileStorage::getDefaultObjectName(filename);
if( comment )
cvWriteComment( fs, comment, 0 );
namespace cv
{
-static void getElemSize( const std::string& fmt, size_t& elemSize, size_t& cn )
+static void getElemSize( const cv::String& fmt, size_t& elemSize, size_t& cn )
{
const char* dt = fmt.c_str();
cn = 1;
state = UNDEFINED;
}
-FileStorage::FileStorage(const std::string& filename, int flags, const std::string& encoding)
+FileStorage::FileStorage(const cv::String& filename, int flags, const cv::String& encoding)
{
state = UNDEFINED;
open( filename, flags, encoding );
}
}
-bool FileStorage::open(const std::string& filename, int flags, const std::string& encoding)
+bool FileStorage::open(const cv::String& filename, int flags, const cv::String& encoding)
{
release();
fs = Ptr<CvFileStorage>(cvOpenFileStorage( filename.c_str(), 0, flags,
state = UNDEFINED;
}
-std::string FileStorage::releaseAndGetString()
+cv::String FileStorage::releaseAndGetString()
{
- std::string buf;
- buf.reserve(16); // HACK: Work around for compiler bug
+ cv::String buf;
if( fs.obj && fs.obj->outbuf )
icvClose(fs.obj, &buf);
return isOpened() ? FileNode(fs, cvGetRootFileNode(fs, streamidx)) : FileNode();
}
-FileStorage& operator << (FileStorage& fs, const std::string& str)
+FileStorage& operator << (FileStorage& fs, const cv::String& str)
{
enum { NAME_EXPECTED = FileStorage::NAME_EXPECTED,
VALUE_EXPECTED = FileStorage::VALUE_EXPECTED,
fs.state = fs.structs.empty() || fs.structs.back() == '{' ?
INSIDE_MAP + NAME_EXPECTED : VALUE_EXPECTED;
cvEndWriteStruct( *fs );
- fs.elname = std::string();
+ fs.elname = cv::String();
}
else if( fs.state == NAME_EXPECTED + INSIDE_MAP )
{
}
cvStartWriteStruct( *fs, fs.elname.size() > 0 ? fs.elname.c_str() : 0,
flags, *_str ? _str : 0 );
- fs.elname = std::string();
+ fs.elname = cv::String();
}
else
{
write( fs, fs.elname, (_str[0] == '\\' && (_str[1] == '{' || _str[1] == '}' ||
- _str[1] == '[' || _str[1] == ']')) ? std::string(_str+1) : str );
+ _str[1] == '[' || _str[1] == ']')) ? cv::String(_str+1) : str );
if( fs.state == INSIDE_MAP + VALUE_EXPECTED )
fs.state = INSIDE_MAP + NAME_EXPECTED;
}
}
-void FileStorage::writeRaw( const std::string& fmt, const uchar* vec, size_t len )
+void FileStorage::writeRaw( const cv::String& fmt, const uchar* vec, size_t len )
{
if( !isOpened() )
return;
}
-void FileStorage::writeObj( const std::string& name, const void* obj )
+void FileStorage::writeObj( const cv::String& name, const void* obj )
{
if( !isOpened() )
return;
}
-FileNode FileStorage::operator[](const std::string& nodename) const
+FileNode FileStorage::operator[](const cv::String& nodename) const
{
return FileNode(fs, cvGetFileNodeByName(fs, 0, nodename.c_str()));
}
return FileNode(fs, cvGetFileNodeByName(fs, 0, nodename));
}
-FileNode FileNode::operator[](const std::string& nodename) const
+FileNode FileNode::operator[](const cv::String& nodename) const
{
return FileNode(fs, cvGetFileNodeByName(fs, node, nodename.c_str()));
}
i == 0 ? *this : FileNode();
}
-std::string FileNode::name() const
+cv::String FileNode::name() const
{
const char* str;
- return !node || (str = cvGetFileNodeName(node)) == 0 ? std::string() : std::string(str);
+ return !node || (str = cvGetFileNodeName(node)) == 0 ? cv::String() : cv::String(str);
}
void* FileNode::readObj() const
}
-FileNodeIterator& FileNodeIterator::readRaw( const std::string& fmt, uchar* vec, size_t maxCount )
+FileNodeIterator& FileNodeIterator::readRaw( const cv::String& fmt, uchar* vec, size_t maxCount )
{
if( fs && container && remaining > 0 )
{
}
-void write( FileStorage& fs, const std::string& name, int value )
+void write( FileStorage& fs, const cv::String& name, int value )
{ cvWriteInt( *fs, name.size() ? name.c_str() : 0, value ); }
-void write( FileStorage& fs, const std::string& name, float value )
+void write( FileStorage& fs, const cv::String& name, float value )
{ cvWriteReal( *fs, name.size() ? name.c_str() : 0, value ); }
-void write( FileStorage& fs, const std::string& name, double value )
+void write( FileStorage& fs, const cv::String& name, double value )
{ cvWriteReal( *fs, name.size() ? name.c_str() : 0, value ); }
-void write( FileStorage& fs, const std::string& name, const std::string& value )
+void write( FileStorage& fs, const cv::String& name, const cv::String& value )
{ cvWriteString( *fs, name.size() ? name.c_str() : 0, value.c_str() ); }
void writeScalar(FileStorage& fs, int value )
void writeScalar(FileStorage& fs, double value )
{ cvWriteReal( *fs, 0, value ); }
-void writeScalar(FileStorage& fs, const std::string& value )
+void writeScalar(FileStorage& fs, const cv::String& value )
{ cvWriteString( *fs, 0, value.c_str() ); }
-void write( FileStorage& fs, const std::string& name, const Mat& value )
+void write( FileStorage& fs, const cv::String& name, const Mat& value )
{
if( value.dims <= 2 )
{
}
// TODO: the 4 functions below need to be implemented more efficiently
-void write( FileStorage& fs, const std::string& name, const SparseMat& value )
+void write( FileStorage& fs, const cv::String& name, const SparseMat& value )
{
Ptr<CvSparseMat> mat = (CvSparseMat*)value;
cvWrite( *fs, name.size() ? name.c_str() : 0, mat );
}
-WriteStructContext::WriteStructContext(FileStorage& _fs, const std::string& name,
- int flags, const std::string& typeName) : fs(&_fs)
+WriteStructContext::WriteStructContext(FileStorage& _fs, const cv::String& name,
+ int flags, const cv::String& typeName) : fs(&_fs)
{
cvStartWriteStruct(**fs, !name.empty() ? name.c_str() : 0, flags,
!typeName.empty() ? typeName.c_str() : 0);
Exception::Exception() { code = 0; line = 0; }
-Exception::Exception(int _code, const std::string& _err, const std::string& _func, const std::string& _file, int _line)
+Exception::Exception(int _code, const cv::String& _err, const cv::String& _func, const cv::String& _file, int _line)
: code(_code), err(_err), func(_func), file(_file), line(_line)
{
formatMessage();
#endif
-const std::string& getBuildInformation()
+const cv::String& getBuildInformation()
{
- static std::string build_info =
+ static cv::String build_info =
#include "version_string.inc"
;
return build_info;
}
-std::string format( const char* fmt, ... )
+cv::String format( const char* fmt, ... )
{
char buf[1 << 16];
va_list args;
va_start( args, fmt );
vsprintf( buf, fmt, args );
- return std::string(buf);
+ return cv::String(buf);
}
-std::string tempfile( const char* suffix )
+cv::String tempfile( const char* suffix )
{
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
- std::string fname;
+ cv::String fname;
#if defined WIN32 || defined _WIN32
char temp_dir2[MAX_PATH + 1] = { 0 };
temp_dir = temp_dir2;
}
if(0 == ::GetTempFileNameA(temp_dir, "ocv", 0, temp_file))
- return std::string();
+ return cv::String();
DeleteFileA(temp_file);
fname = temp_dir;
char ech = fname[fname.size() - 1];
if(ech != '/' && ech != '\\')
- fname += "/";
- fname += "__opencv_temp.XXXXXX";
+ fname = fname + "/";
+ fname = fname + "__opencv_temp.XXXXXX";
}
const int fd = mkstemp((char*)fname.c_str());
- if (fd == -1) return std::string();
+ if (fd == -1) return cv::String();
close(fd);
remove(fname.c_str());
int real_int = (int)fs["test_int"];
double real_real = (double)fs["test_real"];
- string real_string = (string)fs["test_string"];
+ String real_string = (String)fs["test_string"];
if( real_int != test_int ||
fabs(real_real - test_real) > DBL_EPSILON*(fabs(test_real)+1) ||
(int)tl[1] != 2 ||
fabs((double)tl[2] - CV_PI) >= DBL_EPSILON ||
(int)tl[3] != -3435345 ||
- (string)tl[4] != "2-502 2-029 3egegeg" ||
+ (String)tl[4] != "2-502 2-029 3egegeg" ||
tl[5].type() != FileNode::MAP || tl[5].size() != 3 ||
(int)tl[5]["month"] != 12 ||
(int)tl[5]["day"] != 31 ||
std::string patternLena = cvtest::TS::ptr()->get_data_path() + "lena*.*";
std::string patternLenaPng = cvtest::TS::ptr()->get_data_path() + "lena.png";
- std::vector<std::string> lenas, pngLenas;
+ std::vector<cv::String> lenas, pngLenas;
cv::glob(patternLena, lenas, true);
cv::glob(patternLenaPng, pngLenas, true);
};
//! writes vector of keypoints to the file storage
-CV_EXPORTS void write(FileStorage& fs, const std::string& name, const std::vector<KeyPoint>& keypoints);
+CV_EXPORTS void write(FileStorage& fs, const cv::String& name, const std::vector<KeyPoint>& keypoints);
//! reads vector of keypoints from the specified file storage node
CV_EXPORTS void read(const FileNode& node, CV_OUT std::vector<KeyPoint>& keypoints);
CV_WRAP virtual bool empty() const;
// Create feature detector by detector name.
- CV_WRAP static Ptr<FeatureDetector> create( const std::string& detectorType );
+ CV_WRAP static Ptr<FeatureDetector> create( const cv::String& detectorType );
protected:
virtual void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const = 0;
CV_WRAP virtual bool empty() const;
- CV_WRAP static Ptr<DescriptorExtractor> create( const std::string& descriptorExtractorType );
+ CV_WRAP static Ptr<DescriptorExtractor> create( const cv::String& descriptorExtractorType );
protected:
virtual void computeImpl( const Mat& image, std::vector<KeyPoint>& keypoints, Mat& descriptors ) const = 0;
bool useProvidedKeypoints=false ) const = 0;
// Create feature detector and descriptor extractor by name.
- CV_WRAP static Ptr<Feature2D> create( const std::string& name );
+ CV_WRAP static Ptr<Feature2D> create( const cv::String& name );
};
/*!
virtual Ptr<AdjusterAdapter> clone() const = 0;
- static Ptr<AdjusterAdapter> create( const std::string& detectorType );
+ static Ptr<AdjusterAdapter> create( const cv::String& detectorType );
};
/** \brief an adaptively adjusting detector that iteratively detects until the desired number
* of features are detected.
// but with empty train data.
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const = 0;
- CV_WRAP static Ptr<DescriptorMatcher> create( const std::string& descriptorMatcherType );
+ CV_WRAP static Ptr<DescriptorMatcher> create( const cv::String& descriptorMatcherType );
protected:
/*
* Class to work with descriptors from several images as with one merged matrix.
// but with empty train data.
virtual Ptr<GenericDescriptorMatcher> clone( bool emptyTrainData=false ) const = 0;
- static Ptr<GenericDescriptorMatcher> create( const std::string& genericDescritptorMatcherType,
- const std::string ¶msFilename=std::string() );
+ static Ptr<GenericDescriptorMatcher> create( const cv::String& genericDescritptorMatcherType,
+ const cv::String ¶msFilename=cv::String() );
protected:
// In fact the matching is implemented only by the following two methods. These methods suppose
KeyPointsFilter::runByImageBorder( keypoints, imageSize, borderSize );
}
-Ptr<DescriptorExtractor> DescriptorExtractor::create(const std::string& descriptorExtractorType)
+Ptr<DescriptorExtractor> DescriptorExtractor::create(const cv::String& descriptorExtractorType)
{
if( descriptorExtractorType.find("Opponent") == 0 )
{
- size_t pos = std::string("Opponent").size();
- std::string type = descriptorExtractorType.substr(pos);
+ size_t pos = cv::String("Opponent").size();
+ cv::String type = descriptorExtractorType.substr(pos);
return new OpponentColorDescriptorExtractor(DescriptorExtractor::create(type));
}
KeyPointsFilter::runByPixelsMask( keypoints, mask );
}
-Ptr<FeatureDetector> FeatureDetector::create( const std::string& detectorType )
+Ptr<FeatureDetector> FeatureDetector::create( const cv::String& detectorType )
{
if( detectorType.find("Grid") == 0 )
{
return cloned_obj;
}
-Ptr<AdjusterAdapter> AdjusterAdapter::create( const std::string& detectorType )
+Ptr<AdjusterAdapter> AdjusterAdapter::create( const cv::String& detectorType )
{
Ptr<AdjusterAdapter> adapter;
using namespace cv;
-Ptr<Feature2D> Feature2D::create( const std::string& feature2DType )
+Ptr<Feature2D> Feature2D::create( const cv::String& feature2DType )
{
return Algorithm::create<Feature2D>("Feature2D." + feature2DType);
}
return _Val;
}
-void write(FileStorage& fs, const std::string& objname, const std::vector<KeyPoint>& keypoints)
+void write(FileStorage& fs, const cv::String& objname, const std::vector<KeyPoint>& keypoints)
{
WriteStructContext ws(fs, objname, CV_NODE_SEQ + CV_NODE_FLOW);
/*
* Factory function for DescriptorMatcher creating
*/
-Ptr<DescriptorMatcher> DescriptorMatcher::create( const std::string& descriptorMatcherType )
+Ptr<DescriptorMatcher> DescriptorMatcher::create( const cv::String& descriptorMatcherType )
{
DescriptorMatcher* dm = 0;
if( !descriptorMatcherType.compare( "FlannBased" ) )
for(int i = 0; i < (int)ip.size(); ++i)
{
CV_Assert(ip[i].type() == FileNode::MAP);
- std::string _name = (std::string)ip[i]["name"];
+ cv::String _name = (cv::String)ip[i]["name"];
int type = (int)ip[i]["type"];
switch(type)
indexParams->setDouble(_name, (double) ip[i]["value"]);
break;
case CV_USRTYPE1:
- indexParams->setString(_name, (std::string) ip[i]["value"]);
+ indexParams->setString(_name, (cv::String) ip[i]["value"]);
break;
case CV_MAKETYPE(CV_USRTYPE1,2):
indexParams->setBool(_name, (int) ip[i]["value"] != 0);
for(int i = 0; i < (int)sp.size(); ++i)
{
CV_Assert(sp[i].type() == FileNode::MAP);
- std::string _name = (std::string)sp[i]["name"];
+ cv::String _name = (cv::String)sp[i]["name"];
int type = (int)sp[i]["type"];
switch(type)
searchParams->setDouble(_name, (double) ip[i]["value"]);
break;
case CV_USRTYPE1:
- searchParams->setString(_name, (std::string) ip[i]["value"]);
+ searchParams->setString(_name, (cv::String) ip[i]["value"]);
break;
case CV_MAKETYPE(CV_USRTYPE1,2):
searchParams->setBool(_name, (int) ip[i]["value"] != 0);
if (indexParams)
{
- std::vector<std::string> names;
+ std::vector<cv::String> names;
std::vector<int> types;
- std::vector<std::string> strValues;
+ std::vector<cv::String> strValues;
std::vector<double> numValues;
indexParams->getAll(names, types, strValues, numValues);
if (searchParams)
{
- std::vector<std::string> names;
+ std::vector<cv::String> names;
std::vector<int> types;
- std::vector<std::string> strValues;
+ std::vector<cv::String> strValues;
std::vector<double> numValues;
searchParams->getAll(names, types, strValues, numValues);
/*
* Factory function for GenericDescriptorMatch creating
*/
-Ptr<GenericDescriptorMatcher> GenericDescriptorMatcher::create( const std::string& genericDescritptorMatcherType,
- const std::string ¶msFilename )
+Ptr<GenericDescriptorMatcher> GenericDescriptorMatcher::create( const cv::String& genericDescritptorMatcherType,
+ const cv::String ¶msFilename )
{
Ptr<GenericDescriptorMatcher> descriptorMatcher =
Algorithm::create<GenericDescriptorMatcher>("DescriptorMatcher." + genericDescritptorMatcherType);
struct SavedIndexParams : public IndexParams
{
- SavedIndexParams( std::string filename );
+ SavedIndexParams( cv::String filename );
};
------------------------------
Saves the index to a file.
-.. ocv:function:: void flann::Index_<T>::save(std::string filename)
+.. ocv:function:: void flann::Index_<T>::save(cv::String filename)
:param filename: The file to save the index to
int radiusSearch(const Mat& query, Mat& indices, Mat& dists,
DistanceType radius, const ::cvflann::SearchParams& params);
- void save(std::string filename) { nnIndex->save(filename); }
+ void save(cv::String filename) { nnIndex->save(filename); }
int veclen() const { return nnIndex->veclen(); }
int radiusSearch(const std::vector<ElementType>& query, std::vector<int>& indices, std::vector<DistanceType>& dists, DistanceType radius, const ::cvflann::SearchParams& params);
int radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& params);
- void save(std::string filename)
+ void save(cv::String filename)
{
if (nnIndex_L1) nnIndex_L1->save(filename);
if (nnIndex_L2) nnIndex_L2->save(filename);
out << int(*reinterpret_cast<flann_algorithm_t const*>(*src));
}
+template<> inline void big_any_policy<cv::String>::print(std::ostream& out, void* const* src)
+{
+ out << (*reinterpret_cast<cv::String const*>(*src)).c_str();
+}
+
template<typename T>
struct choose_policy
{
*/
struct SavedIndexParams : public IndexParams
{
- SavedIndexParams(std::string filename)
+ SavedIndexParams(cv::String filename)
{
(* this)["algorithm"] = FLANN_INDEX_SAVED;
(*this)["filename"] = filename;
template<typename Distance>
-NNIndex<Distance>* load_saved_index(const Matrix<typename Distance::ElementType>& dataset, const std::string& filename, Distance distance)
+NNIndex<Distance>* load_saved_index(const Matrix<typename Distance::ElementType>& dataset, const cv::String& filename, Distance distance)
{
typedef typename Distance::ElementType ElementType;
loaded_ = false;
if (index_type == FLANN_INDEX_SAVED) {
- nnIndex_ = load_saved_index<Distance>(features, get_param<std::string>(params,"filename"), distance);
+ nnIndex_ = load_saved_index<Distance>(features, get_param<cv::String>(params,"filename"), distance);
loaded_ = true;
}
else {
}
}
- void save(std::string filename)
+ void save(cv::String filename)
{
FILE* fout = fopen(filename.c_str(), "wb");
if (fout == NULL) {
#ifndef OPENCV_FLANN_GENERAL_H_
#define OPENCV_FLANN_GENERAL_H_
-#include "defines.h"
-#include <stdexcept>
-#include <cassert>
+#include "opencv2/core.hpp"
namespace cvflann
{
-class FLANNException : public std::runtime_error
+class FLANNException : public cv::Exception
{
public:
- FLANNException(const char* message) : std::runtime_error(message) { }
+ FLANNException(const char* message) : cv::Exception(0, message, "", __FILE__, __LINE__) { }
- FLANNException(const std::string& message) : std::runtime_error(message) { }
+ FLANNException(const cv::String& message) : cv::Exception(0, message, "", __FILE__, __LINE__) { }
};
}
#define CHECK_ERROR(x,y) if ((x)<0) throw FLANNException((y));
template<typename T>
-void save_to_file(const cvflann::Matrix<T>& dataset, const std::string& filename, const std::string& name)
+void save_to_file(const cvflann::Matrix<T>& dataset, const cv::String& filename, const cv::String& name)
{
#if H5Eset_auto_vers == 2
template<typename T>
-void load_from_file(cvflann::Matrix<T>& dataset, const std::string& filename, const std::string& name)
+void load_from_file(cvflann::Matrix<T>& dataset, const cv::String& filename, const cv::String& name)
{
herr_t status;
hid_t file_id = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
* @param name Name of dataset inside file
*/
template<typename T>
-void load_from_file(cvflann::Matrix<T>& dataset, const std::string& filename, const std::string& name)
+void load_from_file(cvflann::Matrix<T>& dataset, const cv::String& filename, const cv::String& name)
{
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Info info = MPI_INFO_NULL;
const size_t key_size_upper_bound = std::min(sizeof(BucketKey) * CHAR_BIT + 1, sizeof(size_t) * CHAR_BIT);
if (key_size < key_size_lower_bound || key_size >= key_size_upper_bound)
{
- std::stringstream errorMessage;
- errorMessage << "Invalid key_size (=" << key_size << "). Valid values for your system are " << key_size_lower_bound << " <= key_size < " << key_size_upper_bound << ".";
- CV_Error(CV_StsBadArg, errorMessage.str());
+ CV_Error(CV_StsBadArg, cv::format("Invalid key_size (=%d). Valid values for your system are %d <= key_size < %d.", (int)key_size, (int)key_size_lower_bound, (int)key_size_upper_bound));
}
speed_level_ = kHash;
IndexParams();
~IndexParams();
- std::string getString(const std::string& key, const std::string& defaultVal=std::string()) const;
- int getInt(const std::string& key, int defaultVal=-1) const;
- double getDouble(const std::string& key, double defaultVal=-1) const;
-
- void setString(const std::string& key, const std::string& value);
- void setInt(const std::string& key, int value);
- void setDouble(const std::string& key, double value);
- void setFloat(const std::string& key, float value);
- void setBool(const std::string& key, bool value);
+ cv::String getString(const cv::String& key, const cv::String& defaultVal=cv::String()) const;
+ int getInt(const cv::String& key, int defaultVal=-1) const;
+ double getDouble(const cv::String& key, double defaultVal=-1) const;
+
+ void setString(const cv::String& key, const cv::String& value);
+ void setInt(const cv::String& key, int value);
+ void setDouble(const cv::String& key, double value);
+ void setFloat(const cv::String& key, float value);
+ void setBool(const cv::String& key, bool value);
void setAlgorithm(int value);
- void getAll(std::vector<std::string>& names,
+ void getAll(std::vector<cv::String>& names,
std::vector<int>& types,
- std::vector<std::string>& strValues,
+ std::vector<cv::String>& strValues,
std::vector<double>& numValues) const;
void* params;
struct CV_EXPORTS SavedIndexParams : public IndexParams
{
- SavedIndexParams(const std::string& filename);
+ SavedIndexParams(const cv::String& filename);
};
struct CV_EXPORTS SearchParams : public IndexParams
OutputArray dists, double radius, int maxResults,
const SearchParams& params=SearchParams());
- CV_WRAP virtual void save(const std::string& filename) const;
- CV_WRAP virtual bool load(InputArray features, const std::string& filename);
+ CV_WRAP virtual void save(const cv::String& filename) const;
+ CV_WRAP virtual bool load(InputArray features, const cv::String& filename);
CV_WRAP virtual void release();
CV_WRAP cvflann::flann_distance_t getDistance() const;
CV_WRAP cvflann::flann_algorithm_t getAlgorithm() const;
namespace cvflann
{
-typedef std::map<std::string, any> IndexParams;
+typedef std::map<cv::String, any> IndexParams;
struct SearchParams : public IndexParams
{
template<typename T>
-T get_param(const IndexParams& params, std::string name, const T& default_value)
+T get_param(const IndexParams& params, cv::String name, const T& default_value)
{
IndexParams::const_iterator it = params.find(name);
if (it != params.end()) {
}
template<typename T>
-T get_param(const IndexParams& params, std::string name)
+T get_param(const IndexParams& params, cv::String name)
{
IndexParams::const_iterator it = params.find(name);
if (it != params.end()) {
return it->second.cast<T>();
}
else {
- throw FLANNException(std::string("Missing parameter '")+name+std::string("' in the parameters given"));
+ throw FLANNException(cv::String("Missing parameter '")+name+cv::String("' in the parameters given"));
}
}
}
template<typename T>
-T getParam(const IndexParams& _p, const std::string& key, const T& defaultVal=T())
+T getParam(const IndexParams& _p, const cv::String& key, const T& defaultVal=T())
{
::cvflann::IndexParams& p = get_params(_p);
::cvflann::IndexParams::const_iterator it = p.find(key);
}
template<typename T>
-void setParam(IndexParams& _p, const std::string& key, const T& value)
+void setParam(IndexParams& _p, const cv::String& key, const T& value)
{
::cvflann::IndexParams& p = get_params(_p);
p[key] = value;
}
-std::string IndexParams::getString(const std::string& key, const std::string& defaultVal) const
+cv::String IndexParams::getString(const cv::String& key, const cv::String& defaultVal) const
{
return getParam(*this, key, defaultVal);
}
-int IndexParams::getInt(const std::string& key, int defaultVal) const
+int IndexParams::getInt(const cv::String& key, int defaultVal) const
{
return getParam(*this, key, defaultVal);
}
-double IndexParams::getDouble(const std::string& key, double defaultVal) const
+double IndexParams::getDouble(const cv::String& key, double defaultVal) const
{
return getParam(*this, key, defaultVal);
}
-void IndexParams::setString(const std::string& key, const std::string& value)
+void IndexParams::setString(const cv::String& key, const cv::String& value)
{
setParam(*this, key, value);
}
-void IndexParams::setInt(const std::string& key, int value)
+void IndexParams::setInt(const cv::String& key, int value)
{
setParam(*this, key, value);
}
-void IndexParams::setDouble(const std::string& key, double value)
+void IndexParams::setDouble(const cv::String& key, double value)
{
setParam(*this, key, value);
}
-void IndexParams::setFloat(const std::string& key, float value)
+void IndexParams::setFloat(const cv::String& key, float value)
{
setParam(*this, key, value);
}
-void IndexParams::setBool(const std::string& key, bool value)
+void IndexParams::setBool(const cv::String& key, bool value)
{
setParam(*this, key, value);
}
setParam(*this, "algorithm", (cvflann::flann_algorithm_t)value);
}
-void IndexParams::getAll(std::vector<std::string>& names,
+void IndexParams::getAll(std::vector<cv::String>& names,
std::vector<int>& types,
- std::vector<std::string>& strValues,
+ std::vector<cv::String>& strValues,
std::vector<double>& numValues) const
{
names.clear();
names.push_back(it->first);
try
{
- std::string val = it->second.cast<std::string>();
+ cv::String val = it->second.cast<cv::String>();
types.push_back(CV_USRTYPE1);
strValues.push_back(val);
numValues.push_back(-1);
p["multi_probe_level"] = multi_probe_level;
}
-SavedIndexParams::SavedIndexParams(const std::string& _filename)
+SavedIndexParams::SavedIndexParams(const cv::String& _filename)
{
- std::string filename = _filename;
+ cv::String filename = _filename;
::cvflann::IndexParams& p = get_params(*this);
p["algorithm"] = FLANN_INDEX_SAVED;
algo = getParam<flann_algorithm_t>(params, "algorithm", FLANN_INDEX_LINEAR);
if( algo == FLANN_INDEX_SAVED )
{
- load(_data, getParam<std::string>(params, "filename", std::string()));
+ load(_data, getParam<cv::String>(params, "filename", cv::String()));
return;
}
saveIndex_< ::cvflann::Index<Distance> >(index0, index, fout);
}
-void Index::save(const std::string& filename) const
+void Index::save(const cv::String& filename) const
{
FILE* fout = fopen(filename.c_str(), "wb");
if (fout == NULL)
return loadIndex_<Distance, ::cvflann::Index<Distance> >(index0, index, data, fin, dist);
}
-bool Index::load(InputArray _data, const std::string& filename)
+bool Index::load(InputArray _data, const cv::String& filename)
{
Mat data = _data.getMat();
bool ok = true;
WND_PROP_OPENGL = CV_WND_PROP_OPENGL // opengl support
};
-CV_EXPORTS_W void namedWindow(const std::string& winname, int flags = WINDOW_AUTOSIZE);
-CV_EXPORTS_W void destroyWindow(const std::string& winname);
+CV_EXPORTS_W void namedWindow(const cv::String& winname, int flags = WINDOW_AUTOSIZE);
+CV_EXPORTS_W void destroyWindow(const cv::String& winname);
CV_EXPORTS_W void destroyAllWindows();
CV_EXPORTS_W int startWindowThread();
CV_EXPORTS_W int waitKey(int delay = 0);
-CV_EXPORTS_W void imshow(const std::string& winname, InputArray mat);
+CV_EXPORTS_W void imshow(const cv::String& winname, InputArray mat);
-CV_EXPORTS_W void resizeWindow(const std::string& winname, int width, int height);
-CV_EXPORTS_W void moveWindow(const std::string& winname, int x, int y);
+CV_EXPORTS_W void resizeWindow(const cv::String& winname, int width, int height);
+CV_EXPORTS_W void moveWindow(const cv::String& winname, int x, int y);
-CV_EXPORTS_W void setWindowProperty(const std::string& winname, int prop_id, double prop_value);//YV
-CV_EXPORTS_W double getWindowProperty(const std::string& winname, int prop_id);//YV
+CV_EXPORTS_W void setWindowProperty(const cv::String& winname, int prop_id, double prop_value);//YV
+CV_EXPORTS_W double getWindowProperty(const cv::String& winname, int prop_id);//YV
enum
{
typedef void (*MouseCallback)(int event, int x, int y, int flags, void* userdata);
//! assigns callback for mouse events
-CV_EXPORTS void setMouseCallback(const std::string& winname, MouseCallback onMouse, void* userdata = 0);
+CV_EXPORTS void setMouseCallback(const cv::String& winname, MouseCallback onMouse, void* userdata = 0);
typedef void (CV_CDECL *TrackbarCallback)(int pos, void* userdata);
-CV_EXPORTS int createTrackbar(const std::string& trackbarname, const std::string& winname,
+CV_EXPORTS int createTrackbar(const cv::String& trackbarname, const cv::String& winname,
int* value, int count,
TrackbarCallback onChange = 0,
void* userdata = 0);
-CV_EXPORTS_W int getTrackbarPos(const std::string& trackbarname, const std::string& winname);
-CV_EXPORTS_W void setTrackbarPos(const std::string& trackbarname, const std::string& winname, int pos);
+CV_EXPORTS_W int getTrackbarPos(const cv::String& trackbarname, const cv::String& winname);
+CV_EXPORTS_W void setTrackbarPos(const cv::String& trackbarname, const cv::String& winname, int pos);
// OpenGL support
typedef void (*OpenGlDrawCallback)(void* userdata);
-CV_EXPORTS void setOpenGlDrawCallback(const std::string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0);
+CV_EXPORTS void setOpenGlDrawCallback(const cv::String& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0);
-CV_EXPORTS void setOpenGlContext(const std::string& winname);
+CV_EXPORTS void setOpenGlContext(const cv::String& winname);
-CV_EXPORTS void updateWindow(const std::string& winname);
+CV_EXPORTS void updateWindow(const cv::String& winname);
//Only for Qt
-CV_EXPORTS CvFont fontQt(const std::string& nameFont, int pointSize=-1,
+CV_EXPORTS CvFont fontQt(const cv::String& nameFont, int pointSize=-1,
Scalar color=Scalar::all(0), int weight=CV_FONT_NORMAL,
int style=CV_STYLE_NORMAL, int spacing=0);
-CV_EXPORTS void addText( const Mat& img, const std::string& text, Point org, CvFont font);
+CV_EXPORTS void addText( const Mat& img, const cv::String& text, Point org, CvFont font);
-CV_EXPORTS void displayOverlay(const std::string& winname, const std::string& text, int delayms CV_DEFAULT(0));
-CV_EXPORTS void displayStatusBar(const std::string& winname, const std::string& text, int delayms CV_DEFAULT(0));
+CV_EXPORTS void displayOverlay(const cv::String& winname, const cv::String& text, int delayms CV_DEFAULT(0));
+CV_EXPORTS void displayStatusBar(const cv::String& winname, const cv::String& text, int delayms CV_DEFAULT(0));
-CV_EXPORTS void saveWindowParameters(const std::string& windowName);
-CV_EXPORTS void loadWindowParameters(const std::string& windowName);
+CV_EXPORTS void saveWindowParameters(const cv::String& windowName);
+CV_EXPORTS void loadWindowParameters(const cv::String& windowName);
CV_EXPORTS int startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
CV_EXPORTS void stopLoop();
typedef void (CV_CDECL *ButtonCallback)(int state, void* userdata);
-CV_EXPORTS int createButton( const std::string& bar_name, ButtonCallback on_change,
+CV_EXPORTS int createButton( const cv::String& bar_name, ButtonCallback on_change,
void* userdata=NULL, int type=CV_PUSH_BUTTON,
bool initial_button_state=0);
IMWRITE_PXM_BINARY =32
};
-CV_EXPORTS_W Mat imread( const std::string& filename, int flags=1 );
-CV_EXPORTS_W bool imwrite( const std::string& filename, InputArray img,
+CV_EXPORTS_W Mat imread( const cv::String& filename, int flags=1 );
+CV_EXPORTS_W bool imwrite( const cv::String& filename, InputArray img,
const std::vector<int>& params=std::vector<int>());
CV_EXPORTS_W Mat imdecode( InputArray buf, int flags );
CV_EXPORTS Mat imdecode( InputArray buf, int flags, Mat* dst );
-CV_EXPORTS_W bool imencode( const std::string& ext, InputArray img,
+CV_EXPORTS_W bool imencode( const cv::String& ext, InputArray img,
CV_OUT std::vector<uchar>& buf,
const std::vector<int>& params=std::vector<int>());
{
public:
CV_WRAP VideoCapture();
- CV_WRAP VideoCapture(const std::string& filename);
+ CV_WRAP VideoCapture(const cv::String& filename);
CV_WRAP VideoCapture(int device);
virtual ~VideoCapture();
- CV_WRAP virtual bool open(const std::string& filename);
+ CV_WRAP virtual bool open(const cv::String& filename);
CV_WRAP virtual bool open(int device);
CV_WRAP virtual bool isOpened() const;
CV_WRAP virtual void release();
{
public:
CV_WRAP VideoWriter();
- CV_WRAP VideoWriter(const std::string& filename, int fourcc, double fps,
+ CV_WRAP VideoWriter(const cv::String& filename, int fourcc, double fps,
Size frameSize, bool isColor=true);
virtual ~VideoWriter();
- CV_WRAP virtual bool open(const std::string& filename, int fourcc, double fps,
+ CV_WRAP virtual bool open(const cv::String& filename, int fourcc, double fps,
Size frameSize, bool isColor=true);
CV_WRAP virtual bool isOpened() const;
CV_WRAP virtual void release();
}
-bool RBaseStream::open( const std::string& filename )
+bool RBaseStream::open( const cv::String& filename )
{
close();
allocate();
}
-bool WBaseStream::open( const std::string& filename )
+bool WBaseStream::open( const cv::String& filename )
{
close();
allocate();
RBaseStream();
virtual ~RBaseStream();
- virtual bool open( const std::string& filename );
+ virtual bool open( const cv::String& filename );
virtual bool open( const Mat& buf );
virtual void close();
bool isOpened();
WBaseStream();
virtual ~WBaseStream();
- virtual bool open( const std::string& filename );
+ virtual bool open( const cv::String& filename );
virtual bool open( std::vector<uchar>& buf );
virtual void close();
bool isOpened();
VideoCapture::VideoCapture()
{}
-VideoCapture::VideoCapture(const std::string& filename)
+VideoCapture::VideoCapture(const cv::String& filename)
{
open(filename);
}
cap.release();
}
-bool VideoCapture::open(const std::string& filename)
+bool VideoCapture::open(const cv::String& filename)
{
if (!isOpened())
cap = cvCreateFileCapture(filename.c_str());
VideoWriter::VideoWriter()
{}
-VideoWriter::VideoWriter(const std::string& filename, int fourcc, double fps, Size frameSize, bool isColor)
+VideoWriter::VideoWriter(const cv::String& filename, int fourcc, double fps, Size frameSize, bool isColor)
{
open(filename, fourcc, fps, frameSize, isColor);
}
release();
}
-bool VideoWriter::open(const std::string& filename, int fourcc, double fps, Size frameSize, bool isColor)
+bool VideoWriter::open(const cv::String& filename, int fourcc, double fps, Size frameSize, bool isColor)
{
writer = cvCreateVideoWriter(filename.c_str(), fourcc, fps, frameSize, isColor);
return isOpened();
#include "XnCppWrapper.h"
-const std::string XMLConfig =
+const cv::String XMLConfig =
"<OpenNI>"
"<Licenses>"
"<License vendor=\"PrimeSense\" key=\"0KOIk2JeIBYClPWVnMoRKn5cdY4=\"/>"
if( status != XN_STATUS_OK )
{
std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to initialize the context: "
- << std::string(xnGetStatusString(status)) << std::endl;
+ << cv::String(xnGetStatusString(status)) << std::endl;
return;
}
if( status != XN_STATUS_OK )
{
std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: "
- << std::string(xnGetStatusString(status)) << std::endl;
+ << cv::String(xnGetStatusString(status)) << std::endl;
return;
}
if( status != XN_STATUS_OK )
{
std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create production tree: "
- << std::string(xnGetStatusString(status)) << std::endl;
+ << cv::String(xnGetStatusString(status)) << std::endl;
return;
}
if( status != XN_STATUS_OK )
{
std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to run xml script: "
- << std::string(xnGetStatusString(status)) << std::endl;
+ << cv::String(xnGetStatusString(status)) << std::endl;
return;
}
if( status != XN_STATUS_OK )
{
std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate depth generators: "
- << std::string(xnGetStatusString(status)) << std::endl;
+ << cv::String(xnGetStatusString(status)) << std::endl;
return;
}
if( depthList.IsEmpty() )
if( status != XN_STATUS_OK )
{
std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create depth generator: "
- << std::string(xnGetStatusString(status)) << std::endl;
+ << cv::String(xnGetStatusString(status)) << std::endl;
return;
}
if( status != XN_STATUS_OK )
{
std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate image generators: "
- << std::string(xnGetStatusString(status)) << std::endl;
+ << cv::String(xnGetStatusString(status)) << std::endl;
return;
}
if( status != XN_STATUS_OK )
{
std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create image generator: "
- << std::string(xnGetStatusString(status)) << std::endl;
+ << cv::String(xnGetStatusString(status)) << std::endl;
return;
}
}
if( status != XN_STATUS_OK )
{
std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to start generating OpenNI data: "
- << std::string(xnGetStatusString(status)) << std::endl;
+ << cv::String(xnGetStatusString(status)) << std::endl;
return;
}
if( status != XN_STATUS_OK )
{
std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to initialize the context: "
- << std::string(xnGetStatusString(status)) << std::endl;
+ << cv::String(xnGetStatusString(status)) << std::endl;
return;
}
if( status != XN_STATUS_OK )
{
std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to open input file (" << filename << "): "
- << std::string(xnGetStatusString(status)) << std::endl;
+ << cv::String(xnGetStatusString(status)) << std::endl;
return;
}
break;
default :
{
- std::stringstream ss;
+ cv::Stringstream ss;
ss << "Such parameter (propIdx=" << propIdx << ") isn't supported for getting.\n";
CV_Error( CV_StsBadArg, ss.str().c_str() );
}
break;
default:
{
- std::stringstream ss;
+ cv::Stringstream ss;
ss << "Such parameter (propIdx=" << propIdx << ") isn't supported for setting.\n";
CV_Error( CV_StsBadArg, ss.str().c_str() );
}
break;
default :
{
- std::stringstream ss;
+ cv::Stringstream ss;
ss << "Depth generator does not support such parameter (propIdx=" << propIdx << ") for getting.\n";
CV_Error( CV_StsBadArg, ss.str().c_str() );
}
break;
default:
{
- std::stringstream ss;
+ cv::Stringstream ss;
ss << "Depth generator does not support such parameter (propIdx=" << propIdx << ") for setting.\n";
CV_Error( CV_StsBadArg, ss.str().c_str() );
}
break;
default :
{
- std::stringstream ss;
+ cv::Stringstream ss;
ss << "Image generator does not support such parameter (propIdx=" << propIdx << ") for getting.\n";
CV_Error( CV_StsBadArg, ss.str().c_str() );
}
}
default:
{
- std::stringstream ss;
+ cv::Stringstream ss;
ss << "Image generator does not support such parameter (propIdx=" << propIdx << ") for setting.\n";
CV_Error( CV_StsBadArg, ss.str().c_str() );
}
}
else
{
- std::string ip=cv::format("%d.%d.%d.%d", ((int)value>>24)&255, ((int)value>>16)&255, ((int)value>>8)&255, (int)value&255);
+ cv::String ip=cv::format("%d.%d.%d.%d", ((int)value>>24)&255, ((int)value>>16)&255, ((int)value>>8)&255, (int)value&255);
if ((PvAttrEnumSet(Camera.Handle,"MulticastEnable", "On")==ePvErrSuccess) &&
(PvAttrStringSet(Camera.Handle, "MulticastIPAddress", ip.c_str())==ePvErrSuccess))
break;
m_buf_supported = false;
}
-bool BaseImageDecoder::setSource( const std::string& filename )
+bool BaseImageDecoder::setSource( const cv::String& filename )
{
m_filename = filename;
m_buf.release();
{
if( !m_buf_supported )
return false;
- m_filename = std::string();
+ m_filename = cv::String();
m_buf = buf;
return true;
}
return m_signature.size();
}
-bool BaseImageDecoder::checkSignature( const std::string& signature ) const
+bool BaseImageDecoder::checkSignature( const cv::String& signature ) const
{
size_t len = signatureLength();
return signature.size() >= len && memcmp( signature.c_str(), m_signature.c_str(), len ) == 0;
return depth == CV_8U;
}
-std::string BaseImageEncoder::getDescription() const
+cv::String BaseImageEncoder::getDescription() const
{
return m_description;
}
-bool BaseImageEncoder::setDestination( const std::string& filename )
+bool BaseImageEncoder::setDestination( const cv::String& filename )
{
m_filename = filename;
m_buf = 0;
return false;
m_buf = &buf;
m_buf->clear();
- m_filename = std::string();
+ m_filename = cv::String();
return true;
}
{
if(!m_last_error.empty())
{
- std::string msg = "Raw image encoder error: " + m_last_error;
+ cv::String msg = "Raw image encoder error: " + m_last_error;
CV_Error( CV_BadImageSize, msg.c_str() );
}
}
int height() const { return m_height; };
virtual int type() const { return m_type; };
- virtual bool setSource( const std::string& filename );
+ virtual bool setSource( const cv::String& filename );
virtual bool setSource( const Mat& buf );
virtual bool readHeader() = 0;
virtual bool readData( Mat& img ) = 0;
virtual size_t signatureLength() const;
- virtual bool checkSignature( const std::string& signature ) const;
+ virtual bool checkSignature( const cv::String& signature ) const;
virtual ImageDecoder newDecoder() const;
protected:
int m_width; // width of the image ( filled by readHeader )
int m_height; // height of the image ( filled by readHeader )
int m_type;
- std::string m_filename;
- std::string m_signature;
+ cv::String m_filename;
+ cv::String m_signature;
Mat m_buf;
bool m_buf_supported;
};
virtual ~BaseImageEncoder() {};
virtual bool isFormatSupported( int depth ) const;
- virtual bool setDestination( const std::string& filename );
+ virtual bool setDestination( const cv::String& filename );
virtual bool setDestination( std::vector<uchar>& buf );
virtual bool write( const Mat& img, const std::vector<int>& params ) = 0;
- virtual std::string getDescription() const;
+ virtual cv::String getDescription() const;
virtual ImageEncoder newEncoder() const;
virtual void throwOnEror() const;
protected:
- std::string m_description;
+ cv::String m_description;
- std::string m_filename;
+ cv::String m_filename;
std::vector<uchar>* m_buf;
bool m_buf_supported;
- std::string m_last_error;
+ cv::String m_last_error;
};
}
Jpeg2KDecoder::Jpeg2KDecoder()
{
- m_signature = '\0' + std::string() + '\0' + std::string() + '\0' + std::string("\x0cjP \r\n\x87\n");
+ m_signature = '\0' + cv::String() + '\0' + cv::String() + '\0' + cv::String("\x0cjP \r\n\x87\n");
m_stream = 0;
m_image = 0;
}
return 3;
}
-bool PxMDecoder::checkSignature( const std::string& signature ) const
+bool PxMDecoder::checkSignature( const cv::String& signature ) const
{
return signature.size() >= 3 && signature[0] == 'P' &&
'1' <= signature[1] && signature[1] <= '6' &&
void close();
size_t signatureLength() const;
- bool checkSignature( const std::string& signature ) const;
+ bool checkSignature( const cv::String& signature ) const;
ImageDecoder newDecoder() const;
protected:
return 4;
}
-bool TiffDecoder::checkSignature( const std::string& signature ) const
+bool TiffDecoder::checkSignature( const cv::String& signature ) const
{
return signature.size() >= 4 &&
(memcmp(signature.c_str(), fmtSignTiffII, 4) == 0 ||
void close();
size_t signatureLength() const;
- bool checkSignature( const std::string& signature ) const;
+ bool checkSignature( const cv::String& signature ) const;
ImageDecoder newDecoder() const;
protected:
return new WebPDecoder;
}
-bool WebPDecoder::checkSignature( const std::string& signature ) const
+bool WebPDecoder::checkSignature( const cv::String& signature ) const
{
size_t len = signatureLength();
bool ret = false;
bool readData( Mat& img );
bool readHeader();
void close();
- bool checkSignature( const std::string& signature ) const;
+ bool checkSignature( const cv::String& signature ) const;
ImageDecoder newDecoder() const;
static ImageCodecInitializer codecs;
-static ImageDecoder findDecoder( const std::string& filename )
+static ImageDecoder findDecoder( const cv::String& filename )
{
size_t i, maxlen = 0;
for( i = 0; i < codecs.decoders.size(); i++ )
FILE* f= fopen( filename.c_str(), "rb" );
if( !f )
return ImageDecoder();
- std::string signature(maxlen, ' ');
- maxlen = fread( &signature[0], 1, maxlen, f );
+ cv::String signature(maxlen, ' ');
+ maxlen = fread( (void*)signature.c_str(), 1, maxlen, f );
fclose(f);
signature = signature.substr(0, maxlen);
size_t bufSize = buf.rows*buf.cols*buf.elemSize();
maxlen = std::min(maxlen, bufSize);
- std::string signature(maxlen, ' ');
- memcpy( &signature[0], buf.data, maxlen );
+ cv::String signature(maxlen, ' ');
+ memcpy( (void*)signature.c_str(), buf.data, maxlen );
for( i = 0; i < codecs.decoders.size(); i++ )
{
return ImageDecoder();
}
-static ImageEncoder findEncoder( const std::string& _ext )
+static ImageEncoder findEncoder( const cv::String& _ext )
{
if( _ext.size() <= 1 )
return ImageEncoder();
for( size_t i = 0; i < codecs.encoders.size(); i++ )
{
- std::string description = codecs.encoders[i]->getDescription();
+ cv::String description = codecs.encoders[i]->getDescription();
const char* descr = strchr( description.c_str(), '(' );
while( descr )
enum { LOAD_CVMAT=0, LOAD_IMAGE=1, LOAD_MAT=2 };
static void*
-imread_( const std::string& filename, int flags, int hdrtype, Mat* mat=0 )
+imread_( const cv::String& filename, int flags, int hdrtype, Mat* mat=0 )
{
IplImage* image = 0;
CvMat *matrix = 0;
hdrtype == LOAD_IMAGE ? (void*)image : (void*)mat;
}
-Mat imread( const std::string& filename, int flags )
+Mat imread( const cv::String& filename, int flags )
{
Mat img;
imread_( filename, flags, LOAD_MAT, &img );
return img;
}
-static bool imwrite_( const std::string& filename, const Mat& image,
+static bool imwrite_( const cv::String& filename, const Mat& image,
const std::vector<int>& params, bool flipv )
{
Mat temp;
return code;
}
-bool imwrite( const std::string& filename, InputArray _img,
+bool imwrite( const cv::String& filename, InputArray _img,
const std::vector<int>& params )
{
Mat img = _img.getMat();
IplImage* image = 0;
CvMat *matrix = 0;
Mat temp, *data = &temp;
- std::string filename;
+ cv::String filename;
ImageDecoder decoder = findDecoder(buf);
if( decoder.empty() )
return *dst;
}
-bool imencode( const std::string& ext, InputArray _image,
+bool imencode( const cv::String& ext, InputArray _image,
std::vector<uchar>& buf, const std::vector<int>& params )
{
Mat image = _image.getMat();
}
else
{
- std::string filename = tempfile();
+ cv::String filename = tempfile();
code = encoder->setDestination(filename);
CV_Assert( code );
}
}
-void cv::namedWindow( const std::string& winname, int flags )
+void cv::namedWindow( const cv::String& winname, int flags )
{
cvNamedWindow( winname.c_str(), flags );
}
-void cv::destroyWindow( const std::string& winname )
+void cv::destroyWindow( const cv::String& winname )
{
cvDestroyWindow( winname.c_str() );
}
cvDestroyAllWindows();
}
-void cv::resizeWindow( const std::string& winname, int width, int height )
+void cv::resizeWindow( const cv::String& winname, int width, int height )
{
cvResizeWindow( winname.c_str(), width, height );
}
-void cv::moveWindow( const std::string& winname, int x, int y )
+void cv::moveWindow( const cv::String& winname, int x, int y )
{
cvMoveWindow( winname.c_str(), x, y );
}
-void cv::setWindowProperty(const std::string& winname, int prop_id, double prop_value)
+void cv::setWindowProperty(const cv::String& winname, int prop_id, double prop_value)
{
cvSetWindowProperty( winname.c_str(), prop_id, prop_value);
}
-double cv::getWindowProperty(const std::string& winname, int prop_id)
+double cv::getWindowProperty(const cv::String& winname, int prop_id)
{
return cvGetWindowProperty(winname.c_str(), prop_id);
}
return cvWaitKey(delay);
}
-int cv::createTrackbar(const std::string& trackbarName, const std::string& winName,
+int cv::createTrackbar(const cv::String& trackbarName, const cv::String& winName,
int* value, int count, TrackbarCallback callback,
void* userdata)
{
value, count, callback, userdata);
}
-void cv::setTrackbarPos( const std::string& trackbarName, const std::string& winName, int value )
+void cv::setTrackbarPos( const cv::String& trackbarName, const cv::String& winName, int value )
{
cvSetTrackbarPos(trackbarName.c_str(), winName.c_str(), value );
}
-int cv::getTrackbarPos( const std::string& trackbarName, const std::string& winName )
+int cv::getTrackbarPos( const cv::String& trackbarName, const cv::String& winName )
{
return cvGetTrackbarPos(trackbarName.c_str(), winName.c_str());
}
-void cv::setMouseCallback( const std::string& windowName, MouseCallback onMouse, void* param)
+void cv::setMouseCallback( const cv::String& windowName, MouseCallback onMouse, void* param)
{
cvSetMouseCallback(windowName.c_str(), onMouse, param);
}
// OpenGL support
-void cv::setOpenGlDrawCallback(const std::string& name, OpenGlDrawCallback callback, void* userdata)
+void cv::setOpenGlDrawCallback(const cv::String& name, OpenGlDrawCallback callback, void* userdata)
{
cvSetOpenGlDrawCallback(name.c_str(), callback, userdata);
}
-void cv::setOpenGlContext(const std::string& windowName)
+void cv::setOpenGlContext(const cv::String& windowName)
{
cvSetOpenGlContext(windowName.c_str());
}
-void cv::updateWindow(const std::string& windowName)
+void cv::updateWindow(const cv::String& windowName)
{
cvUpdateWindow(windowName.c_str());
}
#ifdef HAVE_OPENGL
namespace
{
- std::map<std::string, cv::ogl::Texture2D> wndTexs;
- std::map<std::string, cv::ogl::Texture2D> ownWndTexs;
- std::map<std::string, cv::ogl::Buffer> ownWndBufs;
+ std::map<cv::String, cv::ogl::Texture2D> wndTexs;
+ std::map<cv::String, cv::ogl::Texture2D> ownWndTexs;
+ std::map<cv::String, cv::ogl::Buffer> ownWndBufs;
void glDrawTextureCallback(void* userdata)
{
}
#endif // HAVE_OPENGL
-void cv::imshow( const std::string& winname, InputArray _img )
+void cv::imshow( const cv::String& winname, InputArray _img )
{
#ifndef HAVE_OPENGL
Mat img = _img.getMat();
#if defined (HAVE_QT)
-CvFont cv::fontQt(const std::string& nameFont, int pointSize, Scalar color, int weight, int style, int /*spacing*/)
+CvFont cv::fontQt(const cv::String& nameFont, int pointSize, Scalar color, int weight, int style, int /*spacing*/)
{
return cvFontQt(nameFont.c_str(), pointSize,color,weight, style);
}
-void cv::addText( const Mat& img, const std::string& text, Point org, CvFont font)
+void cv::addText( const Mat& img, const cv::String& text, Point org, CvFont font)
{
CvMat _img = img;
cvAddText( &_img, text.c_str(), org,&font);
}
-void cv::displayStatusBar(const std::string& name, const std::string& text, int delayms)
+void cv::displayStatusBar(const cv::String& name, const cv::String& text, int delayms)
{
cvDisplayStatusBar(name.c_str(),text.c_str(), delayms);
}
-void cv::displayOverlay(const std::string& name, const std::string& text, int delayms)
+void cv::displayOverlay(const cv::String& name, const cv::String& text, int delayms)
{
cvDisplayOverlay(name.c_str(),text.c_str(), delayms);
}
cvStopLoop();
}
-void cv::saveWindowParameters(const std::string& windowName)
+void cv::saveWindowParameters(const cv::String& windowName)
{
cvSaveWindowParameters(windowName.c_str());
}
-void cv::loadWindowParameters(const std::string& windowName)
+void cv::loadWindowParameters(const cv::String& windowName)
{
cvLoadWindowParameters(windowName.c_str());
}
-int cv::createButton(const std::string& button_name, ButtonCallback on_change, void* userdata, int button_type , bool initial_button_state )
+int cv::createButton(const cv::String& button_name, ButtonCallback on_change, void* userdata, int button_type , bool initial_button_state )
{
return cvCreateButton(button_name.c_str(), on_change, userdata, button_type , initial_button_state );
}
#else
-CvFont cv::fontQt(const std::string&, int, Scalar, int, int, int)
+CvFont cv::fontQt(const cv::String&, int, Scalar, int, int, int)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
return CvFont();
}
-void cv::addText( const Mat&, const std::string&, Point, CvFont)
+void cv::addText( const Mat&, const cv::String&, Point, CvFont)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
}
-void cv::displayStatusBar(const std::string&, const std::string&, int)
+void cv::displayStatusBar(const cv::String&, const cv::String&, int)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
}
-void cv::displayOverlay(const std::string&, const std::string&, int )
+void cv::displayOverlay(const cv::String&, const cv::String&, int )
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
}
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
}
-void cv::saveWindowParameters(const std::string&)
+void cv::saveWindowParameters(const cv::String&)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
}
-void cv::loadWindowParameters(const std::string&)
+void cv::loadWindowParameters(const cv::String&)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
}
-int cv::createButton(const std::string&, ButtonCallback, void*, int , bool )
+int cv::createButton(const cv::String&, ButtonCallback, void*, int , bool )
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
return 0;