Merge pull request #695 from taka-no-me/cv_str
cv::String to replace the std::string
This commit is contained in:
@@ -2457,13 +2457,13 @@ Algorithm::name
|
||||
---------------
|
||||
Returns the algorithm name
|
||||
|
||||
.. ocv:function:: string Algorithm::name() const
|
||||
.. ocv:function:: String Algorithm::name() const
|
||||
|
||||
Algorithm::get
|
||||
--------------
|
||||
Returns the algorithm parameter
|
||||
|
||||
.. ocv:function:: template<typename _Tp> typename ParamType<_Tp>::member_type Algorithm::get(const string& name) const
|
||||
.. ocv:function:: template<typename _Tp> typename ParamType<_Tp>::member_type Algorithm::get(const String& name) const
|
||||
|
||||
:param name: The parameter name.
|
||||
|
||||
@@ -2472,7 +2472,7 @@ The method returns value of the particular parameter. Since the compiler can not
|
||||
* myalgo.get<int>("param_name")
|
||||
* myalgo.get<double>("param_name")
|
||||
* myalgo.get<bool>("param_name")
|
||||
* myalgo.get<string>("param_name")
|
||||
* myalgo.get<String>("param_name")
|
||||
* myalgo.get<Mat>("param_name")
|
||||
* myalgo.get<vector<Mat> >("param_name")
|
||||
* myalgo.get<Algorithm>("param_name") (it returns Ptr<Algorithm>).
|
||||
@@ -2484,13 +2484,13 @@ Algorithm::set
|
||||
--------------
|
||||
Sets the algorithm parameter
|
||||
|
||||
.. ocv:function:: void Algorithm::set(const string& name, int value)
|
||||
.. ocv:function:: void Algorithm::set(const string& name, double value)
|
||||
.. ocv:function:: void Algorithm::set(const string& name, bool value)
|
||||
.. ocv:function:: void Algorithm::set(const string& name, const string& value)
|
||||
.. ocv:function:: void Algorithm::set(const string& name, const Mat& value)
|
||||
.. ocv:function:: void Algorithm::set(const string& name, const vector<Mat>& value)
|
||||
.. ocv:function:: void Algorithm::set(const string& name, const Ptr<Algorithm>& value)
|
||||
.. ocv:function:: void Algorithm::set(const String& name, int value)
|
||||
.. ocv:function:: void Algorithm::set(const String& name, double value)
|
||||
.. ocv:function:: void Algorithm::set(const String& name, bool value)
|
||||
.. ocv:function:: void Algorithm::set(const String& name, const String& value)
|
||||
.. ocv:function:: void Algorithm::set(const String& name, const Mat& value)
|
||||
.. ocv:function:: void Algorithm::set(const String& name, const vector<Mat>& value)
|
||||
.. ocv:function:: void Algorithm::set(const String& name, const Ptr<Algorithm>& value)
|
||||
|
||||
:param name: The parameter name.
|
||||
:param value: The parameter value.
|
||||
@@ -2529,13 +2529,13 @@ Algorithm::getList
|
||||
------------------
|
||||
Returns the list of registered algorithms
|
||||
|
||||
.. ocv:function:: void Algorithm::getList(vector<string>& algorithms)
|
||||
.. ocv:function:: void Algorithm::getList(vector<String>& algorithms)
|
||||
|
||||
:param algorithms: The output vector of algorithm names.
|
||||
|
||||
This static method returns the list of registered algorithms in alphabetical order. Here is how to use it ::
|
||||
|
||||
vector<string> algorithms;
|
||||
vector<String> algorithms;
|
||||
Algorithm::getList(algorithms);
|
||||
cout << "Algorithms: " << algorithms.size() << endl;
|
||||
for (size_t i=0; i < algorithms.size(); i++)
|
||||
@@ -2546,7 +2546,7 @@ Algorithm::create
|
||||
-----------------
|
||||
Creates algorithm instance by name
|
||||
|
||||
.. ocv:function:: template<typename _Tp> Ptr<_Tp> Algorithm::create(const string& name)
|
||||
.. ocv:function:: template<typename _Tp> Ptr<_Tp> Algorithm::create(const String& name)
|
||||
|
||||
:param name: The algorithm name, one of the names returned by ``Algorithm::getList()``.
|
||||
|
||||
|
@@ -10,13 +10,13 @@ CommandLineParser
|
||||
The CommandLineParser class is designed for command line arguments parsing
|
||||
|
||||
|
||||
.. ocv:function:: CommandLineParser::CommandLineParser( int argc, const char* const argv[], const string& keys )
|
||||
.. ocv:function:: CommandLineParser::CommandLineParser( int argc, const char* const argv[], const String& keys )
|
||||
|
||||
:param argc:
|
||||
: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 String& name, bool space_delete = true)
|
||||
|
||||
:param name:
|
||||
:param space_delete:
|
||||
@@ -26,14 +26,14 @@ The CommandLineParser class is designed for command line arguments parsing
|
||||
:param index:
|
||||
:param space_delete:
|
||||
|
||||
.. ocv:function:: bool CommandLineParser::has(const std::string& name)
|
||||
.. ocv:function:: bool CommandLineParser::has(const String& name)
|
||||
|
||||
:param name:
|
||||
|
||||
.. ocv:function:: bool CommandLineParser::check()
|
||||
|
||||
|
||||
.. ocv:function:: void CommandLineParser::about( const string& message )
|
||||
.. ocv:function:: void CommandLineParser::about( const String& message )
|
||||
|
||||
:param message:
|
||||
|
||||
@@ -41,7 +41,7 @@ The CommandLineParser class is designed for command line arguments parsing
|
||||
|
||||
.. ocv:function:: void CommandLineParser::printErrors()
|
||||
|
||||
.. ocv:function:: std::string CommandLineParser::getPathToApplication()
|
||||
.. ocv:function:: String CommandLineParser::getPathToApplication()
|
||||
|
||||
|
||||
The sample below demonstrates how to use CommandLineParser:
|
||||
@@ -59,12 +59,12 @@ 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");
|
||||
String path = parser.get<String>("path");
|
||||
|
||||
use_time_stamp = parser.has("timestamp");
|
||||
|
||||
std::string img1 = parser.get<string>(0);
|
||||
std::string img2 = parser.get<string>(1);
|
||||
String img1 = parser.get<String>(0);
|
||||
String img2 = parser.get<String>(1);
|
||||
|
||||
int repeat = parser.get<int>(2);
|
||||
|
||||
@@ -78,7 +78,7 @@ Syntax:
|
||||
|
||||
::
|
||||
|
||||
const std::string keys =
|
||||
const String keys =
|
||||
"{help h usage ? | | print this message }"
|
||||
"{@image1 | | image1 for compare }"
|
||||
"{@image2 | | image2 for compare }"
|
||||
|
@@ -225,7 +225,7 @@ getTextSize
|
||||
---------------
|
||||
Calculates the width and height of a text string.
|
||||
|
||||
.. ocv:function:: Size getTextSize(const string& text, int fontFace, double fontScale, int thickness, int* baseLine)
|
||||
.. ocv:function:: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine)
|
||||
|
||||
.. ocv:pyfunction:: cv2.getTextSize(text, fontFace, fontScale, thickness) -> retval, baseLine
|
||||
|
||||
@@ -246,7 +246,7 @@ Calculates the width and height of a text string.
|
||||
The function ``getTextSize`` calculates and returns the size of a box that contains the specified text.
|
||||
That is, the following code renders some text, the tight box surrounding it, and the baseline: ::
|
||||
|
||||
string text = "Funny text inside the box";
|
||||
String text = "Funny text inside the box";
|
||||
int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX;
|
||||
double fontScale = 2;
|
||||
int thickness = 3;
|
||||
@@ -570,7 +570,7 @@ putText
|
||||
-----------
|
||||
Draws a text string.
|
||||
|
||||
.. ocv:function:: void putText( Mat& img, const string& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false )
|
||||
.. ocv:function:: void putText( Mat& img, const String& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false )
|
||||
|
||||
.. ocv:pyfunction:: cv2.putText(img, text, org, fontFace, fontScale, color[, thickness[, lineType[, bottomLeftOrigin]]]) -> None
|
||||
|
||||
|
@@ -218,19 +218,19 @@ Exception class passed to an error. ::
|
||||
public:
|
||||
// various constructors and the copy operation
|
||||
Exception() { code = 0; line = 0; }
|
||||
Exception(int _code, const string& _err,
|
||||
const string& _func, const string& _file, int _line);
|
||||
Exception(int _code, const String& _err,
|
||||
const String& _func, const String& _file, int _line);
|
||||
Exception(const Exception& exc);
|
||||
Exception& operator = (const Exception& exc);
|
||||
|
||||
// the error code
|
||||
int code;
|
||||
// the error text message
|
||||
string err;
|
||||
String err;
|
||||
// function name where the error happened
|
||||
string func;
|
||||
String func;
|
||||
// the source file name where the error happened
|
||||
string file;
|
||||
String file;
|
||||
// the source file line where the error happened
|
||||
int line;
|
||||
};
|
||||
@@ -272,7 +272,7 @@ format
|
||||
------
|
||||
Returns a text string formatted using the ``printf``\ -like expression.
|
||||
|
||||
.. ocv:function:: string format( const char* fmt, ... )
|
||||
.. ocv:function:: String format( const char* fmt, ... )
|
||||
|
||||
:param fmt: ``printf`` -compatible formatting specifiers.
|
||||
|
||||
@@ -284,7 +284,7 @@ getBuildInformation
|
||||
-------------------
|
||||
Returns full configuration time cmake output.
|
||||
|
||||
.. ocv:function:: const std::string& getBuildInformation()
|
||||
.. ocv:function:: const 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.
|
||||
|
||||
|
@@ -113,7 +113,7 @@ Here is how to read the file created by the code sample above: ::
|
||||
// first method: use (type) operator on FileNode.
|
||||
int frameCount = (int)fs2["frameCount"];
|
||||
|
||||
std::string date;
|
||||
String date;
|
||||
// second method: use FileNode::operator >>
|
||||
fs2["calibrationDate"] >> date;
|
||||
|
||||
@@ -156,7 +156,7 @@ The constructors.
|
||||
|
||||
.. ocv:function:: FileStorage::FileStorage()
|
||||
|
||||
.. ocv:function:: FileStorage::FileStorage(const string& source, int flags, const string& encoding=string())
|
||||
.. ocv:function:: FileStorage::FileStorage(const String& source, int flags, const String& encoding=String())
|
||||
|
||||
:param source: Name of the file to open or the text string to read the data from. Extension of the file (``.xml`` or ``.yml``/``.yaml``) determines its format (XML or YAML respectively). Also you can append ``.gz`` to work with compressed files, for example ``myHugeMatrix.xml.gz``. If both ``FileStorage::WRITE`` and ``FileStorage::MEMORY`` flags are specified, ``source`` is used just to specify the output file format (e.g. ``mydata.xml``, ``.yml`` etc.).
|
||||
|
||||
@@ -179,7 +179,7 @@ FileStorage::open
|
||||
-----------------
|
||||
Opens a file.
|
||||
|
||||
.. ocv:function:: bool FileStorage::open(const string& filename, int flags, const string& encoding=string())
|
||||
.. ocv:function:: bool FileStorage::open(const String& filename, int flags, const String& encoding=String())
|
||||
|
||||
See description of parameters in :ocv:func:`FileStorage::FileStorage`. The method calls :ocv:func:`FileStorage::release` before opening the file.
|
||||
|
||||
@@ -208,7 +208,7 @@ FileStorage::releaseAndGetString
|
||||
--------------------------------
|
||||
Closes the file and releases all the memory buffers.
|
||||
|
||||
.. ocv:function:: string FileStorage::releaseAndGetString()
|
||||
.. ocv:function:: String FileStorage::releaseAndGetString()
|
||||
|
||||
Call this method after all I/O operations with the storage are finished. If the storage was opened for writing data and ``FileStorage::WRITE`` was specified
|
||||
|
||||
@@ -237,7 +237,7 @@ FileStorage::operator[]
|
||||
-----------------------
|
||||
Returns the specified element of the top-level mapping.
|
||||
|
||||
.. ocv:function:: FileNode FileStorage::operator[](const string& nodename) const
|
||||
.. ocv:function:: FileNode FileStorage::operator[](const String& nodename) const
|
||||
|
||||
.. ocv:function:: FileNode FileStorage::operator[](const char* nodename) const
|
||||
|
||||
@@ -261,7 +261,7 @@ FileStorage::writeRaw
|
||||
---------------------
|
||||
Writes multiple numbers.
|
||||
|
||||
.. ocv:function:: void FileStorage::writeRaw( const string& fmt, const uchar* vec, size_t len )
|
||||
.. ocv:function:: void FileStorage::writeRaw( const String& fmt, const uchar* vec, size_t len )
|
||||
|
||||
:param fmt: Specification of each array element that has the following format ``([count]{'u'|'c'|'w'|'s'|'i'|'f'|'d'})...`` where the characters correspond to fundamental C++ types:
|
||||
|
||||
@@ -293,7 +293,7 @@ FileStorage::writeObj
|
||||
---------------------
|
||||
Writes the registered C structure (CvMat, CvMatND, CvSeq).
|
||||
|
||||
.. ocv:function:: void FileStorage::writeObj( const string& name, const void* obj )
|
||||
.. ocv:function:: void FileStorage::writeObj( const String& name, const void* obj )
|
||||
|
||||
:param name: Name of the written object.
|
||||
|
||||
@@ -306,7 +306,7 @@ FileStorage::getDefaultObjectName
|
||||
---------------------------------
|
||||
Returns the normalized object name for the specified name of a file.
|
||||
|
||||
.. ocv:function:: static string FileStorage::getDefaultObjectName(const string& filename)
|
||||
.. ocv:function:: static String FileStorage::getDefaultObjectName(const String& filename)
|
||||
|
||||
:param filename: Name of a file
|
||||
|
||||
@@ -383,7 +383,7 @@ FileNode::operator[]
|
||||
--------------------
|
||||
Returns element of a mapping node or a sequence node.
|
||||
|
||||
.. ocv:function:: FileNode FileNode::operator[](const string& nodename) const
|
||||
.. ocv:function:: FileNode FileNode::operator[](const String& nodename) const
|
||||
|
||||
.. ocv:function:: FileNode FileNode::operator[](const char* nodename) const
|
||||
|
||||
@@ -507,7 +507,7 @@ FileNode::name
|
||||
--------------
|
||||
Returns the node name.
|
||||
|
||||
.. ocv:function:: string FileNode::name() const
|
||||
.. ocv:function:: String FileNode::name() const
|
||||
|
||||
:returns: The node name or an empty string if the node is nameless.
|
||||
|
||||
@@ -548,11 +548,11 @@ Returns the node content as double.
|
||||
:returns: The node content as double.
|
||||
|
||||
|
||||
FileNode::operator std::string
|
||||
FileNode::operator String
|
||||
------------------------------
|
||||
Returns the node content as text string.
|
||||
|
||||
.. ocv:function:: FileNode::operator std::string() const
|
||||
.. ocv:function:: FileNode::operator String() const
|
||||
|
||||
:returns: The node content as a text string.
|
||||
|
||||
@@ -588,7 +588,7 @@ FileNode::readRaw
|
||||
-----------------
|
||||
Reads node elements to the buffer with the specified format.
|
||||
|
||||
.. ocv:function:: void FileNode::readRaw( const string& fmt, uchar* vec, size_t len ) const
|
||||
.. ocv:function:: void FileNode::readRaw( const String& fmt, uchar* vec, size_t len ) const
|
||||
|
||||
:param fmt: Specification of each array element. It has the same format as in :ocv:func:`FileStorage::writeRaw`.
|
||||
|
||||
@@ -692,7 +692,7 @@ FileNodeIterator::readRaw
|
||||
-------------------------
|
||||
Reads node elements to the buffer with the specified format.
|
||||
|
||||
.. ocv:function:: FileNodeIterator& FileNodeIterator::readRaw( const string& fmt, uchar* vec, size_t maxCount=(size_t)INT_MAX )
|
||||
.. ocv:function:: FileNodeIterator& FileNodeIterator::readRaw( const String& fmt, uchar* vec, size_t maxCount=(size_t)INT_MAX )
|
||||
|
||||
:param fmt: Specification of each array element. It has the same format as in :ocv:func:`FileStorage::writeRaw`.
|
||||
|
||||
|
@@ -47,11 +47,12 @@
|
||||
#define __OPENCV_CORE_HPP__
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
|
||||
#include "opencv2/core/types_c.h"
|
||||
#include "opencv2/core/version.hpp"
|
||||
|
||||
#include "opencv2/core/types_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "opencv2/core/cvstd.hpp"
|
||||
|
||||
#ifndef SKIP_INCLUDES
|
||||
#include <limits.h>
|
||||
@@ -61,7 +62,6 @@
|
||||
#include <complex>
|
||||
#include <map>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#endif // SKIP_INCLUDES
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
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 String& _err, const String& _func, const String& _file, int _line);
|
||||
virtual ~Exception() throw();
|
||||
|
||||
/*!
|
||||
@@ -134,12 +134,12 @@ public:
|
||||
virtual const char *what() const throw();
|
||||
void formatMessage();
|
||||
|
||||
std::string msg; ///< the formatted error message
|
||||
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
|
||||
String err; ///< error description
|
||||
String func; ///< function name. Available only when the compiler supports __func__ macro
|
||||
String file; ///< source file name where the error has occured
|
||||
int line; ///< line number in the source file where the error has occured
|
||||
};
|
||||
|
||||
@@ -2514,13 +2514,13 @@ enum
|
||||
};
|
||||
|
||||
//! 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 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 String& text, int fontFace,
|
||||
double fontScale, int thickness,
|
||||
CV_OUT int* baseLine);
|
||||
|
||||
@@ -3765,7 +3765,7 @@ class CV_EXPORTS FileNode;
|
||||
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"];
|
||||
String test_string = (String)fs["test_string"];
|
||||
|
||||
Mat M;
|
||||
fs["test_mat"] >> M;
|
||||
@@ -3776,7 +3776,7 @@ class CV_EXPORTS FileNode;
|
||||
int tl1 = (int)tl[1];
|
||||
double tl2 = (double)tl[2];
|
||||
int tl3 = (int)tl[3];
|
||||
std::string tl4 = (std::string)tl[4];
|
||||
String tl4 = (String)tl[4];
|
||||
CV_Assert(tl[5].type() == FileNode::MAP && tl[5].size() == 3);
|
||||
|
||||
int month = (int)tl[5]["month"];
|
||||
@@ -3822,27 +3822,27 @@ public:
|
||||
//! 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 String& source, int flags, const String& encoding=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 String& filename, int flags, const String& encoding=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 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 String& nodename) const;
|
||||
//! returns the specified element of the top-level mapping
|
||||
CV_WRAP FileNode operator[](const char* nodename) const;
|
||||
|
||||
@@ -3851,15 +3851,15 @@ public:
|
||||
//! 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 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 String& name, const void* obj );
|
||||
|
||||
//! returns the normalized object name for the specified file name
|
||||
static std::string getDefaultObjectName(const std::string& filename);
|
||||
static String getDefaultObjectName(const String& filename);
|
||||
|
||||
Ptr<CvFileStorage> fs; //!< the underlying C FileStorage structure
|
||||
std::string elname; //!< the currently written element
|
||||
String elname; //!< the currently written element
|
||||
std::vector<char> structs; //!< the stack of written structures
|
||||
int state; //!< the writer state
|
||||
};
|
||||
@@ -3904,7 +3904,7 @@ public:
|
||||
//! the copy constructor
|
||||
FileNode(const FileNode& node);
|
||||
//! returns element of a mapping node
|
||||
FileNode operator[](const std::string& nodename) const;
|
||||
FileNode operator[](const String& nodename) const;
|
||||
//! returns element of a mapping node
|
||||
CV_WRAP FileNode operator[](const char* nodename) const;
|
||||
//! returns element of a sequence node
|
||||
@@ -3929,7 +3929,7 @@ public:
|
||||
//! 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 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.
|
||||
@@ -3939,7 +3939,10 @@ public:
|
||||
//! returns the node content as double
|
||||
operator double() const;
|
||||
//! returns the node content as text string
|
||||
operator String() const;
|
||||
#ifndef OPENCV_NOSTL
|
||||
operator std::string() const;
|
||||
#endif
|
||||
|
||||
//! returns pointer to the underlying file node
|
||||
CvFileNode* operator *();
|
||||
@@ -3952,7 +3955,7 @@ public:
|
||||
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 String& fmt, uchar* vec, size_t len ) const;
|
||||
//! reads the registered object and returns pointer to it
|
||||
void* readObj() const;
|
||||
|
||||
@@ -3995,7 +3998,7 @@ public:
|
||||
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 String& fmt, uchar* vec,
|
||||
size_t maxCount=(size_t)INT_MAX );
|
||||
|
||||
const CvFileStorage* fs;
|
||||
@@ -4151,41 +4154,41 @@ class CV_EXPORTS_W Algorithm
|
||||
public:
|
||||
Algorithm();
|
||||
virtual ~Algorithm();
|
||||
std::string name() const;
|
||||
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 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;
|
||||
CV_WRAP int getInt(const String& name) const;
|
||||
CV_WRAP double getDouble(const String& name) const;
|
||||
CV_WRAP bool getBool(const String& name) const;
|
||||
CV_WRAP String getString(const String& name) const;
|
||||
CV_WRAP Mat getMat(const String& name) const;
|
||||
CV_WRAP std::vector<Mat> getMatVector(const String& name) const;
|
||||
CV_WRAP Ptr<Algorithm> getAlgorithm(const 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);
|
||||
void set(const String& name, int value);
|
||||
void set(const String& name, double value);
|
||||
void set(const String& name, bool value);
|
||||
void set(const String& name, const String& value);
|
||||
void set(const String& name, const Mat& value);
|
||||
void set(const String& name, const std::vector<Mat>& value);
|
||||
void set(const String& name, const Ptr<Algorithm>& value);
|
||||
template<typename _Tp> void set(const 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 void setInt(const String& name, int value);
|
||||
CV_WRAP void setDouble(const String& name, double value);
|
||||
CV_WRAP void setBool(const String& name, bool value);
|
||||
CV_WRAP void setString(const String& name, const String& value);
|
||||
CV_WRAP void setMat(const String& name, const Mat& value);
|
||||
CV_WRAP void setMatVector(const String& name, const std::vector<Mat>& value);
|
||||
CV_WRAP void setAlgorithm(const String& name, const Ptr<Algorithm>& value);
|
||||
template<typename _Tp> void setAlgorithm(const 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 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);
|
||||
@@ -4194,16 +4197,16 @@ public:
|
||||
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 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 String paramHelp(const 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 String& name) const;
|
||||
CV_WRAP void getParams(CV_OUT std::vector<String>& names) const;
|
||||
|
||||
|
||||
virtual void write(FileStorage& fs) const;
|
||||
@@ -4213,9 +4216,9 @@ public:
|
||||
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<String>& algorithms);
|
||||
CV_WRAP static Ptr<Algorithm> _create(const String& name);
|
||||
template<typename _Tp> static Ptr<_Tp> create(const String& name);
|
||||
|
||||
virtual AlgorithmInfo* info() const /* TODO: make it = 0;*/ { return 0; }
|
||||
};
|
||||
@@ -4225,86 +4228,86 @@ class CV_EXPORTS AlgorithmInfo
|
||||
{
|
||||
public:
|
||||
friend class Algorithm;
|
||||
AlgorithmInfo(const std::string& name, Algorithm::Constructor create);
|
||||
AlgorithmInfo(const 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 String& help=String());
|
||||
String paramHelp(const char* name) const;
|
||||
int paramType(const char* name) const;
|
||||
void getParams(std::vector<std::string>& names) const;
|
||||
void getParams(std::vector<String>& names) const;
|
||||
|
||||
void write(const Algorithm* algo, FileStorage& fs) const;
|
||||
void read(Algorithm* algo, const FileNode& fn) const;
|
||||
std::string name() const;
|
||||
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 String& help=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 String& help=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 String& help=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());
|
||||
String& value, bool readOnly=false,
|
||||
String (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(const String&)=0,
|
||||
const String& help=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 String& help=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 String& help=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 String& help=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 String& help=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 String& help=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 String& help=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 String& help=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 String& help=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 String& help=String());
|
||||
protected:
|
||||
AlgorithmInfoData* data;
|
||||
void set(Algorithm* algo, const char* name, int argType,
|
||||
@@ -4320,13 +4323,13 @@ struct CV_EXPORTS Param
|
||||
Param(int _type, bool _readonly, int _offset,
|
||||
Algorithm::Getter _getter=0,
|
||||
Algorithm::Setter _setter=0,
|
||||
const std::string& _help=std::string());
|
||||
const String& _help=String());
|
||||
int type;
|
||||
int offset;
|
||||
bool readonly;
|
||||
Algorithm::Getter getter;
|
||||
Algorithm::Setter setter;
|
||||
std::string help;
|
||||
String help;
|
||||
};
|
||||
|
||||
template<> struct ParamType<bool>
|
||||
@@ -4353,10 +4356,10 @@ template<> struct ParamType<double>
|
||||
enum { type = Param::REAL };
|
||||
};
|
||||
|
||||
template<> struct ParamType<std::string>
|
||||
template<> struct ParamType<String>
|
||||
{
|
||||
typedef const std::string& const_param_type;
|
||||
typedef std::string member_type;
|
||||
typedef const String& const_param_type;
|
||||
typedef String member_type;
|
||||
|
||||
enum { type = Param::STRING };
|
||||
};
|
||||
@@ -4419,9 +4422,11 @@ template<> struct ParamType<uchar>
|
||||
|
||||
} //namespace cv
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#include "opencv2/core/operations.hpp"
|
||||
#include "opencv2/core/mat.hpp"
|
||||
|
||||
#include "opencv2/core/cvstd.inl.hpp"
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
#endif /*__OPENCV_CORE_HPP__*/
|
||||
|
470
modules/core/include/opencv2/core/cvstd.hpp
Normal file
470
modules/core/include/opencv2/core/cvstd.hpp
Normal file
@@ -0,0 +1,470 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_CVSTD_HPP__
|
||||
#define __OPENCV_CORE_CVSTD_HPP__
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
# include <string>
|
||||
#endif
|
||||
|
||||
// import useful primitives from stl
|
||||
#ifndef OPENCV_NOSTL_TRANSITIONAL
|
||||
# include <algorithm>
|
||||
# include <utility>
|
||||
# include <cmath>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
using std::min;
|
||||
using std::max;
|
||||
using std::abs;
|
||||
using std::swap;
|
||||
}
|
||||
|
||||
#else
|
||||
namespace cv
|
||||
{
|
||||
template<typename T> inline T min(T a, T b) { return a < b ? a : b; }
|
||||
template<typename T> inline T max(T a, T b) { return a > b ? a : b; }
|
||||
template<typename T> inline T abs(T a) { return a < 0 ? -a : a; }
|
||||
template<typename T> inline void swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
|
||||
|
||||
template<> inline uchar abs(uchar a) { return a; }
|
||||
template<> inline ushort abs(ushort a) { return a; }
|
||||
template<> inline uint abs(uint a) { return a; }
|
||||
template<> inline uint64 abs(uint64 a) { return a; }
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace cv {
|
||||
|
||||
class CV_EXPORTS FileNode; //for string constructor from FileNode
|
||||
|
||||
class CV_EXPORTS String
|
||||
{
|
||||
public:
|
||||
typedef char value_type;
|
||||
typedef char& reference;
|
||||
typedef const char& const_reference;
|
||||
typedef char* pointer;
|
||||
typedef const char* const_pointer;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef size_t size_type;
|
||||
|
||||
typedef char* iterator;
|
||||
typedef const char* const_iterator;
|
||||
|
||||
static const size_t npos = size_t(-1);
|
||||
|
||||
explicit String() : cstr_(0), len_(0) {}
|
||||
|
||||
String(const String& str) : cstr_(str.cstr_), len_(str.len_)
|
||||
{
|
||||
if (cstr_) CV_XADD(((int*)cstr_)-1, 1);
|
||||
}
|
||||
|
||||
String(const String& str, size_t pos, size_t len = npos) : cstr_(0), len_(0)
|
||||
{
|
||||
pos = min(pos, str.len_);
|
||||
len = min(str.len_ - pos, len);
|
||||
if (!len) return;
|
||||
if (len == str.len_)
|
||||
{
|
||||
CV_XADD(((int*)str.cstr_)-1, 1);
|
||||
cstr_ = str.cstr_;
|
||||
len_ = str.len_;
|
||||
return;
|
||||
}
|
||||
memcpy(allocate(len), str.cstr_ + pos, len);
|
||||
}
|
||||
|
||||
String(const char* s): cstr_(0), len_(0)
|
||||
{
|
||||
if (!s) return;
|
||||
size_t len = strlen(s);
|
||||
memcpy(allocate(len), s, len);
|
||||
}
|
||||
|
||||
String(const char* s, size_t n): cstr_(0), len_(0)
|
||||
{
|
||||
if (!n) return;
|
||||
memcpy(allocate(n), s, n);
|
||||
}
|
||||
|
||||
String(size_t n, char c): cstr_(0), len_(0)
|
||||
{
|
||||
memset(allocate(n), c, n);
|
||||
}
|
||||
|
||||
String(const char* first, const char* last): cstr_(0), len_(0)
|
||||
{
|
||||
size_t len = (size_t)(last - first);
|
||||
memcpy(allocate(len), first, len);
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
String(Iterator first, Iterator last): cstr_(0), len_(0)
|
||||
{
|
||||
size_t len = (size_t)(last - first);
|
||||
char* str = allocate(len);
|
||||
while (first != last)
|
||||
{
|
||||
*str++ = *first;
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
~String() { deallocate(); }
|
||||
|
||||
String& operator=(const String& str)
|
||||
{
|
||||
deallocate();
|
||||
if (str.cstr_) CV_XADD(((int*)str.cstr_)-1, 1);
|
||||
cstr_ = str.cstr_;
|
||||
len_ = str.len_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
String& operator=(const char* s)
|
||||
{
|
||||
deallocate();
|
||||
if (!s) return *this;
|
||||
size_t len = strlen(s);
|
||||
memcpy(allocate(len), s, len);
|
||||
return *this;
|
||||
}
|
||||
|
||||
String& operator=(char c)
|
||||
{
|
||||
deallocate();
|
||||
allocate(1)[0] = c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
size_t size() const { return len_; }
|
||||
size_t length() const { return len_; }
|
||||
|
||||
char operator[](size_t idx) const { return cstr_[idx]; }
|
||||
char operator[](int idx) const { return cstr_[idx]; }
|
||||
|
||||
const char* begin() const { return cstr_; }
|
||||
const char* end() const { return len_ ? cstr_ + 1 : 0; }
|
||||
|
||||
bool empty() const { return len_ == 0; }
|
||||
|
||||
const char* c_str() const { return cstr_ ? cstr_ : ""; }
|
||||
|
||||
void swap(String& str)
|
||||
{
|
||||
cv::swap(cstr_, str.cstr_);
|
||||
cv::swap(len_, str.len_);
|
||||
}
|
||||
|
||||
void clear() { deallocate(); }
|
||||
|
||||
int compare(const char* s) const
|
||||
{
|
||||
if (cstr_ == s) return 0;
|
||||
|
||||
return strcmp(c_str(), s);
|
||||
}
|
||||
|
||||
int compare(const String& str) const
|
||||
{
|
||||
if (cstr_ == str.cstr_) return 0;
|
||||
|
||||
return strcmp(c_str(), str.c_str());
|
||||
}
|
||||
|
||||
String substr(size_t pos = 0, size_t len = npos) const
|
||||
{
|
||||
return String(*this, pos, len);
|
||||
}
|
||||
|
||||
size_t find(const char* s, size_t pos, size_t n) const
|
||||
{
|
||||
if (n == 0 || pos + n > len_) return npos;
|
||||
const char* lmax = cstr_ + len_ - n;
|
||||
for (const char* i = cstr_ + pos; i <= lmax; ++i)
|
||||
{
|
||||
size_t j = 0;
|
||||
while (j < n && s[j] == i[j]) ++j;
|
||||
if (j == n) return (size_t)(i - cstr_);
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
size_t find(char c, size_t pos = 0) const
|
||||
{
|
||||
return find(&c, pos, 1);
|
||||
}
|
||||
|
||||
size_t find(const String& str, size_t pos = 0) const
|
||||
{
|
||||
return find(str.c_str(), pos, str.len_);
|
||||
}
|
||||
|
||||
size_t find(const char* s, size_t pos = 0) const
|
||||
{
|
||||
if (pos >= len_ || !s[0]) return npos;
|
||||
const char* lmax = cstr_ + len_;
|
||||
for (const char* i = cstr_ + pos; i < lmax; ++i)
|
||||
{
|
||||
size_t j = 0;
|
||||
while (s[j] && s[j] == i[j])
|
||||
{ if(i + j >= lmax) return npos;
|
||||
++j;
|
||||
}
|
||||
if (!s[j]) return (size_t)(i - cstr_);
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
size_t rfind(const char* s, size_t pos, size_t n) const
|
||||
{
|
||||
if (n > len_) return npos;
|
||||
if (pos > len_ - n) pos = len_ - n;
|
||||
for (const char* i = cstr_ + pos; i >= cstr_; --i)
|
||||
{
|
||||
size_t j = 0;
|
||||
while (j < n && s[j] == i[j]) ++j;
|
||||
if (j == n) return (size_t)(i - cstr_);
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
size_t rfind(char c, size_t pos = npos) const
|
||||
{
|
||||
return rfind(&c, pos, 1);
|
||||
}
|
||||
|
||||
size_t rfind(const String& str, size_t pos = npos) const
|
||||
{
|
||||
return rfind(str.c_str(), pos, str.len_);
|
||||
}
|
||||
|
||||
size_t rfind(const char* s, size_t pos = npos) const
|
||||
{
|
||||
return rfind(s, pos, strlen(s));
|
||||
}
|
||||
|
||||
size_t find_first_of(const char* s, size_t pos, size_t n) const
|
||||
{
|
||||
if (n == 0 || pos + n > len_) return npos;
|
||||
const char* lmax = cstr_ + len_;
|
||||
for (const char* i = cstr_ + pos; i < lmax; ++i)
|
||||
{
|
||||
for (size_t j = 0; j < n; ++j)
|
||||
if (s[j] == *i)
|
||||
return (size_t)(i - cstr_);
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
size_t find_first_of(char c, size_t pos = 0) const
|
||||
{
|
||||
return find_first_of(&c, pos, 1);
|
||||
}
|
||||
|
||||
size_t find_first_of(const String& str, size_t pos = 0) const
|
||||
{
|
||||
return find_first_of(str.c_str(), pos, str.len_);
|
||||
}
|
||||
|
||||
size_t find_first_of(const char* s, size_t pos = 0) const
|
||||
{
|
||||
if (pos >= len_ || !s[0]) return npos;
|
||||
const char* lmax = cstr_ + len_;
|
||||
for (const char* i = cstr_ + pos; i < lmax; ++i)
|
||||
{
|
||||
for (size_t j = 0; s[j]; ++j)
|
||||
if (s[j] == *i)
|
||||
return (size_t)(i - cstr_);
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
size_t find_last_of(const char* s, size_t pos, size_t n) const
|
||||
{
|
||||
if (pos >= len_) pos = len_ - 1;
|
||||
for (const char* i = cstr_ + pos; i >= cstr_; --i)
|
||||
{
|
||||
for (size_t j = 0; j < n; ++j)
|
||||
if (s[j] == *i)
|
||||
return (size_t)(i - cstr_);
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
size_t find_last_of(char c, size_t pos = npos) const
|
||||
{
|
||||
return find_last_of(&c, pos, 1);
|
||||
}
|
||||
|
||||
size_t find_last_of(const String& str, size_t pos = npos) const
|
||||
{
|
||||
return find_last_of(str.c_str(), pos, str.len_);
|
||||
}
|
||||
|
||||
size_t find_last_of(const char* s, size_t pos = npos) const
|
||||
{
|
||||
if (pos >= len_) pos = len_ - 1;
|
||||
for (const char* i = cstr_ + pos; i >= cstr_; --i)
|
||||
{
|
||||
for (size_t j = 0; s[j]; ++j)
|
||||
if (s[j] == *i)
|
||||
return (size_t)(i - cstr_);
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
friend String operator+ (const String& lhs, const String& rhs);
|
||||
friend String operator+ (const String& lhs, const char* rhs);
|
||||
friend String operator+ (const char* lhs, const String& rhs);
|
||||
friend String operator+ (const String& lhs, char rhs);
|
||||
friend String operator+ (char lhs, const String& rhs);
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
String(const std::string& str);
|
||||
String(const std::string& str, size_t pos, size_t len = npos);
|
||||
String& operator=(const std::string& str);
|
||||
operator std::string() const;
|
||||
|
||||
friend String operator+ (const String& lhs, const std::string& rhs);
|
||||
friend String operator+ (const std::string& lhs, const String& rhs);
|
||||
#endif
|
||||
|
||||
explicit String(const FileNode& fn);
|
||||
|
||||
private:
|
||||
char* cstr_;
|
||||
size_t len_;
|
||||
|
||||
char* allocate(size_t len); // len_ without trailing 0
|
||||
void deallocate();
|
||||
};
|
||||
|
||||
inline String operator+ (const String& lhs, const String& rhs)
|
||||
{
|
||||
String s;
|
||||
s.allocate(lhs.len_ + rhs.len_);
|
||||
memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
memcpy(s.cstr_ + lhs.len_, rhs.cstr_, rhs.len_);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline String operator+ (const String& lhs, const char* rhs)
|
||||
{
|
||||
String s;
|
||||
size_t rhslen = strlen(rhs);
|
||||
s.allocate(lhs.len_ + rhslen);
|
||||
memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
memcpy(s.cstr_ + lhs.len_, rhs, rhslen);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline String operator+ (const char* lhs, const String& rhs)
|
||||
{
|
||||
String s;
|
||||
size_t lhslen = strlen(lhs);
|
||||
s.allocate(lhslen + rhs.len_);
|
||||
memcpy(s.cstr_, lhs, lhslen);
|
||||
memcpy(s.cstr_ + lhslen, rhs.cstr_, rhs.len_);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline String operator+ (const String& lhs, char rhs)
|
||||
{
|
||||
String s;
|
||||
s.allocate(lhs.len_ + 1);
|
||||
memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
s.cstr_[lhs.len_] = rhs;
|
||||
return s;
|
||||
}
|
||||
|
||||
inline String operator+ (char lhs, const String& rhs)
|
||||
{
|
||||
String s;
|
||||
s.allocate(rhs.len_ + 1);
|
||||
s.cstr_[0] = lhs;
|
||||
memcpy(s.cstr_ + 1, rhs.cstr_, rhs.len_);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline bool operator== (const String& lhs, const String& rhs) { return 0 == lhs.compare(rhs); }
|
||||
inline bool operator== (const char* lhs, const String& rhs) { return 0 == rhs.compare(lhs); }
|
||||
inline bool operator== (const String& lhs, const char* rhs) { return 0 == lhs.compare(rhs); }
|
||||
inline bool operator!= (const String& lhs, const String& rhs) { return 0 != lhs.compare(rhs); }
|
||||
inline bool operator!= (const char* lhs, const String& rhs) { return 0 != rhs.compare(lhs); }
|
||||
inline bool operator!= (const String& lhs, const char* rhs) { return 0 != lhs.compare(rhs); }
|
||||
inline bool operator< (const String& lhs, const String& rhs) { return lhs.compare(rhs) < 0; }
|
||||
inline bool operator< (const char* lhs, const String& rhs) { return rhs.compare(lhs) > 0; }
|
||||
inline bool operator< (const String& lhs, const char* rhs) { return lhs.compare(rhs) < 0; }
|
||||
inline bool operator<= (const String& lhs, const String& rhs) { return lhs.compare(rhs) <= 0; }
|
||||
inline bool operator<= (const char* lhs, const String& rhs) { return rhs.compare(lhs) >= 0; }
|
||||
inline bool operator<= (const String& lhs, const char* rhs) { return lhs.compare(rhs) <= 0; }
|
||||
inline bool operator> (const String& lhs, const String& rhs) { return lhs.compare(rhs) > 0; }
|
||||
inline bool operator> (const char* lhs, const String& rhs) { return rhs.compare(lhs) < 0; }
|
||||
inline bool operator> (const String& lhs, const char* rhs) { return lhs.compare(rhs) > 0; }
|
||||
inline bool operator>= (const String& lhs, const String& rhs) { return lhs.compare(rhs) >= 0; }
|
||||
inline bool operator>= (const char* lhs, const String& rhs) { return rhs.compare(lhs) <= 0; }
|
||||
inline bool operator>= (const String& lhs, const char* rhs) { return lhs.compare(rhs) >= 0; }
|
||||
|
||||
} // cv
|
||||
|
||||
#ifndef OPENCV_NOSTL_TRANSITIONAL
|
||||
namespace std
|
||||
#else
|
||||
namespace cv
|
||||
#endif
|
||||
{
|
||||
template<> inline void swap<cv::String>(cv::String& a, cv::String& b) { a.swap(b); }
|
||||
}
|
||||
|
||||
#endif //__OPENCV_CORE_CVSTD_HPP__
|
131
modules/core/include/opencv2/core/cvstd.inl.hpp
Normal file
131
modules/core/include/opencv2/core/cvstd.inl.hpp
Normal file
@@ -0,0 +1,131 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_CVSTDINL_HPP__
|
||||
#define __OPENCV_CORE_CVSTDINL_HPP__
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
# include <ostream>
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
#ifndef OPENCV_NOSTL
|
||||
|
||||
inline String::String(const std::string& str) : cstr_(0), len_(0)
|
||||
{
|
||||
if (!str.empty())
|
||||
{
|
||||
size_t len = str.size();
|
||||
memcpy(allocate(len), str.c_str(), len);
|
||||
}
|
||||
}
|
||||
|
||||
inline String::String(const std::string& str, size_t pos, size_t len) : cstr_(0), len_(0)
|
||||
{
|
||||
size_t strlen = str.size();
|
||||
pos = max(pos, strlen);
|
||||
len = min(strlen - pos, len);
|
||||
if (!len) return;
|
||||
memcpy(allocate(len), str.c_str() + pos, len);
|
||||
}
|
||||
|
||||
inline String& String::operator=(const std::string& str)
|
||||
{
|
||||
deallocate();
|
||||
if (!str.empty())
|
||||
{
|
||||
size_t len = str.size();
|
||||
memcpy(allocate(len), str.c_str(), len);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline String::operator std::string() const
|
||||
{
|
||||
return std::string(cstr_, len_);
|
||||
}
|
||||
|
||||
inline String operator+ (const String& lhs, const std::string& rhs)
|
||||
{
|
||||
String s;
|
||||
size_t rhslen = rhs.size();
|
||||
s.allocate(lhs.len_ + rhslen);
|
||||
memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
memcpy(s.cstr_ + lhs.len_, rhs.c_str(), rhslen);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline String operator+ (const std::string& lhs, const String& rhs)
|
||||
{
|
||||
String s;
|
||||
size_t lhslen = lhs.size();
|
||||
s.allocate(lhslen + rhs.len_);
|
||||
memcpy(s.cstr_, lhs.c_str(), lhslen);
|
||||
memcpy(s.cstr_ + lhslen, rhs.cstr_, rhs.len_);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline std::ostream& operator << (std::ostream& os, const String& str)
|
||||
{
|
||||
return os << str.c_str();
|
||||
}
|
||||
|
||||
inline FileNode::operator std::string() const
|
||||
{
|
||||
String value;
|
||||
read(*this, value, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
template<> inline void operator >> (const FileNode& n, std::string& value)
|
||||
{
|
||||
String val;
|
||||
read(n, val, val);
|
||||
value = val;
|
||||
}
|
||||
|
||||
#endif // OPENCV_NOSTL
|
||||
} // cv
|
||||
|
||||
#endif // __OPENCV_CORE_CVSTDINL_HPP__
|
@@ -247,7 +247,7 @@ namespace cv { namespace gpu
|
||||
// Creates DeviceInfo object for the given GPU
|
||||
DeviceInfo(int device_id) : device_id_(device_id) { query(); }
|
||||
|
||||
std::string name() const { return name_; }
|
||||
String name() const { return name_; }
|
||||
|
||||
// Return compute capability versions
|
||||
int majorVersion() const { return majorVersion_; }
|
||||
@@ -274,7 +274,7 @@ namespace cv { namespace gpu
|
||||
|
||||
int device_id_;
|
||||
|
||||
std::string name_;
|
||||
String name_;
|
||||
int multi_processor_count_;
|
||||
int majorVersion_;
|
||||
int minorVersion_;
|
||||
|
@@ -2648,18 +2648,18 @@ template<> CV_EXPORTS void Ptr<CvFileStorage>::delete_obj();
|
||||
|
||||
//////////////////////////////////////// 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 String& name, int value );
|
||||
CV_EXPORTS_W void write( FileStorage& fs, const String& name, float value );
|
||||
CV_EXPORTS_W void write( FileStorage& fs, const String& name, double value );
|
||||
CV_EXPORTS_W void write( FileStorage& fs, const String& name, const String& value );
|
||||
|
||||
template<typename _Tp> inline void write(FileStorage& fs, const _Tp& value)
|
||||
{ write(fs, std::string(), value); }
|
||||
{ write(fs, 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 String& value );
|
||||
|
||||
template<> inline void write( FileStorage& fs, const int& value )
|
||||
{
|
||||
@@ -2676,7 +2676,7 @@ template<> inline void write( FileStorage& fs, const double& value )
|
||||
writeScalar(fs, value);
|
||||
}
|
||||
|
||||
template<> inline void write( FileStorage& fs, const std::string& value )
|
||||
template<> inline void write( FileStorage& fs, const String& value )
|
||||
{
|
||||
writeScalar(fs, value);
|
||||
}
|
||||
@@ -2737,20 +2737,20 @@ inline void write(FileStorage& fs, const Range& r )
|
||||
class CV_EXPORTS WriteStructContext
|
||||
{
|
||||
public:
|
||||
WriteStructContext(FileStorage& _fs, const std::string& name,
|
||||
int flags, const std::string& typeName=std::string());
|
||||
WriteStructContext(FileStorage& _fs, const String& name,
|
||||
int flags, const String& typeName=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 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 String& name, const Point3_<_Tp>& pt )
|
||||
{
|
||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
||||
write(fs, pt.x);
|
||||
@@ -2758,21 +2758,21 @@ template<typename _Tp> inline void write(FileStorage& fs, const std::string& nam
|
||||
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 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 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 String& name, const Rect_<_Tp>& r )
|
||||
{
|
||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
||||
write(fs, r.x);
|
||||
@@ -2781,14 +2781,14 @@ template<typename _Tp> inline void write(FileStorage& fs, const std::string& nam
|
||||
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 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 String& name, const Scalar_<_Tp>& s )
|
||||
{
|
||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
||||
write(fs, s.val[0]);
|
||||
@@ -2797,7 +2797,7 @@ template<typename _Tp> inline void write(FileStorage& fs, const std::string& nam
|
||||
write(fs, s.val[3]);
|
||||
}
|
||||
|
||||
inline void write(FileStorage& fs, const std::string& name, const Range& r )
|
||||
inline void write(FileStorage& fs, const String& name, const Range& r )
|
||||
{
|
||||
WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW);
|
||||
write(fs, r.start);
|
||||
@@ -2825,7 +2825,7 @@ public:
|
||||
{
|
||||
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( String(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, vec.size()*sizeof(_Tp) );
|
||||
}
|
||||
FileStorage* fs;
|
||||
};
|
||||
@@ -2836,15 +2836,15 @@ template<typename _Tp> static inline void write( FileStorage& fs, const std::vec
|
||||
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 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 String& name, const Mat& value );
|
||||
CV_EXPORTS void write( FileStorage& fs, const String& name, const SparseMat& value );
|
||||
|
||||
template<typename _Tp> static inline FileStorage& operator << (FileStorage& fs, const _Tp& value)
|
||||
{
|
||||
@@ -2858,10 +2858,10 @@ template<typename _Tp> static inline FileStorage& operator << (FileStorage& fs,
|
||||
return fs;
|
||||
}
|
||||
|
||||
CV_EXPORTS FileStorage& operator << (FileStorage& fs, const std::string& str);
|
||||
CV_EXPORTS FileStorage& operator << (FileStorage& fs, const String& str);
|
||||
|
||||
static inline FileStorage& operator << (FileStorage& fs, const char* str)
|
||||
{ return (fs << std::string(str)); }
|
||||
{ return (fs << String(str)); }
|
||||
|
||||
inline FileNode::FileNode() : fs(0), node(0) {}
|
||||
inline FileNode::FileNode(const CvFileStorage* _fs, const CvFileNode* _node)
|
||||
@@ -2939,9 +2939,9 @@ static inline void read(const FileNode& node, double& value, double default_valu
|
||||
CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : 1e300;
|
||||
}
|
||||
|
||||
static inline void read(const FileNode& node, std::string& value, const std::string& default_value)
|
||||
static inline void read(const FileNode& node, String& value, const String& default_value)
|
||||
{
|
||||
value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? std::string(node.node->data.str.ptr) : std::string("");
|
||||
value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? String(node.node->data.str.ptr) : String();
|
||||
}
|
||||
|
||||
CV_EXPORTS_W void read(const FileNode& node, Mat& mat, const Mat& default_mat=Mat() );
|
||||
@@ -2965,14 +2965,19 @@ inline FileNode::operator double() const
|
||||
read(*this, value, 0.);
|
||||
return value;
|
||||
}
|
||||
inline FileNode::operator std::string() const
|
||||
inline FileNode::operator String() const
|
||||
{
|
||||
std::string value;
|
||||
String value;
|
||||
read(*this, value, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
inline void FileNode::readRaw( const std::string& fmt, uchar* vec, size_t len ) const
|
||||
inline String::String(const FileNode& fn): cstr_(0), len_(0)
|
||||
{
|
||||
read(fn, *this, *this);
|
||||
}
|
||||
|
||||
inline void FileNode::readRaw( const String& fmt, uchar* vec, size_t len ) const
|
||||
{
|
||||
begin().readRaw( fmt, vec, len );
|
||||
}
|
||||
@@ -3003,7 +3008,7 @@ public:
|
||||
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( String(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, count*sizeof(_Tp) );
|
||||
}
|
||||
FileNodeIterator* it;
|
||||
};
|
||||
@@ -3694,7 +3699,7 @@ public:
|
||||
{
|
||||
FileStorage fs(_fs);
|
||||
fs.fs.addref();
|
||||
((const _ClsName*)ptr)->write(fs, std::string(name));
|
||||
((const _ClsName*)ptr)->write(fs, String(name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3856,7 +3861,7 @@ template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const
|
||||
}
|
||||
|
||||
|
||||
template<typename _Tp> inline Ptr<_Tp> Algorithm::create(const std::string& name)
|
||||
template<typename _Tp> inline Ptr<_Tp> Algorithm::create(const String& name)
|
||||
{
|
||||
return _create(name).ptr<_Tp>();
|
||||
}
|
||||
@@ -3872,7 +3877,7 @@ inline void Algorithm::set(const char* _name, const Ptr<_Tp>& value)
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline void Algorithm::set(const std::string& _name, const Ptr<_Tp>& value)
|
||||
inline void Algorithm::set(const String& _name, const Ptr<_Tp>& value)
|
||||
{
|
||||
this->set<_Tp>(_name.c_str(), value);
|
||||
}
|
||||
@@ -3888,12 +3893,12 @@ inline void Algorithm::setAlgorithm(const char* _name, const Ptr<_Tp>& value)
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline void Algorithm::setAlgorithm(const std::string& _name, const Ptr<_Tp>& value)
|
||||
inline void Algorithm::setAlgorithm(const 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 String& _name) const
|
||||
{
|
||||
typename ParamType<_Tp>::member_type value;
|
||||
info()->get(this, _name.c_str(), ParamType<_Tp>::type, &value);
|
||||
@@ -3909,7 +3914,7 @@ template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::ge
|
||||
|
||||
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 String& help)
|
||||
{
|
||||
//TODO: static assert: _Tp inherits from _Base
|
||||
addParam_(algo, parameter, ParamType<_Base>::type, &value, readOnly,
|
||||
@@ -3918,7 +3923,7 @@ template<typename _Tp, typename _Base> inline void AlgorithmInfo::addParam(Algor
|
||||
|
||||
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 String& help)
|
||||
{
|
||||
//TODO: static assert: _Tp inherits from Algorithm
|
||||
addParam_(algo, parameter, ParamType<Algorithm>::type, &value, readOnly,
|
||||
|
@@ -143,14 +143,14 @@ typedef int (CV_CDECL *ErrorCallback)( int status, const char* func_name,
|
||||
*/
|
||||
CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback, void* userdata=0, void** prevUserdata=0);
|
||||
|
||||
CV_EXPORTS std::string format( const char* fmt, ... );
|
||||
CV_EXPORTS std::string tempfile( const char* suffix CV_DEFAULT(0));
|
||||
CV_EXPORTS void glob(std::string pattern, std::vector<std::string>& result, bool recursive = false);
|
||||
CV_EXPORTS String format( const char* fmt, ... );
|
||||
CV_EXPORTS String tempfile( const char* suffix CV_DEFAULT(0));
|
||||
CV_EXPORTS void glob(String pattern, std::vector<String>& result, bool recursive = false);
|
||||
CV_EXPORTS void setNumThreads(int nthreads);
|
||||
CV_EXPORTS int getNumThreads();
|
||||
CV_EXPORTS int getThreadNum();
|
||||
|
||||
CV_EXPORTS_W const std::string& getBuildInformation();
|
||||
CV_EXPORTS_W const String& getBuildInformation();
|
||||
|
||||
//! Returns the number of ticks.
|
||||
|
||||
@@ -297,19 +297,19 @@ protected:
|
||||
class CV_EXPORTS CommandLineParser
|
||||
{
|
||||
public:
|
||||
CommandLineParser(int argc, const char* const argv[], const std::string& keys);
|
||||
CommandLineParser(int argc, const char* const argv[], const String& keys);
|
||||
CommandLineParser(const CommandLineParser& parser);
|
||||
CommandLineParser& operator = (const CommandLineParser& parser);
|
||||
|
||||
std::string getPathToApplication() const;
|
||||
String getPathToApplication() const;
|
||||
|
||||
template <typename T>
|
||||
T get(const std::string& name, bool space_delete = true) const
|
||||
{
|
||||
T get(const String& name, bool space_delete = true) const
|
||||
{
|
||||
T val = T();
|
||||
getByName(name, space_delete, ParamType<T>::type, (void*)&val);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T get(int index, bool space_delete = true) const
|
||||
@@ -319,17 +319,17 @@ class CV_EXPORTS CommandLineParser
|
||||
return val;
|
||||
}
|
||||
|
||||
bool has(const std::string& name) const;
|
||||
bool has(const String& name) const;
|
||||
|
||||
bool check() const;
|
||||
|
||||
void about(const std::string& message);
|
||||
void about(const String& message);
|
||||
|
||||
void printMessage() const;
|
||||
void printErrors() const;
|
||||
|
||||
protected:
|
||||
void getByName(const std::string& name, bool space_delete, int type, void* dst) const;
|
||||
void getByName(const String& name, bool space_delete, int type, void* dst) const;
|
||||
void getByIndex(int index, bool space_delete, int type, void* dst) const;
|
||||
|
||||
struct Impl;
|
||||
@@ -454,6 +454,17 @@ static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMod
|
||||
return cvarrToMat(arr, copyData, true, coiMode);
|
||||
}
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
template<> inline std::string CommandLineParser::get<std::string>(int index, bool space_delete) const
|
||||
{
|
||||
return get<String>(index, space_delete);
|
||||
}
|
||||
template<> inline std::string CommandLineParser::get<std::string>(const String& name, bool space_delete) const
|
||||
{
|
||||
return get<String>(name, space_delete);
|
||||
}
|
||||
#endif // OPENCV_NOSTL
|
||||
|
||||
} //namespace cv
|
||||
|
||||
#endif //__OPENCV_CORE_UTILITY_H__
|
||||
|
@@ -96,7 +96,7 @@ template<typename _KeyTp, typename _ValueTp> struct sorted_vector
|
||||
};
|
||||
|
||||
|
||||
template<typename _ValueTp> inline const _ValueTp* findstr(const sorted_vector<std::string, _ValueTp>& vec,
|
||||
template<typename _ValueTp> inline const _ValueTp* findstr(const sorted_vector<String, _ValueTp>& vec,
|
||||
const char* key)
|
||||
{
|
||||
if( !key )
|
||||
@@ -130,7 +130,7 @@ Param::Param()
|
||||
|
||||
Param::Param(int _type, bool _readonly, int _offset,
|
||||
Algorithm::Getter _getter, Algorithm::Setter _setter,
|
||||
const std::string& _help)
|
||||
const String& _help)
|
||||
{
|
||||
type = _type;
|
||||
readonly = _readonly;
|
||||
@@ -142,23 +142,23 @@ Param::Param(int _type, bool _readonly, int _offset,
|
||||
|
||||
struct CV_EXPORTS AlgorithmInfoData
|
||||
{
|
||||
sorted_vector<std::string, Param> params;
|
||||
std::string _name;
|
||||
sorted_vector<String, Param> params;
|
||||
String _name;
|
||||
};
|
||||
|
||||
|
||||
static sorted_vector<std::string, Algorithm::Constructor>& alglist()
|
||||
static sorted_vector<String, Algorithm::Constructor>& alglist()
|
||||
{
|
||||
static sorted_vector<std::string, Algorithm::Constructor> alglist_var;
|
||||
static sorted_vector<String, Algorithm::Constructor> alglist_var;
|
||||
return alglist_var;
|
||||
}
|
||||
|
||||
void Algorithm::getList(std::vector<std::string>& algorithms)
|
||||
void Algorithm::getList(std::vector<String>& algorithms)
|
||||
{
|
||||
alglist().get_keys(algorithms);
|
||||
}
|
||||
|
||||
Ptr<Algorithm> Algorithm::_create(const std::string& name)
|
||||
Ptr<Algorithm> Algorithm::_create(const String& name)
|
||||
{
|
||||
Algorithm::Constructor c = 0;
|
||||
if( !alglist().find(name, c) )
|
||||
@@ -174,42 +174,42 @@ Algorithm::~Algorithm()
|
||||
{
|
||||
}
|
||||
|
||||
std::string Algorithm::name() const
|
||||
String Algorithm::name() const
|
||||
{
|
||||
return info()->name();
|
||||
}
|
||||
|
||||
void Algorithm::set(const std::string& parameter, int value)
|
||||
void Algorithm::set(const 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 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 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 String& parameter, const String& value)
|
||||
{
|
||||
info()->set(this, parameter.c_str(), ParamType<std::string>::type, &value);
|
||||
info()->set(this, parameter.c_str(), ParamType<String>::type, &value);
|
||||
}
|
||||
|
||||
void Algorithm::set(const std::string& parameter, const Mat& value)
|
||||
void Algorithm::set(const 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 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 String& parameter, const Ptr<Algorithm>& value)
|
||||
{
|
||||
info()->set(this, parameter.c_str(), ParamType<Algorithm>::type, &value);
|
||||
}
|
||||
@@ -229,9 +229,9 @@ void Algorithm::set(const char* parameter, bool 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 String& value)
|
||||
{
|
||||
info()->set(this, parameter, ParamType<std::string>::type, &value);
|
||||
info()->set(this, parameter, ParamType<String>::type, &value);
|
||||
}
|
||||
|
||||
void Algorithm::set(const char* parameter, const Mat& value)
|
||||
@@ -250,37 +250,37 @@ void Algorithm::set(const char* parameter, const Ptr<Algorithm>& value)
|
||||
}
|
||||
|
||||
|
||||
void Algorithm::setInt(const std::string& parameter, int value)
|
||||
void Algorithm::setInt(const 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 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 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 String& parameter, const String& value)
|
||||
{
|
||||
info()->set(this, parameter.c_str(), ParamType<std::string>::type, &value);
|
||||
info()->set(this, parameter.c_str(), ParamType<String>::type, &value);
|
||||
}
|
||||
|
||||
void Algorithm::setMat(const std::string& parameter, const Mat& value)
|
||||
void Algorithm::setMat(const 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 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 String& parameter, const Ptr<Algorithm>& value)
|
||||
{
|
||||
info()->set(this, parameter.c_str(), ParamType<Algorithm>::type, &value);
|
||||
}
|
||||
@@ -300,9 +300,9 @@ void Algorithm::setBool(const char* parameter, bool 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 String& value)
|
||||
{
|
||||
info()->set(this, parameter, ParamType<std::string>::type, &value);
|
||||
info()->set(this, parameter, ParamType<String>::type, &value);
|
||||
}
|
||||
|
||||
void Algorithm::setMat(const char* parameter, const Mat& value)
|
||||
@@ -322,47 +322,47 @@ void Algorithm::setAlgorithm(const char* parameter, const Ptr<Algorithm>& value)
|
||||
|
||||
|
||||
|
||||
int Algorithm::getInt(const std::string& parameter) const
|
||||
int Algorithm::getInt(const String& parameter) const
|
||||
{
|
||||
return get<int>(parameter);
|
||||
}
|
||||
|
||||
double Algorithm::getDouble(const std::string& parameter) const
|
||||
double Algorithm::getDouble(const String& parameter) const
|
||||
{
|
||||
return get<double>(parameter);
|
||||
}
|
||||
|
||||
bool Algorithm::getBool(const std::string& parameter) const
|
||||
bool Algorithm::getBool(const String& parameter) const
|
||||
{
|
||||
return get<bool>(parameter);
|
||||
}
|
||||
|
||||
std::string Algorithm::getString(const std::string& parameter) const
|
||||
String Algorithm::getString(const String& parameter) const
|
||||
{
|
||||
return get<std::string>(parameter);
|
||||
return get<String>(parameter);
|
||||
}
|
||||
|
||||
Mat Algorithm::getMat(const std::string& parameter) const
|
||||
Mat Algorithm::getMat(const String& parameter) const
|
||||
{
|
||||
return get<Mat>(parameter);
|
||||
}
|
||||
|
||||
std::vector<Mat> Algorithm::getMatVector(const std::string& parameter) const
|
||||
std::vector<Mat> Algorithm::getMatVector(const String& parameter) const
|
||||
{
|
||||
return get<std::vector<Mat> >(parameter);
|
||||
}
|
||||
|
||||
Ptr<Algorithm> Algorithm::getAlgorithm(const std::string& parameter) const
|
||||
Ptr<Algorithm> Algorithm::getAlgorithm(const String& parameter) const
|
||||
{
|
||||
return get<Algorithm>(parameter);
|
||||
}
|
||||
|
||||
std::string Algorithm::paramHelp(const std::string& parameter) const
|
||||
String Algorithm::paramHelp(const String& parameter) const
|
||||
{
|
||||
return info()->paramHelp(parameter.c_str());
|
||||
}
|
||||
|
||||
int Algorithm::paramType(const std::string& parameter) const
|
||||
int Algorithm::paramType(const String& parameter) const
|
||||
{
|
||||
return info()->paramType(parameter.c_str());
|
||||
}
|
||||
@@ -372,7 +372,7 @@ int Algorithm::paramType(const char* parameter) const
|
||||
return info()->paramType(parameter);
|
||||
}
|
||||
|
||||
void Algorithm::getParams(std::vector<std::string>& names) const
|
||||
void Algorithm::getParams(std::vector<String>& names) const
|
||||
{
|
||||
info()->getParams(names);
|
||||
}
|
||||
@@ -388,7 +388,7 @@ void Algorithm::read(const FileNode& fn)
|
||||
}
|
||||
|
||||
|
||||
AlgorithmInfo::AlgorithmInfo(const std::string& _name, Algorithm::Constructor create)
|
||||
AlgorithmInfo::AlgorithmInfo(const String& _name, Algorithm::Constructor create)
|
||||
{
|
||||
data = new AlgorithmInfoData;
|
||||
data->_name = _name;
|
||||
@@ -408,7 +408,7 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const
|
||||
for( i = 0; i < nparams; i++ )
|
||||
{
|
||||
const Param& p = data->params.vec[i].second;
|
||||
const std::string& pname = data->params.vec[i].first;
|
||||
const 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 )
|
||||
@@ -416,7 +416,7 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const
|
||||
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<String>(pname));
|
||||
else if( p.type == Param::MAT )
|
||||
cv::write(fs, pname, algo->get<Mat>(pname));
|
||||
else if( p.type == Param::MAT_VECTOR )
|
||||
@@ -437,7 +437,7 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const
|
||||
cv::write(fs, pname, algo->getInt(pname));
|
||||
else
|
||||
{
|
||||
std::string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
|
||||
String msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
|
||||
CV_Error( CV_StsUnsupportedFormat, msg.c_str());
|
||||
}
|
||||
}
|
||||
@@ -451,7 +451,7 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const
|
||||
for( i = 0; i < nparams; i++ )
|
||||
{
|
||||
const Param& p = data->params.vec[i].second;
|
||||
const std::string& pname = data->params.vec[i].first;
|
||||
const String& pname = data->params.vec[i].first;
|
||||
const FileNode n = fn[pname];
|
||||
if( n.empty() )
|
||||
continue;
|
||||
@@ -472,7 +472,7 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const
|
||||
}
|
||||
else if( p.type == Param::STRING )
|
||||
{
|
||||
std::string val = (std::string)n;
|
||||
String val = (String)n;
|
||||
info->set(algo, pname.c_str(), p.type, &val, true);
|
||||
}
|
||||
else if( p.type == Param::MAT )
|
||||
@@ -489,7 +489,7 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const
|
||||
}
|
||||
else if( p.type == Param::ALGORITHM )
|
||||
{
|
||||
Ptr<Algorithm> nestedAlgo = Algorithm::_create((std::string)n["name"]);
|
||||
Ptr<Algorithm> nestedAlgo = Algorithm::_create((String)n["name"]);
|
||||
CV_Assert( !nestedAlgo.empty() );
|
||||
nestedAlgo->read(n);
|
||||
info->set(algo, pname.c_str(), p.type, &nestedAlgo, true);
|
||||
@@ -516,13 +516,13 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
|
||||
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
|
||||
String AlgorithmInfo::name() const
|
||||
{
|
||||
return data->_name;
|
||||
}
|
||||
@@ -532,7 +532,7 @@ union GetSetParam
|
||||
int (Algorithm::*get_int)() const;
|
||||
bool (Algorithm::*get_bool)() const;
|
||||
double (Algorithm::*get_double)() const;
|
||||
std::string (Algorithm::*get_string)() const;
|
||||
String (Algorithm::*get_string)() const;
|
||||
Mat (Algorithm::*get_mat)() const;
|
||||
std::vector<Mat> (Algorithm::*get_mat_vector)() const;
|
||||
Ptr<Algorithm> (Algorithm::*get_algo)() const;
|
||||
@@ -544,7 +544,7 @@ union GetSetParam
|
||||
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 String&);
|
||||
void (Algorithm::*set_mat)(const Mat&);
|
||||
void (Algorithm::*set_mat_vector)(const std::vector<Mat>&);
|
||||
void (Algorithm::*set_algo)(const Ptr<Algorithm>&);
|
||||
@@ -554,9 +554,9 @@ union GetSetParam
|
||||
void (Algorithm::*set_uchar)(uchar);
|
||||
};
|
||||
|
||||
static std::string getNameOfType(int argType);
|
||||
static String getNameOfType(int argType);
|
||||
|
||||
static std::string getNameOfType(int argType)
|
||||
static String getNameOfType(int argType)
|
||||
{
|
||||
switch(argType)
|
||||
{
|
||||
@@ -576,37 +576,37 @@ static std::string getNameOfType(int argType)
|
||||
return "";
|
||||
}
|
||||
|
||||
static std::string getErrorMessageForWrongArgumentInSetter(std::string algoName, std::string paramName, int paramType, int argType)
|
||||
static String getErrorMessageForWrongArgumentInSetter(String algoName, String paramName, int paramType, int argType)
|
||||
{
|
||||
std::string message = std::string("Argument error: the setter")
|
||||
String message = 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 String getErrorMessageForWrongArgumentInGetter(String algoName, String paramName, int paramType, int argType)
|
||||
{
|
||||
std::string message = std::string("Argument error: the getter")
|
||||
String message = 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;
|
||||
}
|
||||
@@ -630,7 +630,7 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
||||
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);
|
||||
String message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
|
||||
@@ -790,21 +790,21 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
||||
{
|
||||
if( p->type != Param::STRING )
|
||||
{
|
||||
std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||
String message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
|
||||
const std::string& val = *(const std::string*)value;
|
||||
const String& val = *(const String*)value;
|
||||
if( p->setter )
|
||||
(algo->*f.set_string)(val);
|
||||
else
|
||||
*(std::string*)((uchar*)algo + p->offset) = val;
|
||||
*(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);
|
||||
String message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
|
||||
@@ -818,7 +818,7 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
||||
{
|
||||
if( p->type != Param::MAT_VECTOR )
|
||||
{
|
||||
std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||
String message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
|
||||
@@ -832,7 +832,7 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
||||
{
|
||||
if( p->type != Param::ALGORITHM )
|
||||
{
|
||||
std::string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||
String message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
|
||||
@@ -862,7 +862,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
{
|
||||
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);
|
||||
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);
|
||||
@@ -887,7 +887,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
{
|
||||
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);
|
||||
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);
|
||||
@@ -913,7 +913,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
{
|
||||
if(!( argType == Param::REAL || argType == Param::FLOAT))
|
||||
{
|
||||
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
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);
|
||||
@@ -929,7 +929,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
{
|
||||
if(!( argType == Param::REAL || argType == Param::FLOAT))
|
||||
{
|
||||
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
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);
|
||||
@@ -945,7 +945,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
{
|
||||
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);
|
||||
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);
|
||||
@@ -969,7 +969,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
{
|
||||
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);
|
||||
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);
|
||||
@@ -993,7 +993,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
{
|
||||
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);
|
||||
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);
|
||||
@@ -1021,18 +1021,18 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
{
|
||||
if( p->type != Param::STRING )
|
||||
{
|
||||
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
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);
|
||||
*(String*)value = p->getter ? (algo->*f.get_string)() :
|
||||
*(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);
|
||||
String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
|
||||
@@ -1043,7 +1043,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
{
|
||||
if( p->type != Param::MAT_VECTOR )
|
||||
{
|
||||
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
|
||||
@@ -1054,7 +1054,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
{
|
||||
if( p->type != Param::ALGORITHM )
|
||||
{
|
||||
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
|
||||
@@ -1063,7 +1063,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
String message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
}
|
||||
@@ -1078,7 +1078,7 @@ int AlgorithmInfo::paramType(const char* parameter) const
|
||||
}
|
||||
|
||||
|
||||
std::string AlgorithmInfo::paramHelp(const char* parameter) const
|
||||
String AlgorithmInfo::paramHelp(const char* parameter) const
|
||||
{
|
||||
const Param* p = findstr(data->params, parameter);
|
||||
if( !p )
|
||||
@@ -1087,7 +1087,7 @@ std::string AlgorithmInfo::paramHelp(const char* parameter) const
|
||||
}
|
||||
|
||||
|
||||
void AlgorithmInfo::getParams(std::vector<std::string>& names) const
|
||||
void AlgorithmInfo::getParams(std::vector<String>& names) const
|
||||
{
|
||||
data->params.get_keys(names);
|
||||
}
|
||||
@@ -1096,7 +1096,7 @@ void AlgorithmInfo::getParams(std::vector<std::string>& names) const
|
||||
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 String& help)
|
||||
{
|
||||
CV_Assert( argType == Param::INT || argType == Param::BOOLEAN ||
|
||||
argType == Param::REAL || argType == Param::STRING ||
|
||||
@@ -1104,7 +1104,7 @@ void AlgorithmInfo::addParam_(Algorithm& algo, const char* parameter, int argTyp
|
||||
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(String(parameter), Param(argType, readOnly,
|
||||
(int)((size_t)value - (size_t)(void*)&algo),
|
||||
getter, setter, help));
|
||||
}
|
||||
@@ -1114,7 +1114,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
int& value, bool readOnly,
|
||||
int (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(int),
|
||||
const std::string& help)
|
||||
const String& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<int>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
@@ -1124,7 +1124,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
bool& value, bool readOnly,
|
||||
int (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(int),
|
||||
const std::string& help)
|
||||
const String& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<bool>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
@@ -1134,19 +1134,19 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
double& value, bool readOnly,
|
||||
double (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(double),
|
||||
const std::string& help)
|
||||
const 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)
|
||||
String& value, bool readOnly,
|
||||
String (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(const String&),
|
||||
const String& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<std::string>::type, &value, readOnly,
|
||||
addParam_(algo, parameter, ParamType<String>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
}
|
||||
|
||||
@@ -1154,7 +1154,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
Mat& value, bool readOnly,
|
||||
Mat (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(const Mat&),
|
||||
const std::string& help)
|
||||
const String& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<Mat>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
@@ -1164,7 +1164,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
std::vector<Mat>& value, bool readOnly,
|
||||
std::vector<Mat> (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(const std::vector<Mat>&),
|
||||
const std::string& help)
|
||||
const String& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<std::vector<Mat> >::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
@@ -1174,7 +1174,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
Ptr<Algorithm>& value, bool readOnly,
|
||||
Ptr<Algorithm> (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(const Ptr<Algorithm>&),
|
||||
const std::string& help)
|
||||
const String& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<Algorithm>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
@@ -1184,7 +1184,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
float& value, bool readOnly,
|
||||
float (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(float),
|
||||
const std::string& help)
|
||||
const String& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<float>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
@@ -1194,7 +1194,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
unsigned int& value, bool readOnly,
|
||||
unsigned int (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(unsigned int),
|
||||
const std::string& help)
|
||||
const String& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<unsigned int>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
@@ -1204,7 +1204,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
uint64& value, bool readOnly,
|
||||
uint64 (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(uint64),
|
||||
const std::string& help)
|
||||
const String& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<uint64>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
@@ -1214,7 +1214,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
uchar& value, bool readOnly,
|
||||
uchar (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(uchar),
|
||||
const std::string& help)
|
||||
const String& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<uchar>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
|
@@ -1,17 +1,14 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
struct CommandLineParserParams
|
||||
{
|
||||
public:
|
||||
std::string help_message;
|
||||
std::string def_value;
|
||||
std::vector<std::string> keys;
|
||||
String help_message;
|
||||
String def_value;
|
||||
std::vector<String> keys;
|
||||
int number;
|
||||
};
|
||||
|
||||
@@ -19,27 +16,27 @@ public:
|
||||
struct CommandLineParser::Impl
|
||||
{
|
||||
bool error;
|
||||
std::string error_message;
|
||||
std::string about_message;
|
||||
String error_message;
|
||||
String about_message;
|
||||
|
||||
std::string path_to_app;
|
||||
std::string app_name;
|
||||
String path_to_app;
|
||||
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<String> split_range_string(const String& str, char fs, char ss) const;
|
||||
std::vector<String> split_string(const String& str, char symbol = ' ', bool create_empty_item = false) const;
|
||||
String cat_string(const 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 String& key, const String& value);
|
||||
void apply_params(int i, String value);
|
||||
|
||||
void sort_params();
|
||||
int refcount;
|
||||
};
|
||||
|
||||
|
||||
static std::string get_type_name(int type)
|
||||
static String get_type_name(int type)
|
||||
{
|
||||
if( type == Param::INT )
|
||||
return "int";
|
||||
@@ -56,9 +53,9 @@ static std::string get_type_name(int type)
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static void from_str(const std::string& str, int type, void* dst)
|
||||
static void from_str(const 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 )
|
||||
@@ -70,20 +67,20 @@ static void from_str(const std::string& str, int type, void* dst)
|
||||
else if( type == Param::REAL )
|
||||
ss >> *(double*)dst;
|
||||
else if( type == Param::STRING )
|
||||
*(std::string*)dst = str;
|
||||
*(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 +
|
||||
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 String& name, bool space_delete, int type, void* dst) const
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -93,7 +90,7 @@ void CommandLineParser::getByName(const std::string& name, bool space_delete, in
|
||||
{
|
||||
if (name.compare(impl->data[i].keys[j]) == 0)
|
||||
{
|
||||
std::string v = impl->data[i].def_value;
|
||||
String v = impl->data[i].def_value;
|
||||
if (space_delete)
|
||||
v = impl->cat_string(v);
|
||||
from_str(v, type, dst);
|
||||
@@ -102,12 +99,12 @@ void CommandLineParser::getByName(const std::string& name, bool space_delete, in
|
||||
}
|
||||
}
|
||||
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: " + String(e.what()) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,19 +117,19 @@ void CommandLineParser::getByIndex(int index, bool space_delete, int type, void*
|
||||
{
|
||||
if (impl->data[i].number == index)
|
||||
{
|
||||
std::string v = impl->data[i].def_value;
|
||||
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: " + String(e.what()) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,34 +149,34 @@ static bool cmp_params(const CommandLineParserParams & p1, const CommandLinePars
|
||||
return true;
|
||||
}
|
||||
|
||||
CommandLineParser::CommandLineParser(int argc, const char* const argv[], const std::string& keys)
|
||||
CommandLineParser::CommandLineParser(int argc, const char* const argv[], const 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 = String(argv[0]).find_last_of("/\\");
|
||||
if (pos_s == String::npos)
|
||||
{
|
||||
impl->path_to_app = "";
|
||||
impl->app_name = std::string(argv[0]);
|
||||
impl->app_name = 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 = String(argv[0]).substr(0, pos_s);
|
||||
impl->app_name = String(argv[0]).substr(pos_s + 1, 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<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<String> l = impl->split_string(k[i], '|', true);
|
||||
CommandLineParserParams p;
|
||||
p.keys = impl->split_string(l[0]);
|
||||
p.def_value = l[1];
|
||||
@@ -206,11 +203,11 @@ CommandLineParser::CommandLineParser(int argc, const char* const argv[], const s
|
||||
jj = 0;
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
std::string s = std::string(argv[i]);
|
||||
String s = String(argv[i]);
|
||||
|
||||
if (s.find('=') != std::string::npos && s.find('=') < s.length())
|
||||
if (s.find('=') != String::npos && s.find('=') < s.length())
|
||||
{
|
||||
std::vector<std::string> k_v = impl->split_string(s, '=', true);
|
||||
std::vector<String> k_v = impl->split_string(s, '=', true);
|
||||
for (int h = 0; h < 2; h++)
|
||||
{
|
||||
if (k_v[0][0] == '-')
|
||||
@@ -256,12 +253,12 @@ CommandLineParser& CommandLineParser::operator = (const CommandLineParser& parse
|
||||
return *this;
|
||||
}
|
||||
|
||||
void CommandLineParser::about(const std::string& message)
|
||||
void CommandLineParser::about(const 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 String& key, const String& value)
|
||||
{
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
@@ -276,7 +273,7 @@ void CommandLineParser::Impl::apply_params(const std::string& key, const std::st
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineParser::Impl::apply_params(int i, std::string value)
|
||||
void CommandLineParser::Impl::apply_params(int i, String value)
|
||||
{
|
||||
for (size_t j = 0; j < data.size(); j++)
|
||||
{
|
||||
@@ -292,34 +289,34 @@ void CommandLineParser::Impl::sort_params()
|
||||
{
|
||||
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
|
||||
String CommandLineParser::Impl::cat_string(const 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 ? String("") : str.substr(left, right-left);
|
||||
}
|
||||
|
||||
std::string CommandLineParser::getPathToApplication() const
|
||||
String CommandLineParser::getPathToApplication() const
|
||||
{
|
||||
return impl->path_to_app;
|
||||
}
|
||||
|
||||
bool CommandLineParser::has(const std::string& name) const
|
||||
bool CommandLineParser::has(const 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 && String("true").compare(impl->data[i].def_value) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -337,86 +334,87 @@ void CommandLineParser::printErrors() const
|
||||
{
|
||||
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 << " ";
|
||||
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];
|
||||
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);
|
||||
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");
|
||||
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);
|
||||
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<String> CommandLineParser::Impl::split_range_string(const String& _str, char fs, char ss) const
|
||||
{
|
||||
std::string str = _str;
|
||||
std::vector<std::string> vec;
|
||||
std::string word = "";
|
||||
String str = _str;
|
||||
std::vector<String> vec;
|
||||
String word = "";
|
||||
bool begin = false;
|
||||
|
||||
while (!str.empty())
|
||||
@@ -426,13 +424,13 @@ std::vector<std::string> CommandLineParser::Impl::split_range_string(const std::
|
||||
if (begin == true)
|
||||
{
|
||||
throw cv::Exception(CV_StsParseError,
|
||||
std::string("error in split_range_string(")
|
||||
String("error in split_range_string(")
|
||||
+ str
|
||||
+ std::string(", ")
|
||||
+ std::string(1, fs)
|
||||
+ std::string(", ")
|
||||
+ std::string(1, ss)
|
||||
+ std::string(")"),
|
||||
+ String(", ")
|
||||
+ String(1, fs)
|
||||
+ String(", ")
|
||||
+ String(1, ss)
|
||||
+ String(")"),
|
||||
"", __FILE__, __LINE__
|
||||
);
|
||||
}
|
||||
@@ -446,13 +444,13 @@ std::vector<std::string> CommandLineParser::Impl::split_range_string(const std::
|
||||
if (begin == false)
|
||||
{
|
||||
throw cv::Exception(CV_StsParseError,
|
||||
std::string("error in split_range_string(")
|
||||
String("error in split_range_string(")
|
||||
+ str
|
||||
+ std::string(", ")
|
||||
+ std::string(1, fs)
|
||||
+ std::string(", ")
|
||||
+ std::string(1, ss)
|
||||
+ std::string(")"),
|
||||
+ String(", ")
|
||||
+ String(1, fs)
|
||||
+ String(", ")
|
||||
+ String(1, ss)
|
||||
+ String(")"),
|
||||
"", __FILE__, __LINE__
|
||||
);
|
||||
}
|
||||
@@ -462,7 +460,7 @@ std::vector<std::string> CommandLineParser::Impl::split_range_string(const std::
|
||||
|
||||
if (begin == true)
|
||||
{
|
||||
word += str[0];
|
||||
word = word + str[0];
|
||||
}
|
||||
str = str.substr(1, str.length() - 1);
|
||||
}
|
||||
@@ -470,13 +468,13 @@ std::vector<std::string> CommandLineParser::Impl::split_range_string(const std::
|
||||
if (begin == true)
|
||||
{
|
||||
throw cv::Exception(CV_StsParseError,
|
||||
std::string("error in split_range_string(")
|
||||
String("error in split_range_string(")
|
||||
+ str
|
||||
+ std::string(", ")
|
||||
+ std::string(1, fs)
|
||||
+ std::string(", ")
|
||||
+ std::string(1, ss)
|
||||
+ std::string(")"),
|
||||
+ String(", ")
|
||||
+ String(1, fs)
|
||||
+ String(", ")
|
||||
+ String(1, ss)
|
||||
+ String(")"),
|
||||
"", __FILE__, __LINE__
|
||||
);
|
||||
}
|
||||
@@ -484,11 +482,11 @@ std::vector<std::string> CommandLineParser::Impl::split_range_string(const std::
|
||||
return vec;
|
||||
}
|
||||
|
||||
std::vector<std::string> CommandLineParser::Impl::split_string(const std::string& _str, char symbol, bool create_empty_item) const
|
||||
std::vector<String> CommandLineParser::Impl::split_string(const String& _str, char symbol, bool create_empty_item) const
|
||||
{
|
||||
std::string str = _str;
|
||||
std::vector<std::string> vec;
|
||||
std::string word = "";
|
||||
String str = _str;
|
||||
std::vector<String> vec;
|
||||
String word = "";
|
||||
|
||||
while (!str.empty())
|
||||
{
|
||||
@@ -502,7 +500,7 @@ std::vector<std::string> CommandLineParser::Impl::split_string(const std::string
|
||||
}
|
||||
else
|
||||
{
|
||||
word += str[0];
|
||||
word = word + str[0];
|
||||
}
|
||||
str = str.substr(1, str.length() - 1);
|
||||
}
|
||||
|
@@ -1916,7 +1916,7 @@ static const int* getFontData(int fontFace)
|
||||
}
|
||||
|
||||
|
||||
void putText( Mat& img, const std::string& text, Point org,
|
||||
void putText( Mat& img, const String& text, Point org,
|
||||
int fontFace, double fontScale, Scalar color,
|
||||
int thickness, int line_type, bool bottomLeftOrigin )
|
||||
|
||||
@@ -1978,7 +1978,7 @@ void putText( Mat& img, const std::string& text, Point org,
|
||||
}
|
||||
}
|
||||
|
||||
Size getTextSize( const std::string& text, int fontFace, double fontScale, int thickness, int* _base_line)
|
||||
Size getTextSize( const String& text, int fontFace, double fontScale, int thickness, int* _base_line)
|
||||
{
|
||||
Size size;
|
||||
double view_x = 0;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "cvconfig.h"
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
#include "gl_core_3_1.hpp"
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
@@ -15,8 +15,8 @@
|
||||
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);
|
||||
String symbolName = "_";
|
||||
symbolName += String(name);
|
||||
|
||||
NSSymbol symbol = image ? NSLookupSymbolInImage(image, &symbolName[0], NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : 0;
|
||||
|
||||
@@ -94,9 +94,7 @@
|
||||
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;
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ namespace
|
||||
{
|
||||
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*/
|
||||
@@ -100,7 +100,7 @@ const char dir_separators[] = "/";
|
||||
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;
|
||||
@@ -168,10 +168,11 @@ static bool wildcmp(const char *string, const char *wild)
|
||||
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 */
|
||||
@@ -183,7 +184,7 @@ static void glob_rec(const std::string& directory, const std::string& wildchart,
|
||||
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))
|
||||
{
|
||||
@@ -207,14 +208,13 @@ static void glob_rec(const std::string& directory, const std::string& wildchart,
|
||||
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(String pattern, std::vector<String>& result, bool recursive)
|
||||
{
|
||||
result.clear();
|
||||
std::string path, wildchart;
|
||||
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);
|
||||
@@ -227,7 +227,7 @@ void cv::glob(std::string pattern, std::vector<std::string>& result, bool recurs
|
||||
else
|
||||
{
|
||||
size_t pos = pattern.find_last_of(dir_separators);
|
||||
if (pos == std::string::npos)
|
||||
if (pos == String::npos)
|
||||
{
|
||||
wildchart = pattern;
|
||||
path = ".";
|
||||
|
@@ -172,7 +172,7 @@ namespace
|
||||
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 String& set_as_str, std::vector<int>& arr);
|
||||
|
||||
std::vector<int> bin;
|
||||
std::vector<int> ptx;
|
||||
@@ -218,9 +218,9 @@ namespace
|
||||
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 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(" ") == String::npos)
|
||||
return;
|
||||
|
||||
std::istringstream stream(set_as_str);
|
||||
|
@@ -116,7 +116,7 @@ static char* icv_itoa( int _val, char* buffer, int /*radix*/ )
|
||||
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();
|
||||
@@ -152,7 +152,7 @@ std::string cv::FileStorage::getDefaultObjectName(const std::string& _filename)
|
||||
name = name_buf;
|
||||
if( strcmp( name, "_" ) == 0 )
|
||||
strcpy( name, stubname );
|
||||
return std::string(name);
|
||||
return String(name);
|
||||
}
|
||||
|
||||
typedef struct CvGenericHash
|
||||
@@ -516,7 +516,7 @@ icvFSFlush( CvFileStorage* fs )
|
||||
|
||||
|
||||
static void
|
||||
icvClose( CvFileStorage* fs, std::string* out )
|
||||
icvClose( CvFileStorage* fs, cv::String* out )
|
||||
{
|
||||
if( out )
|
||||
out->clear();
|
||||
@@ -543,8 +543,7 @@ icvClose( CvFileStorage* fs, std::string* out )
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5011,7 +5010,7 @@ cvSave( const char* filename, const void* struct_ptr,
|
||||
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 );
|
||||
@@ -5105,7 +5104,7 @@ stop_search:
|
||||
namespace cv
|
||||
{
|
||||
|
||||
static void getElemSize( const std::string& fmt, size_t& elemSize, size_t& cn )
|
||||
static void getElemSize( const String& fmt, size_t& elemSize, size_t& cn )
|
||||
{
|
||||
const char* dt = fmt.c_str();
|
||||
cn = 1;
|
||||
@@ -5125,7 +5124,7 @@ FileStorage::FileStorage()
|
||||
state = UNDEFINED;
|
||||
}
|
||||
|
||||
FileStorage::FileStorage(const std::string& filename, int flags, const std::string& encoding)
|
||||
FileStorage::FileStorage(const String& filename, int flags, const String& encoding)
|
||||
{
|
||||
state = UNDEFINED;
|
||||
open( filename, flags, encoding );
|
||||
@@ -5146,7 +5145,7 @@ FileStorage::~FileStorage()
|
||||
}
|
||||
}
|
||||
|
||||
bool FileStorage::open(const std::string& filename, int flags, const std::string& encoding)
|
||||
bool FileStorage::open(const String& filename, int flags, const String& encoding)
|
||||
{
|
||||
release();
|
||||
fs = Ptr<CvFileStorage>(cvOpenFileStorage( filename.c_str(), 0, flags,
|
||||
@@ -5168,10 +5167,9 @@ void FileStorage::release()
|
||||
state = UNDEFINED;
|
||||
}
|
||||
|
||||
std::string FileStorage::releaseAndGetString()
|
||||
String FileStorage::releaseAndGetString()
|
||||
{
|
||||
std::string buf;
|
||||
buf.reserve(16); // HACK: Work around for compiler bug
|
||||
String buf;
|
||||
if( fs.obj && fs.obj->outbuf )
|
||||
icvClose(fs.obj, &buf);
|
||||
|
||||
@@ -5184,7 +5182,7 @@ FileNode FileStorage::root(int streamidx) const
|
||||
return isOpened() ? FileNode(fs, cvGetRootFileNode(fs, streamidx)) : FileNode();
|
||||
}
|
||||
|
||||
FileStorage& operator << (FileStorage& fs, const std::string& str)
|
||||
FileStorage& operator << (FileStorage& fs, const String& str)
|
||||
{
|
||||
enum { NAME_EXPECTED = FileStorage::NAME_EXPECTED,
|
||||
VALUE_EXPECTED = FileStorage::VALUE_EXPECTED,
|
||||
@@ -5203,7 +5201,7 @@ FileStorage& operator << (FileStorage& fs, const std::string& str)
|
||||
fs.state = fs.structs.empty() || fs.structs.back() == '{' ?
|
||||
INSIDE_MAP + NAME_EXPECTED : VALUE_EXPECTED;
|
||||
cvEndWriteStruct( *fs );
|
||||
fs.elname = std::string();
|
||||
fs.elname = String();
|
||||
}
|
||||
else if( fs.state == NAME_EXPECTED + INSIDE_MAP )
|
||||
{
|
||||
@@ -5227,12 +5225,12 @@ FileStorage& operator << (FileStorage& fs, const std::string& str)
|
||||
}
|
||||
cvStartWriteStruct( *fs, fs.elname.size() > 0 ? fs.elname.c_str() : 0,
|
||||
flags, *_str ? _str : 0 );
|
||||
fs.elname = std::string();
|
||||
fs.elname = 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] == ']')) ? String(_str+1) : str );
|
||||
if( fs.state == INSIDE_MAP + VALUE_EXPECTED )
|
||||
fs.state = INSIDE_MAP + NAME_EXPECTED;
|
||||
}
|
||||
@@ -5243,7 +5241,7 @@ FileStorage& operator << (FileStorage& fs, const std::string& str)
|
||||
}
|
||||
|
||||
|
||||
void FileStorage::writeRaw( const std::string& fmt, const uchar* vec, size_t len )
|
||||
void FileStorage::writeRaw( const String& fmt, const uchar* vec, size_t len )
|
||||
{
|
||||
if( !isOpened() )
|
||||
return;
|
||||
@@ -5254,7 +5252,7 @@ void FileStorage::writeRaw( const std::string& fmt, const uchar* vec, size_t len
|
||||
}
|
||||
|
||||
|
||||
void FileStorage::writeObj( const std::string& name, const void* obj )
|
||||
void FileStorage::writeObj( const String& name, const void* obj )
|
||||
{
|
||||
if( !isOpened() )
|
||||
return;
|
||||
@@ -5262,7 +5260,7 @@ void FileStorage::writeObj( const std::string& name, const void* obj )
|
||||
}
|
||||
|
||||
|
||||
FileNode FileStorage::operator[](const std::string& nodename) const
|
||||
FileNode FileStorage::operator[](const String& nodename) const
|
||||
{
|
||||
return FileNode(fs, cvGetFileNodeByName(fs, 0, nodename.c_str()));
|
||||
}
|
||||
@@ -5272,7 +5270,7 @@ FileNode FileStorage::operator[](const char* nodename) const
|
||||
return FileNode(fs, cvGetFileNodeByName(fs, 0, nodename));
|
||||
}
|
||||
|
||||
FileNode FileNode::operator[](const std::string& nodename) const
|
||||
FileNode FileNode::operator[](const String& nodename) const
|
||||
{
|
||||
return FileNode(fs, cvGetFileNodeByName(fs, node, nodename.c_str()));
|
||||
}
|
||||
@@ -5288,10 +5286,10 @@ FileNode FileNode::operator[](int i) const
|
||||
i == 0 ? *this : FileNode();
|
||||
}
|
||||
|
||||
std::string FileNode::name() const
|
||||
String FileNode::name() const
|
||||
{
|
||||
const char* str;
|
||||
return !node || (str = cvGetFileNodeName(node)) == 0 ? std::string() : std::string(str);
|
||||
return !node || (str = cvGetFileNodeName(node)) == 0 ? String() : String(str);
|
||||
}
|
||||
|
||||
void* FileNode::readObj() const
|
||||
@@ -5406,7 +5404,7 @@ FileNodeIterator& FileNodeIterator::operator -= (int ofs)
|
||||
}
|
||||
|
||||
|
||||
FileNodeIterator& FileNodeIterator::readRaw( const std::string& fmt, uchar* vec, size_t maxCount )
|
||||
FileNodeIterator& FileNodeIterator::readRaw( const String& fmt, uchar* vec, size_t maxCount )
|
||||
{
|
||||
if( fs && container && remaining > 0 )
|
||||
{
|
||||
@@ -5430,16 +5428,16 @@ FileNodeIterator& FileNodeIterator::readRaw( const std::string& fmt, uchar* vec,
|
||||
}
|
||||
|
||||
|
||||
void write( FileStorage& fs, const std::string& name, int value )
|
||||
void write( FileStorage& fs, const 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 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 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 String& name, const String& value )
|
||||
{ cvWriteString( *fs, name.size() ? name.c_str() : 0, value.c_str() ); }
|
||||
|
||||
void writeScalar(FileStorage& fs, int value )
|
||||
@@ -5451,11 +5449,11 @@ void writeScalar(FileStorage& fs, float value )
|
||||
void writeScalar(FileStorage& fs, double value )
|
||||
{ cvWriteReal( *fs, 0, value ); }
|
||||
|
||||
void writeScalar(FileStorage& fs, const std::string& value )
|
||||
void writeScalar(FileStorage& fs, const String& value )
|
||||
{ cvWriteString( *fs, 0, value.c_str() ); }
|
||||
|
||||
|
||||
void write( FileStorage& fs, const std::string& name, const Mat& value )
|
||||
void write( FileStorage& fs, const String& name, const Mat& value )
|
||||
{
|
||||
if( value.dims <= 2 )
|
||||
{
|
||||
@@ -5470,15 +5468,15 @@ void write( FileStorage& fs, const std::string& name, const Mat& value )
|
||||
}
|
||||
|
||||
// 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 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 String& name,
|
||||
int flags, const String& typeName) : fs(&_fs)
|
||||
{
|
||||
cvStartWriteStruct(**fs, !name.empty() ? name.c_str() : 0, flags,
|
||||
!typeName.empty() ? typeName.c_str() : 0);
|
||||
|
69
modules/core/src/stl.cpp
Normal file
69
modules/core/src/stl.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
char* cv::String::allocate(size_t len)
|
||||
{
|
||||
size_t totalsize = alignSize(len + 1, (int)sizeof(int));
|
||||
int* data = (int*)cv::fastMalloc(totalsize + sizeof(int));
|
||||
data[0] = 1;
|
||||
cstr_ = (char*)(data + 1);
|
||||
len_ = len;
|
||||
cstr_[len] = 0;
|
||||
return cstr_;
|
||||
}
|
||||
|
||||
|
||||
void cv::String::deallocate()
|
||||
{
|
||||
int* data = (int*)cstr_;
|
||||
len_ = 0;
|
||||
cstr_ = 0;
|
||||
|
||||
if(data && 1 == CV_XADD(data-1, -1))
|
||||
{
|
||||
cv::fastFree(data-1);
|
||||
}
|
||||
}
|
@@ -113,7 +113,7 @@ namespace cv
|
||||
|
||||
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 String& _err, const String& _func, const String& _file, int _line)
|
||||
: code(_code), err(_err), func(_func), file(_file), line(_line)
|
||||
{
|
||||
formatMessage();
|
||||
@@ -340,27 +340,27 @@ int64 getCPUTickCount(void)
|
||||
|
||||
#endif
|
||||
|
||||
const std::string& getBuildInformation()
|
||||
const String& getBuildInformation()
|
||||
{
|
||||
static std::string build_info =
|
||||
static String build_info =
|
||||
#include "version_string.inc"
|
||||
;
|
||||
return build_info;
|
||||
}
|
||||
|
||||
std::string format( const char* fmt, ... )
|
||||
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 String(buf);
|
||||
}
|
||||
|
||||
std::string tempfile( const char* suffix )
|
||||
String tempfile( const char* suffix )
|
||||
{
|
||||
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
|
||||
std::string fname;
|
||||
String fname;
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
char temp_dir2[MAX_PATH + 1] = { 0 };
|
||||
@@ -372,7 +372,7 @@ std::string tempfile( const char* suffix )
|
||||
temp_dir = temp_dir2;
|
||||
}
|
||||
if(0 == ::GetTempFileNameA(temp_dir, "ocv", 0, temp_file))
|
||||
return std::string();
|
||||
return String();
|
||||
|
||||
DeleteFileA(temp_file);
|
||||
|
||||
@@ -392,12 +392,12 @@ std::string tempfile( const char* suffix )
|
||||
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 String();
|
||||
|
||||
close(fd);
|
||||
remove(fname.c_str());
|
||||
|
@@ -191,7 +191,7 @@ protected:
|
||||
|
||||
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) ||
|
||||
@@ -292,7 +292,7 @@ protected:
|
||||
(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 ||
|
||||
@@ -459,7 +459,7 @@ TEST(Core_globbing, accurasy)
|
||||
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<String> lenas, pngLenas;
|
||||
cv::glob(patternLena, lenas, true);
|
||||
cv::glob(patternLenaPng, pngLenas, true);
|
||||
|
||||
|
Reference in New Issue
Block a user