diff --git a/apps/sft/include/sft/common.hpp b/apps/sft/include/sft/common.hpp index 7e5c0ff26..4a0a03f36 100644 --- a/apps/sft/include/sft/common.hpp +++ b/apps/sft/include/sft/common.hpp @@ -54,7 +54,7 @@ namespace sft using cv::Mat; struct ICF; - typedef std::string string; + typedef cv::String string; typedef std::vector Icfvector; typedef std::vector svector; diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index 75f91a1a2..6edcba711 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -471,6 +471,9 @@ endmacro() # ocv_create_module(SKIP_LINK) macro(ocv_create_module) add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES}) + if(NOT the_module STREQUAL opencv_ts) + set_target_properties(${the_module} PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL) + endif() if(NOT "${ARGN}" STREQUAL "SKIP_LINK") target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN}) diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake index cfc4bfa72..9b3efd9d1 100644 --- a/cmake/OpenCVPCHSupport.cmake +++ b/cmake/OpenCVPCHSupport.cmake @@ -46,6 +46,13 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags) LIST(APPEND ${_out_compile_flags} "-fPIC") ENDIF() + GET_TARGET_PROPERTY(_target_definitions ${_PCH_current_target} COMPILE_DEFINITIONS) + if(_target_definitions) + foreach(_def ${_target_definitions}) + LIST(APPEND ${_out_compile_flags} "-D${_def}") + endforeach() + endif() + ELSE() ## TODO ... ? or does it work out of the box ENDIF() diff --git a/modules/androidcamera/src/camera_activity.cpp b/modules/androidcamera/src/camera_activity.cpp index 9ea54d78b..c65fd7d3b 100644 --- a/modules/androidcamera/src/camera_activity.cpp +++ b/modules/androidcamera/src/camera_activity.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -12,6 +11,8 @@ #include "camera_wrapper.h" #include "EngineCommon.h" +#include "opencv2/core.hpp" + #undef LOG_TAG #undef LOGE #undef LOGD @@ -37,17 +38,17 @@ public: static CameraActivity::ErrorCode getProperty(void* camera, int propIdx, double* value); static CameraActivity::ErrorCode applyProperties(void** ppcamera); - static void setPathLibFolder(const std::string& path); + static void setPathLibFolder(const cv::String& path); private: - static std::string pathLibFolder; + static cv::String pathLibFolder; static bool isConnectedToLib; - static std::string getPathLibFolder(); - static std::string getDefaultPathLibFolder(); + static cv::String getPathLibFolder(); + static cv::String getDefaultPathLibFolder(); static CameraActivity::ErrorCode connectToLib(); static CameraActivity::ErrorCode getSymbolFromLib(void * libHandle, const char* symbolName, void** ppSymbol); - static void fillListWrapperLibs(const std::string& folderPath, std::vector& listLibs); + static void fillListWrapperLibs(const cv::String& folderPath, std::vector& listLibs); static InitCameraConnectC pInitCameraC; static CloseCameraConnectC pCloseCameraC; @@ -58,7 +59,7 @@ private: friend bool nextFrame(void* buffer, size_t bufferSize, void* userData); }; -std::string CameraWrapperConnector::pathLibFolder; +cv::String CameraWrapperConnector::pathLibFolder; bool CameraWrapperConnector::isConnectedToLib = false; InitCameraConnectC CameraWrapperConnector::pInitCameraC = 0; @@ -165,7 +166,7 @@ CameraActivity::ErrorCode CameraWrapperConnector::connectToLib() } dlerror(); - std::string folderPath = getPathLibFolder(); + cv::String folderPath = getPathLibFolder(); if (folderPath.empty()) { LOGD("Trying to find native camera in default OpenCV packages"); @@ -174,12 +175,12 @@ CameraActivity::ErrorCode CameraWrapperConnector::connectToLib() LOGD("CameraWrapperConnector::connectToLib: folderPath=%s", folderPath.c_str()); - std::vector listLibs; + std::vector listLibs; fillListWrapperLibs(folderPath, listLibs); - std::sort(listLibs.begin(), listLibs.end(), std::greater()); + std::sort(listLibs.begin(), listLibs.end(), std::greater()); void * libHandle=0; - std::string cur_path; + cv::String cur_path; for(size_t i = 0; i < listLibs.size(); i++) { cur_path=folderPath + listLibs[i]; LOGD("try to load library '%s'", listLibs[i].c_str()); @@ -245,7 +246,7 @@ CameraActivity::ErrorCode CameraWrapperConnector::getSymbolFromLib(void* libHand return CameraActivity::NO_ERROR; } -void CameraWrapperConnector::fillListWrapperLibs(const std::string& folderPath, std::vector& listLibs) +void CameraWrapperConnector::fillListWrapperLibs(const cv::String& folderPath, std::vector& listLibs) { DIR *dp; struct dirent *ep; @@ -264,7 +265,7 @@ void CameraWrapperConnector::fillListWrapperLibs(const std::string& folderPath, } } -std::string CameraWrapperConnector::getDefaultPathLibFolder() +cv::String CameraWrapperConnector::getDefaultPathLibFolder() { #define BIN_PACKAGE_NAME(x) "org.opencv.lib_v" CVAUX_STR(CV_VERSION_EPOCH) CVAUX_STR(CV_VERSION_MAJOR) "_" x const char* const packageList[] = {BIN_PACKAGE_NAME("armv7a"), OPENCV_ENGINE_PACKAGE}; @@ -287,10 +288,10 @@ std::string CameraWrapperConnector::getDefaultPathLibFolder() } } - return std::string(); + return cv::String(); } -std::string CameraWrapperConnector::getPathLibFolder() +cv::String CameraWrapperConnector::getPathLibFolder() { if (!pathLibFolder.empty()) return pathLibFolder; @@ -358,10 +359,10 @@ std::string CameraWrapperConnector::getPathLibFolder() LOGE("Could not get library name and base address"); } - return std::string(); + return cv::String(); } -void CameraWrapperConnector::setPathLibFolder(const std::string& path) +void CameraWrapperConnector::setPathLibFolder(const cv::String& path) { pathLibFolder=path; } diff --git a/modules/calib3d/test/test_chesscorners.cpp b/modules/calib3d/test/test_chesscorners.cpp index 42c25b86a..bbc792ea5 100644 --- a/modules/calib3d/test/test_chesscorners.cpp +++ b/modules/calib3d/test/test_chesscorners.cpp @@ -217,7 +217,7 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename ) ts->update_context( this, idx, true ); /* read the image */ - string img_file = board_list[idx * 2]; + String img_file = board_list[idx * 2]; Mat gray = imread( folder + img_file, 0); if( gray.empty() ) @@ -227,7 +227,7 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename ) return; } - string _filename = folder + (string)board_list[idx * 2 + 1]; + String _filename = folder + (String)board_list[idx * 2 + 1]; bool doesContatinChessboard; Mat expected; { diff --git a/modules/calib3d/test/test_stereomatching.cpp b/modules/calib3d/test/test_stereomatching.cpp index 4b35dad99..d1cdb23b7 100644 --- a/modules/calib3d/test/test_stereomatching.cpp +++ b/modules/calib3d/test/test_stereomatching.cpp @@ -593,10 +593,10 @@ int CV_StereoMatchingTest::readDatasetsParams( FileStorage& fs ) assert(fn.isSeq()); for( int i = 0; i < (int)fn.size(); i+=3 ) { - string _name = fn[i]; + String _name = fn[i]; DatasetParams params; - string sf = fn[i+1]; params.dispScaleFactor = atoi(sf.c_str()); - string uv = fn[i+2]; params.dispUnknVal = atoi(uv.c_str()); + String sf = fn[i+1]; params.dispScaleFactor = atoi(sf.c_str()); + String uv = fn[i+2]; params.dispUnknVal = atoi(uv.c_str()); datasetsParams[_name] = params; } return cvtest::TS::OK; @@ -680,10 +680,10 @@ protected: assert(fn.isSeq()); for( int i = 0; i < (int)fn.size(); i+=4 ) { - string caseName = fn[i], datasetName = fn[i+1]; + String caseName = fn[i], datasetName = fn[i+1]; RunParams params; - string ndisp = fn[i+2]; params.ndisp = atoi(ndisp.c_str()); - string winSize = fn[i+3]; params.winSize = atoi(winSize.c_str()); + String ndisp = fn[i+2]; params.ndisp = atoi(ndisp.c_str()); + String winSize = fn[i+3]; params.winSize = atoi(winSize.c_str()); caseNames.push_back( caseName ); caseDatasets.push_back( datasetName ); caseRunParams.push_back( params ); @@ -734,11 +734,11 @@ protected: assert(fn.isSeq()); for( int i = 0; i < (int)fn.size(); i+=5 ) { - string caseName = fn[i], datasetName = fn[i+1]; + String caseName = fn[i], datasetName = fn[i+1]; RunParams params; - string ndisp = fn[i+2]; params.ndisp = atoi(ndisp.c_str()); - string winSize = fn[i+3]; params.winSize = atoi(winSize.c_str()); - string fullDP = fn[i+4]; params.fullDP = atoi(fullDP.c_str()) == 0 ? false : true; + String ndisp = fn[i+2]; params.ndisp = atoi(ndisp.c_str()); + String winSize = fn[i+3]; params.winSize = atoi(winSize.c_str()); + String fullDP = fn[i+4]; params.fullDP = atoi(fullDP.c_str()) == 0 ? false : true; caseNames.push_back( caseName ); caseDatasets.push_back( datasetName ); caseRunParams.push_back( params ); diff --git a/modules/contrib/doc/facerec/colormaps.rst b/modules/contrib/doc/facerec/colormaps.rst index beba413fd..95750ab5c 100644 --- a/modules/contrib/doc/facerec/colormaps.rst +++ b/modules/contrib/doc/facerec/colormaps.rst @@ -51,9 +51,9 @@ In OpenCV 2.4 you only need :ocv:func:`applyColorMap` to apply a colormap on a g int main(int argc, const char *argv[]) { // Get the path to the image, if it was given // if no arguments were given. - string filename; + String filename; if (argc > 1) { - filename = string(argv[1]); + filename = String(argv[1]); } // The following lines show how to apply a colormap on a given image // and show it with cv::imshow example with an image. An exception is diff --git a/modules/contrib/doc/facerec/facerec_api.rst b/modules/contrib/doc/facerec/facerec_api.rst index 8bea7070a..e16d15e62 100644 --- a/modules/contrib/doc/facerec/facerec_api.rst +++ b/modules/contrib/doc/facerec/facerec_api.rst @@ -30,10 +30,10 @@ a unified access to all face recongition algorithms in OpenCV. :: virtual void predict(InputArray src, int &label, double &confidence) const = 0; // Serializes this object to a given filename. - virtual void save(const string& filename) const; + virtual void save(const String& filename) const; // Deserializes this object from a given filename. - virtual void load(const string& filename); + virtual void load(const String& filename); // Serializes this object to a given cv::FileStorage. virtual void save(FileStorage& fs) const = 0; @@ -52,7 +52,7 @@ I'll go a bit more into detail explaining :ocv:class:`FaceRecognizer`, because i * So called “virtual constructor”. That is, each Algorithm derivative is registered at program start and you can get the list of registered algorithms and create instance of a particular algorithm by its name (see :ocv:func:`Algorithm::create`). If you plan to add your own algorithms, it is good practice to add a unique prefix to your algorithms to distinguish them from other algorithms. -* Setting/Retrieving algorithm parameters by name. If you used video capturing functionality from OpenCV highgui module, you are probably familar with :ocv:cfunc:`cvSetCaptureProperty`, :ocv:cfunc:`cvGetCaptureProperty`, :ocv:func:`VideoCapture::set` and :ocv:func:`VideoCapture::get`. :ocv:class:`Algorithm` provides similar method where instead of integer id's you specify the parameter names as text strings. See :ocv:func:`Algorithm::set` and :ocv:func:`Algorithm::get` for details. +* Setting/Retrieving algorithm parameters by name. If you used video capturing functionality from OpenCV highgui module, you are probably familar with :ocv:cfunc:`cvSetCaptureProperty`, :ocv:cfunc:`cvGetCaptureProperty`, :ocv:func:`VideoCapture::set` and :ocv:func:`VideoCapture::get`. :ocv:class:`Algorithm` provides similar method where instead of integer id's you specify the parameter names as text Strings. See :ocv:func:`Algorithm::set` and :ocv:func:`Algorithm::get` for details. * Reading and writing parameters from/to XML or YAML files. Every Algorithm derivative can store all its parameters and then read them back. There is no need to re-implement it each time. @@ -113,7 +113,7 @@ Since every :ocv:class:`FaceRecognizer` is a :ocv:class:`Algorithm`, you can use // Create a FaceRecognizer: Ptr model = createEigenFaceRecognizer(); // And here's how to get its name: - std::string name = model->name(); + String name = model->name(); FaceRecognizer::train @@ -251,7 +251,7 @@ FaceRecognizer::save Saves a :ocv:class:`FaceRecognizer` and its model state. -.. ocv:function:: void FaceRecognizer::save(const string& filename) const +.. ocv:function:: void FaceRecognizer::save(const String& filename) const Saves this model to a given filename, either as XML or YAML. @@ -265,7 +265,7 @@ Saves a :ocv:class:`FaceRecognizer` and its model state. Every :ocv:class:`FaceRecognizer` overwrites ``FaceRecognizer::save(FileStorage& fs)`` -to save the internal model state. ``FaceRecognizer::save(const string& filename)`` saves +to save the internal model state. ``FaceRecognizer::save(const String& filename)`` saves the state of a model to the given filename. The suffix ``const`` means that prediction does not affect the internal model @@ -276,13 +276,13 @@ FaceRecognizer::load Loads a :ocv:class:`FaceRecognizer` and its model state. -.. ocv:function:: void FaceRecognizer::load( const string& filename ) +.. ocv:function:: void FaceRecognizer::load( const String& filename ) .. ocv:function:: void FaceRecognizer::load( const FileStorage& fs ) = 0 Loads a persisted model and state from a given XML or YAML file . Every :ocv:class:`FaceRecognizer` has to overwrite ``FaceRecognizer::load(FileStorage& fs)`` to enable loading the model state. ``FaceRecognizer::load(FileStorage& fs)`` in -turn gets called by ``FaceRecognizer::load(const string& filename)``, to ease +turn gets called by ``FaceRecognizer::load(const String& filename)``, to ease saving a model. createEigenFaceRecognizer diff --git a/modules/contrib/doc/retina/index.rst b/modules/contrib/doc/retina/index.rst index a3a5bc82f..0cd8752be 100644 --- a/modules/contrib/doc/retina/index.rst +++ b/modules/contrib/doc/retina/index.rst @@ -16,7 +16,7 @@ Class which provides the main controls to the Gipsa/Listic labs human retina mo **NOTE : See the Retina tutorial in the tutorial/contrib section for complementary explanations.** -The retina can be settled up with various parameters, by default, the retina cancels mean luminance and enforces all details of the visual scene. In order to use your own parameters, you can use at least one time the *write(std::string fs)* method which will write a proper XML file with all default parameters. Then, tweak it on your own and reload them at any time using method *setup(std::string fs)*. These methods update a *Retina::RetinaParameters* member structure that is described hereafter. :: +The retina can be settled up with various parameters, by default, the retina cancels mean luminance and enforces all details of the visual scene. In order to use your own parameters, you can use at least one time the *write(String fs)* method which will write a proper XML file with all default parameters. Then, tweak it on your own and reload them at any time using method *setup(String fs)*. These methods update a *Retina::RetinaParameters* member structure that is described hereafter. :: class Retina { @@ -49,12 +49,12 @@ The retina can be settled up with various parameters, by default, the retina can Size outputSize (); // setup methods with specific parameters specification of global xml config file loading/write - void setup (std::string retinaParameterFile="", const bool applyDefaultSetupOnFailure=true); + void setup (String retinaParameterFile="", const bool applyDefaultSetupOnFailure=true); void setup (FileStorage &fs, const bool applyDefaultSetupOnFailure=true); void setup (RetinaParameters newParameters); struct Retina::RetinaParameters getParameters (); - const std::string printSetup (); - virtual void write (std::string fs) const; + const String printSetup (); + virtual void write (String fs) const; virtual void write (FileStorage &fs) const; void setupOPLandIPLParvoChannel (const bool colorMode=true, const bool normaliseOutput=true, const float photoreceptorsLocalAdaptationSensitivity=0.7, const float photoreceptorsTemporalConstant=0.5, const float photoreceptorsSpatialConstant=0.53, const float horizontalCellsGain=0, const float HcellsTemporalConstant=1, const float HcellsSpatialConstant=7, const float ganglionCellsSensitivity=0.7); void setupIPLMagnoChannel (const bool normaliseOutput=true, const float parasolCells_beta=0, const float parasolCells_tau=0, const float parasolCells_k=7, const float amacrinCellsTemporalCutFrequency=1.2, const float V0CompressionParameter=0.95, const float localAdaptintegration_tau=0, const float localAdaptintegration_k=7); @@ -235,7 +235,7 @@ Retina::outputSize Retina::printSetup ++++++++++++++++++ -.. ocv:function:: const std::string Retina::printSetup() +.. ocv:function:: const String Retina::printSetup() Outputs a string showing the used parameters setup @@ -264,7 +264,7 @@ Retina::setColorSaturation Retina::setup +++++++++++++ -.. ocv:function:: void Retina::setup(std::string retinaParameterFile = "", const bool applyDefaultSetupOnFailure = true ) +.. ocv:function:: void Retina::setup(String retinaParameterFile = "", const bool applyDefaultSetupOnFailure = true ) .. ocv:function:: void Retina::setup(FileStorage & fs, const bool applyDefaultSetupOnFailure = true ) .. ocv:function:: void Retina::setup(RetinaParameters newParameters) @@ -278,7 +278,7 @@ Retina::setup Retina::write +++++++++++++ -.. ocv:function:: void Retina::write( std::string fs ) const +.. ocv:function:: void Retina::write( String fs ) const .. ocv:function:: void Retina::write( FileStorage& fs ) const Write xml/yml formated parameters information diff --git a/modules/contrib/include/opencv2/contrib.hpp b/modules/contrib/include/opencv2/contrib.hpp index 44bf3313e..09989ec1f 100644 --- a/modules/contrib/include/opencv2/contrib.hpp +++ b/modules/contrib/include/opencv2/contrib.hpp @@ -301,7 +301,7 @@ namespace cv void computeNormals(float normalRadius, int minNeighbors = 20); void computeNormals(const std::vector& subset, float normalRadius, int minNeighbors = 20); - void writeAsVrml(const std::string& file, const std::vector& colors = std::vector()) const; + void writeAsVrml(const String& file, const std::vector& colors = std::vector()) const; std::vector vtx; std::vector normals; @@ -610,9 +610,9 @@ namespace cv class CV_EXPORTS Directory { public: - static std::vector GetListFiles ( const std::string& path, const std::string & exten = "*", bool addPath = true ); - static std::vector GetListFilesR ( const std::string& path, const std::string & exten = "*", bool addPath = true ); - static std::vector GetListFolders( const std::string& path, const std::string & exten = "*", bool addPath = true ); + static std::vector GetListFiles ( const String& path, const String & exten = "*", bool addPath = true ); + static std::vector GetListFilesR ( const String& path, const String & exten = "*", bool addPath = true ); + static std::vector GetListFolders( const String& path, const String & exten = "*", bool addPath = true ); }; /* @@ -869,10 +869,10 @@ namespace cv } // Serializes this object to a given filename. - void save(const std::string& filename) const; + void save(const String& filename) const; // Deserializes this object from a given filename. - void load(const std::string& filename); + void load(const String& filename); // Serializes this object to a given cv::FileStorage. void save(FileStorage& fs) const; @@ -926,10 +926,10 @@ namespace cv CV_WRAP virtual void predict(InputArray src, CV_OUT int &label, CV_OUT double &confidence) const = 0; // Serializes this object to a given filename. - CV_WRAP virtual void save(const std::string& filename) const; + CV_WRAP virtual void save(const String& filename) const; // Deserializes this object from a given filename. - CV_WRAP virtual void load(const std::string& filename); + CV_WRAP virtual void load(const String& filename); // Serializes this object to a given cv::FileStorage. virtual void save(FileStorage& fs) const = 0; diff --git a/modules/contrib/include/opencv2/contrib/retina.hpp b/modules/contrib/include/opencv2/contrib/retina.hpp index 456daab44..32ba1cf0e 100644 --- a/modules/contrib/include/opencv2/contrib/retina.hpp +++ b/modules/contrib/include/opencv2/contrib/retina.hpp @@ -182,7 +182,7 @@ public: * @param retinaParameterFile : the parameters filename * @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error */ - void setup(std::string retinaParameterFile="", const bool applyDefaultSetupOnFailure=true); + void setup(String retinaParameterFile="", const bool applyDefaultSetupOnFailure=true); /** @@ -212,13 +212,13 @@ public: * parameters setup display method * @return a string which contains formatted parameters information */ - const std::string printSetup(); + const String printSetup(); /** * write xml/yml formated parameters information * @rparam fs : the filename of the xml file that will be open and writen with formatted parameters information */ - virtual void write( std::string fs ) const; + virtual void write( String fs ) const; /** diff --git a/modules/contrib/src/facerec.cpp b/modules/contrib/src/facerec.cpp index fedaeab88..de4fb5bc4 100644 --- a/modules/contrib/src/facerec.cpp +++ b/modules/contrib/src/facerec.cpp @@ -35,7 +35,7 @@ inline void readFileNodeList(const FileNode& fn, std::vector<_Tp>& result) { // Writes the a list of given items to a cv::FileStorage. template -inline void writeFileNodeList(FileStorage& fs, const std::string& name, +inline void writeFileNodeList(FileStorage& fs, const String& name, const std::vector<_Tp>& items) { // typedefs typedef typename std::vector<_Tp>::const_iterator constVecIterator; @@ -50,7 +50,7 @@ inline void writeFileNodeList(FileStorage& fs, const std::string& name, static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) { // make sure the input data is a vector of matrices or vector of vector if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) { - std::string error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >)."; + String error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >)."; CV_Error(CV_StsBadArg, error_message); } // number of samples @@ -66,7 +66,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double for(unsigned int i = 0; i < n; i++) { // make sure data can be reshaped, throw exception if not! if(src.getMat(i).total() != d) { - std::string error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, d, src.getMat(i).total()); + String error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, d, src.getMat(i).total()); CV_Error(CV_StsBadArg, error_message); } // get a hold of the current row @@ -305,11 +305,11 @@ void FaceRecognizer::update(InputArrayOfArrays src, InputArray labels ) { return; } - std::string error_msg = format("This FaceRecognizer (%s) does not support updating, you have to use FaceRecognizer::train to update it.", this->name().c_str()); + String error_msg = format("This FaceRecognizer (%s) does not support updating, you have to use FaceRecognizer::train to update it.", this->name().c_str()); CV_Error(CV_StsNotImplemented, error_msg); } -void FaceRecognizer::save(const std::string& filename) const { +void FaceRecognizer::save(const String& filename) const { FileStorage fs(filename, FileStorage::WRITE); if (!fs.isOpened()) CV_Error(CV_StsError, "File can't be opened for writing!"); @@ -317,7 +317,7 @@ void FaceRecognizer::save(const std::string& filename) const { fs.release(); } -void FaceRecognizer::load(const std::string& filename) { +void FaceRecognizer::load(const String& filename) { FileStorage fs(filename, FileStorage::READ); if (!fs.isOpened()) CV_Error(CV_StsError, "File can't be opened for writing!"); @@ -330,17 +330,17 @@ void FaceRecognizer::load(const std::string& filename) { //------------------------------------------------------------------------------ void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) { if(_src.total() == 0) { - std::string error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); + String error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); CV_Error(CV_StsBadArg, error_message); } else if(_local_labels.getMat().type() != CV_32SC1) { - std::string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _local_labels.type()); + String error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _local_labels.type()); CV_Error(CV_StsBadArg, error_message); } // make sure data has correct size if(_src.total() > 1) { for(int i = 1; i < static_cast(_src.total()); i++) { if(_src.getMat(i-1).total() != _src.getMat(i).total()) { - std::string error_message = format("In the Eigenfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", _src.getMat(i-1).total(), _src.getMat(i).total()); + String error_message = format("In the Eigenfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", _src.getMat(i-1).total(), _src.getMat(i).total()); CV_Error(CV_StsUnsupportedFormat, error_message); } } @@ -354,7 +354,7 @@ void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) { int n = data.rows; // assert there are as much samples as labels if(static_cast(labels.total()) != n) { - std::string error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", n, labels.total()); + String error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", n, labels.total()); CV_Error(CV_StsBadArg, error_message); } // clear existing model data @@ -385,11 +385,11 @@ void Eigenfaces::predict(InputArray _src, int &minClass, double &minDist) const // make sure the user is passing correct data if(_projections.empty()) { // throw error if no data (or simply return -1?) - std::string error_message = "This Eigenfaces model is not computed yet. Did you call Eigenfaces::train?"; + String error_message = "This Eigenfaces model is not computed yet. Did you call Eigenfaces::train?"; CV_Error(CV_StsError, error_message); } else if(_eigenvectors.rows != static_cast(src.total())) { // check data alignment just for clearer exception messages - std::string error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total()); + String error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total()); CV_Error(CV_StsBadArg, error_message); } // project into PCA subspace @@ -439,17 +439,17 @@ void Eigenfaces::save(FileStorage& fs) const { //------------------------------------------------------------------------------ void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) { if(src.total() == 0) { - std::string error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); + String error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); CV_Error(CV_StsBadArg, error_message); } else if(_lbls.getMat().type() != CV_32SC1) { - std::string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _lbls.type()); + String error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _lbls.type()); CV_Error(CV_StsBadArg, error_message); } // make sure data has correct size if(src.total() > 1) { for(int i = 1; i < static_cast(src.total()); i++) { if(src.getMat(i-1).total() != src.getMat(i).total()) { - std::string error_message = format("In the Fisherfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", src.getMat(i-1).total(), src.getMat(i).total()); + String error_message = format("In the Fisherfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", src.getMat(i-1).total(), src.getMat(i).total()); CV_Error(CV_StsUnsupportedFormat, error_message); } } @@ -461,10 +461,10 @@ void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) { int N = data.rows; // make sure labels are passed in correct shape if(labels.total() != (size_t) N) { - std::string error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", N, labels.total()); + String error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", N, labels.total()); CV_Error(CV_StsBadArg, error_message); } else if(labels.rows != 1 && labels.cols != 1) { - std::string error_message = format("Expected the labels in a matrix with one row or column! Given dimensions are rows=%s, cols=%d.", labels.rows, labels.cols); + String error_message = format("Expected the labels in a matrix with one row or column! Given dimensions are rows=%s, cols=%d.", labels.rows, labels.cols); CV_Error(CV_StsBadArg, error_message); } // clear existing model data @@ -505,10 +505,10 @@ void Fisherfaces::predict(InputArray _src, int &minClass, double &minDist) const // check data alignment just for clearer exception messages if(_projections.empty()) { // throw error if no data (or simply return -1?) - std::string error_message = "This Fisherfaces model is not computed yet. Did you call Fisherfaces::train?"; + String error_message = "This Fisherfaces model is not computed yet. Did you call Fisherfaces::train?"; CV_Error(CV_StsBadArg, error_message); } else if(src.total() != (size_t) _eigenvectors.rows) { - std::string error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total()); + String error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total()); CV_Error(CV_StsBadArg, error_message); } // project into LDA subspace @@ -640,7 +640,7 @@ static void elbp(InputArray src, OutputArray dst, int radius, int neighbors) case CV_32FC1: elbp_(src,dst, radius, neighbors); break; case CV_64FC1: elbp_(src,dst, radius, neighbors); break; default: - std::string error_msg = format("Using Original Local Binary Patterns for feature extraction only works on single-channel images (given %d). Please pass the image data as a grayscale image!", type); + String error_msg = format("Using Original Local Binary Patterns for feature extraction only works on single-channel images (given %d). Please pass the image data as a grayscale image!", type); CV_Error(CV_StsNotImplemented, error_msg); break; } @@ -768,14 +768,14 @@ void LBPH::update(InputArrayOfArrays _in_src, InputArray _in_labels) { void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserveData) { if(_in_src.kind() != _InputArray::STD_VECTOR_MAT && _in_src.kind() != _InputArray::STD_VECTOR_VECTOR) { - std::string error_message = "The images are expected as InputArray::STD_VECTOR_MAT (a std::vector) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >)."; + String error_message = "The images are expected as InputArray::STD_VECTOR_MAT (a std::vector) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >)."; CV_Error(CV_StsBadArg, error_message); } if(_in_src.total() == 0) { - std::string error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); + String error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); CV_Error(CV_StsUnsupportedFormat, error_message); } else if(_in_labels.getMat().type() != CV_32SC1) { - std::string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _in_labels.type()); + String error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _in_labels.type()); CV_Error(CV_StsUnsupportedFormat, error_message); } // get the vector of matrices @@ -785,7 +785,7 @@ void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserv Mat labels = _in_labels.getMat(); // check if data is well- aligned if(labels.total() != src.size()) { - std::string error_message = format("The number of samples (src) must equal the number of labels (labels). Was len(samples)=%d, len(labels)=%d.", src.size(), _labels.total()); + String error_message = format("The number of samples (src) must equal the number of labels (labels). Was len(samples)=%d, len(labels)=%d.", src.size(), _labels.total()); CV_Error(CV_StsBadArg, error_message); } // if this model should be trained without preserving old data, delete old model data @@ -816,7 +816,7 @@ void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserv void LBPH::predict(InputArray _src, int &minClass, double &minDist) const { if(_histograms.empty()) { // throw error if no data (or simply return -1?) - std::string error_message = "This LBPH model is not computed yet. Did you call the train method?"; + String error_message = "This LBPH model is not computed yet. Did you call the train method?"; CV_Error(CV_StsBadArg, error_message); } Mat src = _src.getMat(); diff --git a/modules/contrib/src/inputoutput.cpp b/modules/contrib/src/inputoutput.cpp index ee97e1287..f64502e43 100644 --- a/modules/contrib/src/inputoutput.cpp +++ b/modules/contrib/src/inputoutput.cpp @@ -10,11 +10,11 @@ namespace cv { - std::vector Directory::GetListFiles( const std::string& path, const std::string & exten, bool addPath ) + std::vector Directory::GetListFiles( const String& path, const String & exten, bool addPath ) { - std::vector list; + std::vector list; list.clear(); - std::string path_f = path + "/" + exten; + String path_f = path + "/" + exten; #ifdef WIN32 WIN32_FIND_DATA FindFileData; HANDLE hFind; @@ -57,10 +57,10 @@ namespace cv if (dirp->d_type == DT_REG) { if (exten.compare("*") == 0) - list.push_back(static_cast(dirp->d_name)); + list.push_back(static_cast(dirp->d_name)); else - if (std::string(dirp->d_name).find(exten) != std::string::npos) - list.push_back(static_cast(dirp->d_name)); + if (String(dirp->d_name).find(exten) != String::npos) + list.push_back(static_cast(dirp->d_name)); } } closedir(dp); @@ -69,10 +69,10 @@ namespace cv return list; } - std::vector Directory::GetListFolders( const std::string& path, const std::string & exten, bool addPath ) + std::vector Directory::GetListFolders( const String& path, const String & exten, bool addPath ) { - std::vector list; - std::string path_f = path + "/" + exten; + std::vector list; + String path_f = path + "/" + exten; list.clear(); #ifdef WIN32 WIN32_FIND_DATA FindFileData; @@ -117,10 +117,10 @@ namespace cv strcmp(dirp->d_name, "..") != 0 ) { if (exten.compare("*") == 0) - list.push_back(static_cast(dirp->d_name)); + list.push_back(static_cast(dirp->d_name)); else - if (std::string(dirp->d_name).find(exten) != std::string::npos) - list.push_back(static_cast(dirp->d_name)); + if (String(dirp->d_name).find(exten) != String::npos) + list.push_back(static_cast(dirp->d_name)); } } closedir(dp); @@ -129,16 +129,16 @@ namespace cv return list; } - std::vector Directory::GetListFilesR ( const std::string& path, const std::string & exten, bool addPath ) + std::vector Directory::GetListFilesR ( const String& path, const String & exten, bool addPath ) { - std::vector list = Directory::GetListFiles(path, exten, addPath); + std::vector list = Directory::GetListFiles(path, exten, addPath); - std::vector dirs = Directory::GetListFolders(path, exten, addPath); + std::vector dirs = Directory::GetListFolders(path, exten, addPath); - std::vector::const_iterator it; + std::vector::const_iterator it; for (it = dirs.begin(); it != dirs.end(); ++it) { - std::vector cl = Directory::GetListFiles(*it, exten, addPath); + std::vector cl = Directory::GetListFiles(*it, exten, addPath); list.insert(list.end(), cl.begin(), cl.end()); } diff --git a/modules/contrib/src/lda.cpp b/modules/contrib/src/lda.cpp index 442d56750..e643529ae 100644 --- a/modules/contrib/src/lda.cpp +++ b/modules/contrib/src/lda.cpp @@ -42,7 +42,7 @@ static Mat argsort(InputArray _src, bool ascending=true) { Mat src = _src.getMat(); if (src.rows != 1 && src.cols != 1) { - std::string error_message = "Wrong shape of input matrix! Expected a matrix with one row or column."; + String error_message = "Wrong shape of input matrix! Expected a matrix with one row or column."; CV_Error(CV_StsBadArg, error_message); } int flags = CV_SORT_EVERY_ROW+(ascending ? CV_SORT_ASCENDING : CV_SORT_DESCENDING); @@ -54,7 +54,7 @@ static Mat argsort(InputArray _src, bool ascending=true) static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) { // make sure the input data is a vector of matrices or vector of vector if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) { - std::string error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >)."; + String error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >)."; CV_Error(CV_StsBadArg, error_message); } // number of samples @@ -70,7 +70,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double for(int i = 0; i < (int)n; i++) { // make sure data can be reshaped, throw exception if not! if(src.getMat(i).total() != d) { - std::string error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, (int)d, (int)src.getMat(i).total()); + String error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, (int)d, (int)src.getMat(i).total()); CV_Error(CV_StsBadArg, error_message); } // get a hold of the current row @@ -178,12 +178,12 @@ Mat subspaceProject(InputArray _W, InputArray _mean, InputArray _src) { int d = src.cols; // make sure the data has the correct shape if(W.rows != d) { - std::string error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols); + String error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols); CV_Error(CV_StsBadArg, error_message); } // make sure mean is correct if not empty if(!mean.empty() && (mean.total() != (size_t) d)) { - std::string error_message = format("Wrong mean shape for the given data matrix. Expected %d, but was %d.", d, mean.total()); + String error_message = format("Wrong mean shape for the given data matrix. Expected %d, but was %d.", d, mean.total()); CV_Error(CV_StsBadArg, error_message); } // create temporary matrices @@ -216,12 +216,12 @@ Mat subspaceReconstruct(InputArray _W, InputArray _mean, InputArray _src) int d = src.cols; // make sure the data has the correct shape if(W.cols != d) { - std::string error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols); + String error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols); CV_Error(CV_StsBadArg, error_message); } // make sure mean is correct if not empty if(!mean.empty() && (mean.total() != (size_t) W.rows)) { - std::string error_message = format("Wrong mean shape for the given eigenvector matrix. Expected %d, but was %d.", W.cols, mean.total()); + String error_message = format("Wrong mean shape for the given eigenvector matrix. Expected %d, but was %d.", W.cols, mean.total()); CV_Error(CV_StsBadArg, error_message); } // initalize temporary matrices @@ -936,7 +936,7 @@ public: //------------------------------------------------------------------------------ // Linear Discriminant Analysis implementation //------------------------------------------------------------------------------ -void LDA::save(const std::string& filename) const { +void LDA::save(const String& filename) const { FileStorage fs(filename, FileStorage::WRITE); if (!fs.isOpened()) { CV_Error(CV_StsError, "File can't be opened for writing!"); @@ -946,7 +946,7 @@ void LDA::save(const std::string& filename) const { } // Deserializes this object from a given filename. -void LDA::load(const std::string& filename) { +void LDA::load(const String& filename) { FileStorage fs(filename, FileStorage::READ); if (!fs.isOpened()) CV_Error(CV_StsError, "File can't be opened for writing!"); @@ -1001,12 +1001,12 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) { // we can't do a LDA on one class, what do you // want to separate from each other then? if(C == 1) { - std::string error_message = "At least two classes are needed to perform a LDA. Reason: Only one class was given!"; + String error_message = "At least two classes are needed to perform a LDA. Reason: Only one class was given!"; CV_Error(CV_StsBadArg, error_message); } // throw error if less labels, than samples if (labels.size() != static_cast(N)) { - std::string error_message = format("The number of samples must equal the number of labels. Given %d labels, %d samples. ", labels.size(), N); + String error_message = format("The number of samples must equal the number of labels. Given %d labels, %d samples. ", labels.size(), N); CV_Error(CV_StsBadArg, error_message); } // warn if within-classes scatter matrix becomes singular @@ -1089,7 +1089,7 @@ void LDA::compute(InputArrayOfArrays _src, InputArray _lbls) { lda(_src.getMat(), _lbls); break; default: - std::string error_message= format("InputArray Datatype %d is not supported.", _src.kind()); + String error_message= format("InputArray Datatype %d is not supported.", _src.kind()); CV_Error(CV_StsBadArg, error_message); break; } diff --git a/modules/contrib/src/retina.cpp b/modules/contrib/src/retina.cpp index 146489687..772b146e7 100644 --- a/modules/contrib/src/retina.cpp +++ b/modules/contrib/src/retina.cpp @@ -70,7 +70,7 @@ */ #include "precomp.hpp" #include "retinafilter.hpp" -#include +#include namespace cv { @@ -112,25 +112,26 @@ void Retina::setColorSaturation(const bool saturateColors, const float colorSatu struct Retina::RetinaParameters Retina::getParameters(){return _retinaParameters;} -void Retina::setup(std::string retinaParameterFile, const bool applyDefaultSetupOnFailure) +void Retina::setup(String retinaParameterFile, const bool applyDefaultSetupOnFailure) { try { // opening retinaParameterFile in read mode cv::FileStorage fs(retinaParameterFile, cv::FileStorage::READ); setup(fs, applyDefaultSetupOnFailure); - }catch(Exception &e) - { - std::cout<<"Retina::setup: wrong/unappropriate xml parameter file : error report :`n=>"<%s\n", e.what()); + if (applyDefaultSetupOnFailure) + { + printf("Retina::setup: resetting retina with default parameters\n"); + setupOPLandIPLParvoChannel(); + setupIPLMagnoChannel(); + } else { - std::cout<<"=> keeping current parameters"< keeping current parameters\n"); } } } @@ -142,7 +143,7 @@ void Retina::setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure) // read parameters file if it exists or apply default setup if asked for if (!fs.isOpened()) { - std::cout<<"Retina::setup: provided parameters file could not be open... skeeping configuration"<"< keeping current parameters"<%s\n", e.what()); + printf("=> keeping current parameters\n"); } // report current configuration - std::cout< localAdaptintegration_tau : " << _retinaParameters.IplMagno.localAdaptintegration_tau << "\n==> localAdaptintegration_k : " << _retinaParameters.IplMagno.localAdaptintegration_k <<"}"; - return outmessage.str(); + return outmessage.str().c_str(); } -void Retina::write( std::string fs ) const +void Retina::write( String fs ) const { FileStorage parametersSaveFile(fs, cv::FileStorage::WRITE ); write(parametersSaveFile); @@ -364,7 +365,7 @@ void Retina::_init(const cv::Size inputSz, const bool colorMode, RETINA_COLORSAM _retinaFilter->clearAllBuffers(); // report current configuration - std::cout< &grayMatrixToConvert, const unsigned int nbRows, const unsigned int nbColumns, const bool colorMode, cv::Mat &outBuffer) diff --git a/modules/contrib/src/spinimages.cpp b/modules/contrib/src/spinimages.cpp index 7f7a8ad63..fd580b566 100644 --- a/modules/contrib/src/spinimages.cpp +++ b/modules/contrib/src/spinimages.cpp @@ -494,7 +494,7 @@ void cv::Mesh3D::computeNormals(const std::vector& subset, float normalRadi ::computeNormals(octree, vtx, normals, mask, normalRadius, minNeighbors); } -void cv::Mesh3D::writeAsVrml(const std::string& file, const std::vector& _colors) const +void cv::Mesh3D::writeAsVrml(const String& file, const std::vector& _colors) const { std::ofstream ofs(file.c_str()); diff --git a/modules/core/doc/basic_structures.rst b/modules/core/doc/basic_structures.rst index d9cc30331..2d0faf2c6 100644 --- a/modules/core/doc/basic_structures.rst +++ b/modules/core/doc/basic_structures.rst @@ -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 ParamType<_Tp>::member_type Algorithm::get(const string& name) const +.. ocv:function:: template 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("param_name") * myalgo.get("param_name") * myalgo.get("param_name") - * myalgo.get("param_name") + * myalgo.get("param_name") * myalgo.get("param_name") * myalgo.get >("param_name") * myalgo.get("param_name") (it returns Ptr). @@ -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& value) -.. ocv:function:: void Algorithm::set(const string& name, const Ptr& 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& value) +.. ocv:function:: void Algorithm::set(const String& name, const Ptr& 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& algorithms) +.. ocv:function:: void Algorithm::getList(vector& 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 algorithms; + vector 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 Ptr<_Tp> Algorithm::create(const string& name) +.. ocv:function:: template Ptr<_Tp> Algorithm::create(const String& name) :param name: The algorithm name, one of the names returned by ``Algorithm::getList()``. diff --git a/modules/core/doc/command_line_parser.rst b/modules/core/doc/command_line_parser.rst index 53396b23b..64c72020a 100644 --- a/modules/core/doc/command_line_parser.rst +++ b/modules/core/doc/command_line_parser.rst @@ -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 T CommandLineParser::get(const std::string& name, bool space_delete = true) + .. ocv:function:: template T CommandLineParser::get(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("N"); double fps = parser.get("fps"); - std::string path = parser.get("path"); + String path = parser.get("path"); use_time_stamp = parser.has("timestamp"); - std::string img1 = parser.get(0); - std::string img2 = parser.get(1); + String img1 = parser.get(0); + String img2 = parser.get(1); int repeat = parser.get(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 }" diff --git a/modules/core/doc/drawing_functions.rst b/modules/core/doc/drawing_functions.rst index 6c0ac4b35..f821fc44e 100644 --- a/modules/core/doc/drawing_functions.rst +++ b/modules/core/doc/drawing_functions.rst @@ -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 diff --git a/modules/core/doc/utility_and_system_functions_and_macros.rst b/modules/core/doc/utility_and_system_functions_and_macros.rst index 54198b058..16038e0a4 100644 --- a/modules/core/doc/utility_and_system_functions_and_macros.rst +++ b/modules/core/doc/utility_and_system_functions_and_macros.rst @@ -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. diff --git a/modules/core/doc/xml_yaml_persistence.rst b/modules/core/doc/xml_yaml_persistence.rst index 102dafc70..b3938b75c 100644 --- a/modules/core/doc/xml_yaml_persistence.rst +++ b/modules/core/doc/xml_yaml_persistence.rst @@ -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`. diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 337ddb059..ec4f5610d 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -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 @@ -61,7 +62,6 @@ #include #include #include -#include #include #include #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 fs; //!< the underlying C FileStorage structure - std::string elname; //!< the currently written element + String elname; //!< the currently written element std::vector 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 ParamType<_Tp>::member_type get(const std::string& name) const; + template typename ParamType<_Tp>::member_type get(const String& name) const; template 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 getMatVector(const std::string& name) const; - CV_WRAP Ptr 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 getMatVector(const String& name) const; + CV_WRAP Ptr 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& value); - void set(const std::string& name, const Ptr& value); - template 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& value); + void set(const String& name, const Ptr& value); + template 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& value); - CV_WRAP void setAlgorithm(const std::string& name, const Ptr& value); - template 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& value); + CV_WRAP void setAlgorithm(const String& name, const Ptr& value); + template 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& value); void set(const char* name, const Ptr& 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& value); void setAlgorithm(const char* name, const Ptr& value); template 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& names) const; + CV_WRAP int paramType(const String& name) const; + CV_WRAP void getParams(CV_OUT std::vector& 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& algorithms); - CV_WRAP static Ptr _create(const std::string& name); - template static Ptr<_Tp> create(const std::string& name); + CV_WRAP static void getList(CV_OUT std::vector& algorithms); + CV_WRAP static Ptr _create(const String& name); + template 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& names) const; + void getParams(std::vector& 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& value, bool readOnly=false, std::vector (Algorithm::*getter)()=0, void (Algorithm::*setter)(const std::vector&)=0, - const std::string& help=std::string()); + const String& help=String()); void addParam(Algorithm& algo, const char* name, Ptr& value, bool readOnly=false, Ptr (Algorithm::*getter)()=0, void (Algorithm::*setter)(const Ptr&)=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 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 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 @@ -4353,10 +4356,10 @@ template<> struct ParamType enum { type = Param::REAL }; }; -template<> struct ParamType +template<> struct ParamType { - 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 } //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__*/ diff --git a/modules/core/include/opencv2/core/cvstd.hpp b/modules/core/include/opencv2/core/cvstd.hpp new file mode 100644 index 000000000..e5af0f234 --- /dev/null +++ b/modules/core/include/opencv2/core/cvstd.hpp @@ -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 +#include + +#include "opencv2/core/cvdef.h" + +#ifndef OPENCV_NOSTL +# include +#endif + +// import useful primitives from stl +#ifndef OPENCV_NOSTL_TRANSITIONAL +# include +# include +# include + +namespace cv +{ + using std::min; + using std::max; + using std::abs; + using std::swap; +} + +#else +namespace cv +{ + template inline T min(T a, T b) { return a < b ? a : b; } + template inline T max(T a, T b) { return a > b ? a : b; } + template inline T abs(T a) { return a < 0 ? -a : a; } + template 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 + 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& a, cv::String& b) { a.swap(b); } +} + +#endif //__OPENCV_CORE_CVSTD_HPP__ diff --git a/modules/core/include/opencv2/core/cvstd.inl.hpp b/modules/core/include/opencv2/core/cvstd.inl.hpp new file mode 100644 index 000000000..88d114a61 --- /dev/null +++ b/modules/core/include/opencv2/core/cvstd.inl.hpp @@ -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 +#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__ \ No newline at end of file diff --git a/modules/core/include/opencv2/core/gpumat.hpp b/modules/core/include/opencv2/core/gpumat.hpp index bb436ec55..54ba4e67f 100644 --- a/modules/core/include/opencv2/core/gpumat.hpp +++ b/modules/core/include/opencv2/core/gpumat.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_; diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index e3c45cd0c..26f91461a 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -2648,18 +2648,18 @@ template<> CV_EXPORTS void Ptr::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 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 inline void write(FileStorage& fs, const std::string& name, const Point_<_Tp>& pt ) +template 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 inline void write(FileStorage& fs, const std::string& name, const Point3_<_Tp>& pt ) +template 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 inline void write(FileStorage& fs, const std::string& nam write(fs, pt.z); } -template inline void write(FileStorage& fs, const std::string& name, const Size_<_Tp>& sz ) +template 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 inline void write(FileStorage& fs, const std::string& name, const Complex<_Tp>& c ) +template 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 inline void write(FileStorage& fs, const std::string& name, const Rect_<_Tp>& r ) +template 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 inline void write(FileStorage& fs, const std::string& nam write(fs, r.height); } -template inline void write(FileStorage& fs, const std::string& name, const Vec<_Tp, cn>& v ) +template 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 inline void write(FileStorage& fs, const std::string& name, const Scalar_<_Tp>& s ) +template 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 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 static inline void write( FileStorage& fs, const std::vec w(vec); } -template static inline void write( FileStorage& fs, const std::string& name, +template 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 static inline FileStorage& operator << (FileStorage& fs, const _Tp& value) { @@ -2858,10 +2858,10 @@ template 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 inline std::ostream& operator<<(std::ostream& out, const } -template inline Ptr<_Tp> Algorithm::create(const std::string& name) +template 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 -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 -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 inline typename ParamType<_Tp>::member_type Algorithm::get(const std::string& _name) const +template 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 inline typename ParamType<_Tp>::member_type Algorithm::ge template 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 inline void AlgorithmInfo::addParam(Algor template 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::type, &value, readOnly, diff --git a/modules/core/include/opencv2/core/utility.hpp b/modules/core/include/opencv2/core/utility.hpp index 6a08c37af..47be3e57f 100644 --- a/modules/core/include/opencv2/core/utility.hpp +++ b/modules/core/include/opencv2/core/utility.hpp @@ -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& 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& 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 - 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::type, (void*)&val); return val; - } + } template 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(int index, bool space_delete) const +{ + return get(index, space_delete); +} +template<> inline std::string CommandLineParser::get(const String& name, bool space_delete) const +{ + return get(name, space_delete); +} +#endif // OPENCV_NOSTL + } //namespace cv #endif //__OPENCV_CORE_UTILITY_H__ diff --git a/modules/core/src/algorithm.cpp b/modules/core/src/algorithm.cpp index 67c71443c..8e71e8322 100644 --- a/modules/core/src/algorithm.cpp +++ b/modules/core/src/algorithm.cpp @@ -96,7 +96,7 @@ template struct sorted_vector }; -template inline const _ValueTp* findstr(const sorted_vector& vec, +template inline const _ValueTp* findstr(const sorted_vector& 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 params; - std::string _name; + sorted_vector params; + String _name; }; -static sorted_vector& alglist() +static sorted_vector& alglist() { - static sorted_vector alglist_var; + static sorted_vector alglist_var; return alglist_var; } -void Algorithm::getList(std::vector& algorithms) +void Algorithm::getList(std::vector& algorithms) { alglist().get_keys(algorithms); } -Ptr Algorithm::_create(const std::string& name) +Ptr 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::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::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::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::type, &value); + info()->set(this, parameter.c_str(), ParamType::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::type, &value); } -void Algorithm::set(const std::string& parameter, const std::vector& value) +void Algorithm::set(const String& parameter, const std::vector& value) { info()->set(this, parameter.c_str(), ParamType >::type, &value); } -void Algorithm::set(const std::string& parameter, const Ptr& value) +void Algorithm::set(const String& parameter, const Ptr& value) { info()->set(this, parameter.c_str(), ParamType::type, &value); } @@ -229,9 +229,9 @@ void Algorithm::set(const char* parameter, bool value) info()->set(this, parameter, ParamType::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::type, &value); + info()->set(this, parameter, ParamType::type, &value); } void Algorithm::set(const char* parameter, const Mat& value) @@ -250,37 +250,37 @@ void Algorithm::set(const char* parameter, const Ptr& 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::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::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::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::type, &value); + info()->set(this, parameter.c_str(), ParamType::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::type, &value); } -void Algorithm::setMatVector(const std::string& parameter, const std::vector& value) +void Algorithm::setMatVector(const String& parameter, const std::vector& value) { info()->set(this, parameter.c_str(), ParamType >::type, &value); } -void Algorithm::setAlgorithm(const std::string& parameter, const Ptr& value) +void Algorithm::setAlgorithm(const String& parameter, const Ptr& value) { info()->set(this, parameter.c_str(), ParamType::type, &value); } @@ -300,9 +300,9 @@ void Algorithm::setBool(const char* parameter, bool value) info()->set(this, parameter, ParamType::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::type, &value); + info()->set(this, parameter, ParamType::type, &value); } void Algorithm::setMat(const char* parameter, const Mat& value) @@ -322,47 +322,47 @@ void Algorithm::setAlgorithm(const char* parameter, const Ptr& value) -int Algorithm::getInt(const std::string& parameter) const +int Algorithm::getInt(const String& parameter) const { return get(parameter); } -double Algorithm::getDouble(const std::string& parameter) const +double Algorithm::getDouble(const String& parameter) const { return get(parameter); } -bool Algorithm::getBool(const std::string& parameter) const +bool Algorithm::getBool(const String& parameter) const { return get(parameter); } -std::string Algorithm::getString(const std::string& parameter) const +String Algorithm::getString(const String& parameter) const { - return get(parameter); + return get(parameter); } -Mat Algorithm::getMat(const std::string& parameter) const +Mat Algorithm::getMat(const String& parameter) const { return get(parameter); } -std::vector Algorithm::getMatVector(const std::string& parameter) const +std::vector Algorithm::getMatVector(const String& parameter) const { return get >(parameter); } -Ptr Algorithm::getAlgorithm(const std::string& parameter) const +Ptr Algorithm::getAlgorithm(const String& parameter) const { return get(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& names) const +void Algorithm::getParams(std::vector& 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(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(pname)); else if( p.type == Param::STRING ) - cv::write(fs, pname, algo->get(pname)); + cv::write(fs, pname, algo->get(pname)); else if( p.type == Param::MAT ) cv::write(fs, pname, algo->get(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 nestedAlgo = Algorithm::_create((std::string)n["name"]); + Ptr 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 (Algorithm::*get_mat_vector)() const; Ptr (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&); void (Algorithm::*set_algo)(const Ptr&); @@ -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& names) const +void AlgorithmInfo::getParams(std::vector& names) const { data->params.get_keys(names); } @@ -1096,7 +1096,7 @@ void AlgorithmInfo::getParams(std::vector& 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::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::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::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::type, &value, readOnly, + addParam_(algo, parameter, ParamType::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::type, &value, readOnly, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); @@ -1164,7 +1164,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, std::vector& value, bool readOnly, std::vector (Algorithm::*getter)(), void (Algorithm::*setter)(const std::vector&), - const std::string& help) + const String& help) { addParam_(algo, parameter, ParamType >::type, &value, readOnly, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); @@ -1174,7 +1174,7 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, Ptr& value, bool readOnly, Ptr (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr&), - const std::string& help) + const String& help) { addParam_(algo, parameter, ParamType::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::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::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::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::type, &value, readOnly, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); diff --git a/modules/core/src/command_line_parser.cpp b/modules/core/src/command_line_parser.cpp index 1bffe5af7..0bd04ef96 100644 --- a/modules/core/src/command_line_parser.cpp +++ b/modules/core/src/command_line_parser.cpp @@ -1,17 +1,14 @@ - #include "precomp.hpp" -#include - namespace cv { struct CommandLineParserParams { public: - std::string help_message; - std::string def_value; - std::vector keys; + String help_message; + String def_value; + std::vector 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 data; - std::vector split_range_string(const std::string& str, char fs, char ss) const; - std::vector 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 split_range_string(const String& str, char fs, char ss) const; + std::vector 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 k = impl->split_range_string(keys, '{', '}'); + std::vector k = impl->split_range_string(keys, '{', '}'); int jj = 0; for (size_t i = 0; i < k.size(); i++) { - std::vector l = impl->split_string(k[i], '|', true); + std::vector 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 k_v = impl->split_string(s, '=', true); + std::vector 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 CommandLineParser::Impl::split_range_string(const std::string& _str, char fs, char ss) const +std::vector CommandLineParser::Impl::split_range_string(const String& _str, char fs, char ss) const { - std::string str = _str; - std::vector vec; - std::string word = ""; + String str = _str; + std::vector vec; + String word = ""; bool begin = false; while (!str.empty()) @@ -426,13 +424,13 @@ std::vector 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 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 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 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 CommandLineParser::Impl::split_range_string(const std:: return vec; } -std::vector CommandLineParser::Impl::split_string(const std::string& _str, char symbol, bool create_empty_item) const +std::vector CommandLineParser::Impl::split_string(const String& _str, char symbol, bool create_empty_item) const { - std::string str = _str; - std::vector vec; - std::string word = ""; + String str = _str; + std::vector vec; + String word = ""; while (!str.empty()) { @@ -502,7 +500,7 @@ std::vector CommandLineParser::Impl::split_string(const std::string } else { - word += str[0]; + word = word + str[0]; } str = str.substr(1, str.length() - 1); } diff --git a/modules/core/src/drawing.cpp b/modules/core/src/drawing.cpp index a6d5287be..a5392363a 100644 --- a/modules/core/src/drawing.cpp +++ b/modules/core/src/drawing.cpp @@ -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; diff --git a/modules/core/src/gl_core_3_1.cpp b/modules/core/src/gl_core_3_1.cpp index 61006f5ca..86744c50a 100644 --- a/modules/core/src/gl_core_3_1.cpp +++ b/modules/core/src/gl_core_3_1.cpp @@ -1,7 +1,7 @@ -#include #include #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; } diff --git a/modules/core/src/glob.cpp b/modules/core/src/glob.cpp index 4659c21d8..d31dccaf3 100644 --- a/modules/core/src/glob.cpp +++ b/modules/core/src/glob.cpp @@ -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& result, bool recursive) +static void glob_rec(const cv::String& directory, const cv::String& wildchart, std::vector& 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& result, bool recursive) +void cv::glob(String pattern, std::vector& 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& 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 = "."; diff --git a/modules/core/src/gpumat.cpp b/modules/core/src/gpumat.cpp index cc7442a66..e64e20030 100644 --- a/modules/core/src/gpumat.cpp +++ b/modules/core/src/gpumat.cpp @@ -172,7 +172,7 @@ namespace bool hasEqualOrGreaterBin(int major, int minor) const; private: - static void fromStr(const std::string& set_as_str, std::vector& arr); + static void fromStr(const String& set_as_str, std::vector& arr); std::vector bin; std::vector 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& arr) + void CudaArch::fromStr(const String& set_as_str, std::vector& 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); diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 1ee511910..bd3aab970 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -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(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 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); diff --git a/modules/core/src/stl.cpp b/modules/core/src/stl.cpp new file mode 100644 index 000000000..09ba66c21 --- /dev/null +++ b/modules/core/src/stl.cpp @@ -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); + } +} \ No newline at end of file diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 668b868b3..162605201 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -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()); diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp index 7d4e7d939..3c9b324f0 100644 --- a/modules/core/test/test_io.cpp +++ b/modules/core/test/test_io.cpp @@ -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 lenas, pngLenas; + std::vector lenas, pngLenas; cv::glob(patternLena, lenas, true); cv::glob(patternLenaPng, pngLenas, true); diff --git a/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst b/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst index 63e56f678..a1ac7b95e 100644 --- a/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst +++ b/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst @@ -33,7 +33,7 @@ Abstract base class for computing descriptors for image keypoints. :: virtual int descriptorSize() const = 0; virtual int descriptorType() const = 0; - static Ptr create( const string& descriptorExtractorType ); + static Ptr create( const String& descriptorExtractorType ); protected: ... @@ -70,7 +70,7 @@ DescriptorExtractor::create ------------------------------- Creates a descriptor extractor by name. -.. ocv:function:: Ptr DescriptorExtractor::create( const string& descriptorExtractorType ) +.. ocv:function:: Ptr DescriptorExtractor::create( const String& descriptorExtractorType ) :param descriptorExtractorType: Descriptor extractor type. diff --git a/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst b/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst index 8596ae43d..bdd834c5b 100644 --- a/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst +++ b/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst @@ -88,7 +88,7 @@ with an image set. :: virtual Ptr clone( bool emptyTrainData=false ) const = 0; - static Ptr create( const string& descriptorMatcherType ); + static Ptr create( const String& descriptorMatcherType ); protected: vector trainDescCollection; @@ -237,7 +237,7 @@ DescriptorMatcher::create ----------------------------- Creates a descriptor matcher of a given type with the default parameters (using default constructor). -.. ocv:function:: Ptr DescriptorMatcher::create( const string& descriptorMatcherType ) +.. ocv:function:: Ptr DescriptorMatcher::create( const String& descriptorMatcherType ) :param descriptorMatcherType: Descriptor matcher type. Now the following matcher types are supported: diff --git a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst index 81c72d3a8..fe52bbe28 100644 --- a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst +++ b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst @@ -88,7 +88,7 @@ Abstract base class for 2D image feature detectors. :: virtual void read(const FileNode&); virtual void write(FileStorage&) const; - static Ptr create( const string& detectorType ); + static Ptr create( const String& detectorType ); protected: ... @@ -116,7 +116,7 @@ FeatureDetector::create ----------------------- Creates a feature detector by its name. -.. ocv:function:: Ptr FeatureDetector::create( const string& detectorType ) +.. ocv:function:: Ptr FeatureDetector::create( const String& detectorType ) :param detectorType: Feature detector type. @@ -439,7 +439,7 @@ Class providing an interface for adjusting parameters of a feature detector. Thi virtual void tooMany(int max, int n_detected) = 0; virtual bool good() const = 0; virtual Ptr clone() const = 0; - static Ptr create( const string& detectorType ); + static Ptr create( const String& detectorType ); }; @@ -500,7 +500,7 @@ AdjusterAdapter::create ----------------------- Creates an adjuster adapter by name -.. ocv:function:: Ptr AdjusterAdapter::create( const string& detectorType ) +.. ocv:function:: Ptr AdjusterAdapter::create( const String& detectorType ) Creates an adjuster adapter by name ``detectorType``. The detector name is the same as in :ocv:func:`FeatureDetector::create`, but now supports ``"FAST"``, ``"STAR"``, and ``"SURF"`` only. diff --git a/modules/features2d/include/opencv2/features2d.hpp b/modules/features2d/include/opencv2/features2d.hpp index 8f32445ca..4184f5ea7 100644 --- a/modules/features2d/include/opencv2/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d.hpp @@ -109,7 +109,7 @@ public: }; //! writes vector of keypoints to the file storage -CV_EXPORTS void write(FileStorage& fs, const std::string& name, const std::vector& keypoints); +CV_EXPORTS void write(FileStorage& fs, const String& name, const std::vector& keypoints); //! reads vector of keypoints from the specified file storage node CV_EXPORTS void read(const FileNode& node, CV_OUT std::vector& keypoints); @@ -179,7 +179,7 @@ public: CV_WRAP virtual bool empty() const; // Create feature detector by detector name. - CV_WRAP static Ptr create( const std::string& detectorType ); + CV_WRAP static Ptr create( const String& detectorType ); protected: virtual void detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask=Mat() ) const = 0; @@ -229,7 +229,7 @@ public: CV_WRAP virtual bool empty() const; - CV_WRAP static Ptr create( const std::string& descriptorExtractorType ); + CV_WRAP static Ptr create( const String& descriptorExtractorType ); protected: virtual void computeImpl( const Mat& image, std::vector& keypoints, Mat& descriptors ) const = 0; @@ -264,7 +264,7 @@ public: bool useProvidedKeypoints=false ) const = 0; // Create feature detector and descriptor extractor by name. - CV_WRAP static Ptr create( const std::string& name ); + CV_WRAP static Ptr create( const String& name ); }; /*! @@ -765,7 +765,7 @@ public: virtual Ptr clone() const = 0; - static Ptr create( const std::string& detectorType ); + static Ptr create( const String& detectorType ); }; /** \brief an adaptively adjusting detector that iteratively detects until the desired number * of features are detected. @@ -1141,7 +1141,7 @@ public: // but with empty train data. virtual Ptr clone( bool emptyTrainData=false ) const = 0; - CV_WRAP static Ptr create( const std::string& descriptorMatcherType ); + CV_WRAP static Ptr create( const String& descriptorMatcherType ); protected: /* * Class to work with descriptors from several images as with one merged matrix. @@ -1367,8 +1367,8 @@ public: // but with empty train data. virtual Ptr clone( bool emptyTrainData=false ) const = 0; - static Ptr create( const std::string& genericDescritptorMatcherType, - const std::string ¶msFilename=std::string() ); + static Ptr create( const String& genericDescritptorMatcherType, + const String ¶msFilename=String() ); protected: // In fact the matching is implemented only by the following two methods. These methods suppose diff --git a/modules/features2d/src/descriptors.cpp b/modules/features2d/src/descriptors.cpp index 7f87bd5eb..b093d23f0 100644 --- a/modules/features2d/src/descriptors.cpp +++ b/modules/features2d/src/descriptors.cpp @@ -92,12 +92,12 @@ void DescriptorExtractor::removeBorderKeypoints( std::vector& keypoint KeyPointsFilter::runByImageBorder( keypoints, imageSize, borderSize ); } -Ptr DescriptorExtractor::create(const std::string& descriptorExtractorType) +Ptr DescriptorExtractor::create(const String& descriptorExtractorType) { if( descriptorExtractorType.find("Opponent") == 0 ) { - size_t pos = std::string("Opponent").size(); - std::string type = descriptorExtractorType.substr(pos); + size_t pos = String("Opponent").size(); + String type = descriptorExtractorType.substr(pos); return new OpponentColorDescriptorExtractor(DescriptorExtractor::create(type)); } diff --git a/modules/features2d/src/detectors.cpp b/modules/features2d/src/detectors.cpp index 19175f1b6..5fcf7c687 100644 --- a/modules/features2d/src/detectors.cpp +++ b/modules/features2d/src/detectors.cpp @@ -86,7 +86,7 @@ void FeatureDetector::removeInvalidPoints( const Mat& mask, std::vector FeatureDetector::create( const std::string& detectorType ) +Ptr FeatureDetector::create( const String& detectorType ) { if( detectorType.find("Grid") == 0 ) { diff --git a/modules/features2d/src/dynamic.cpp b/modules/features2d/src/dynamic.cpp index 523a3e1f8..d08434da4 100644 --- a/modules/features2d/src/dynamic.cpp +++ b/modules/features2d/src/dynamic.cpp @@ -199,7 +199,7 @@ Ptr SurfAdjuster::clone() const return cloned_obj; } -Ptr AdjusterAdapter::create( const std::string& detectorType ) +Ptr AdjusterAdapter::create( const String& detectorType ) { Ptr adapter; diff --git a/modules/features2d/src/features2d_init.cpp b/modules/features2d/src/features2d_init.cpp index 85640585f..780a67b87 100644 --- a/modules/features2d/src/features2d_init.cpp +++ b/modules/features2d/src/features2d_init.cpp @@ -44,7 +44,7 @@ using namespace cv; -Ptr Feature2D::create( const std::string& feature2DType ) +Ptr Feature2D::create( const String& feature2DType ) { return Algorithm::create("Feature2D." + feature2DType); } diff --git a/modules/features2d/src/keypoint.cpp b/modules/features2d/src/keypoint.cpp index a4b960d1b..cec6fca30 100644 --- a/modules/features2d/src/keypoint.cpp +++ b/modules/features2d/src/keypoint.cpp @@ -58,7 +58,7 @@ size_t KeyPoint::hash() const return _Val; } -void write(FileStorage& fs, const std::string& objname, const std::vector& keypoints) +void write(FileStorage& fs, const String& objname, const std::vector& keypoints) { WriteStructContext ws(fs, objname, CV_NODE_SEQ + CV_NODE_FLOW); diff --git a/modules/features2d/src/matchers.cpp b/modules/features2d/src/matchers.cpp index 658c902f9..e0e5f4018 100644 --- a/modules/features2d/src/matchers.cpp +++ b/modules/features2d/src/matchers.cpp @@ -456,7 +456,7 @@ void BFMatcher::radiusMatchImpl( const Mat& queryDescriptors, std::vector DescriptorMatcher::create( const std::string& descriptorMatcherType ) +Ptr DescriptorMatcher::create( const String& descriptorMatcherType ) { DescriptorMatcher* dm = 0; if( !descriptorMatcherType.compare( "FlannBased" ) ) @@ -540,7 +540,7 @@ void FlannBasedMatcher::read( const FileNode& fn) for(int i = 0; i < (int)ip.size(); ++i) { CV_Assert(ip[i].type() == FileNode::MAP); - std::string _name = (std::string)ip[i]["name"]; + String _name = (String)ip[i]["name"]; int type = (int)ip[i]["type"]; switch(type) @@ -559,7 +559,7 @@ void FlannBasedMatcher::read( const FileNode& fn) indexParams->setDouble(_name, (double) ip[i]["value"]); break; case CV_USRTYPE1: - indexParams->setString(_name, (std::string) ip[i]["value"]); + indexParams->setString(_name, (String) ip[i]["value"]); break; case CV_MAKETYPE(CV_USRTYPE1,2): indexParams->setBool(_name, (int) ip[i]["value"] != 0); @@ -579,7 +579,7 @@ void FlannBasedMatcher::read( const FileNode& fn) for(int i = 0; i < (int)sp.size(); ++i) { CV_Assert(sp[i].type() == FileNode::MAP); - std::string _name = (std::string)sp[i]["name"]; + String _name = (String)sp[i]["name"]; int type = (int)sp[i]["type"]; switch(type) @@ -598,7 +598,7 @@ void FlannBasedMatcher::read( const FileNode& fn) searchParams->setDouble(_name, (double) ip[i]["value"]); break; case CV_USRTYPE1: - searchParams->setString(_name, (std::string) ip[i]["value"]); + searchParams->setString(_name, (String) ip[i]["value"]); break; case CV_MAKETYPE(CV_USRTYPE1,2): searchParams->setBool(_name, (int) ip[i]["value"] != 0); @@ -618,9 +618,9 @@ void FlannBasedMatcher::write( FileStorage& fs) const if (indexParams) { - std::vector names; + std::vector names; std::vector types; - std::vector strValues; + std::vector strValues; std::vector numValues; indexParams->getAll(names, types, strValues, numValues); @@ -669,9 +669,9 @@ void FlannBasedMatcher::write( FileStorage& fs) const if (searchParams) { - std::vector names; + std::vector names; std::vector types; - std::vector strValues; + std::vector strValues; std::vector numValues; searchParams->getAll(names, types, strValues, numValues); @@ -1060,8 +1060,8 @@ bool GenericDescriptorMatcher::empty() const /* * Factory function for GenericDescriptorMatch creating */ -Ptr GenericDescriptorMatcher::create( const std::string& genericDescritptorMatcherType, - const std::string ¶msFilename ) +Ptr GenericDescriptorMatcher::create( const String& genericDescritptorMatcherType, + const String ¶msFilename ) { Ptr descriptorMatcher = Algorithm::create("DescriptorMatcher." + genericDescritptorMatcherType); diff --git a/modules/flann/doc/flann_fast_approximate_nearest_neighbor_search.rst b/modules/flann/doc/flann_fast_approximate_nearest_neighbor_search.rst index 07b0b2a46..e058e8886 100644 --- a/modules/flann/doc/flann_fast_approximate_nearest_neighbor_search.rst +++ b/modules/flann/doc/flann_fast_approximate_nearest_neighbor_search.rst @@ -138,7 +138,7 @@ The method constructs a fast search structure from a set of features using the s struct SavedIndexParams : public IndexParams { - SavedIndexParams( std::string filename ); + SavedIndexParams( String filename ); }; @@ -199,7 +199,7 @@ flann::Index_::save ------------------------------ Saves the index to a file. -.. ocv:function:: void flann::Index_::save(std::string filename) +.. ocv:function:: void flann::Index_::save(String filename) :param filename: The file to save the index to diff --git a/modules/flann/include/opencv2/flann.hpp b/modules/flann/include/opencv2/flann.hpp index d5eedcc0f..1bc7a3c97 100644 --- a/modules/flann/include/opencv2/flann.hpp +++ b/modules/flann/include/opencv2/flann.hpp @@ -112,7 +112,7 @@ public: int radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& params); - void save(std::string filename) { nnIndex->save(filename); } + void save(String filename) { nnIndex->save(filename); } int veclen() const { return nnIndex->veclen(); } @@ -244,7 +244,7 @@ public: int radiusSearch(const std::vector& query, std::vector& indices, std::vector& dists, DistanceType radius, const ::cvflann::SearchParams& params); int radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& params); - void save(std::string filename) + void save(String filename) { if (nnIndex_L1) nnIndex_L1->save(filename); if (nnIndex_L2) nnIndex_L2->save(filename); diff --git a/modules/flann/include/opencv2/flann/any.h b/modules/flann/include/opencv2/flann/any.h index dc0b9481a..4042db67c 100644 --- a/modules/flann/include/opencv2/flann/any.h +++ b/modules/flann/include/opencv2/flann/any.h @@ -106,6 +106,11 @@ template<> inline void big_any_policy::print(std::ostream& ou out << int(*reinterpret_cast(*src)); } +template<> inline void big_any_policy::print(std::ostream& out, void* const* src) +{ + out << (*reinterpret_cast(*src)).c_str(); +} + template struct choose_policy { diff --git a/modules/flann/include/opencv2/flann/flann_base.hpp b/modules/flann/include/opencv2/flann/flann_base.hpp index b5ba7d79e..98c33cf6c 100644 --- a/modules/flann/include/opencv2/flann/flann_base.hpp +++ b/modules/flann/include/opencv2/flann/flann_base.hpp @@ -32,7 +32,6 @@ #define OPENCV_FLANN_BASE_HPP_ #include -#include #include #include @@ -62,7 +61,7 @@ inline void log_verbosity(int level) */ struct SavedIndexParams : public IndexParams { - SavedIndexParams(std::string filename) + SavedIndexParams(cv::String filename) { (* this)["algorithm"] = FLANN_INDEX_SAVED; (*this)["filename"] = filename; @@ -71,7 +70,7 @@ struct SavedIndexParams : public IndexParams template -NNIndex* load_saved_index(const Matrix& dataset, const std::string& filename, Distance distance) +NNIndex* load_saved_index(const Matrix& dataset, const cv::String& filename, Distance distance) { typedef typename Distance::ElementType ElementType; @@ -111,7 +110,7 @@ public: loaded_ = false; if (index_type == FLANN_INDEX_SAVED) { - nnIndex_ = load_saved_index(features, get_param(params,"filename"), distance); + nnIndex_ = load_saved_index(features, get_param(params,"filename"), distance); loaded_ = true; } else { @@ -134,7 +133,7 @@ public: } } - void save(std::string filename) + void save(cv::String filename) { FILE* fout = fopen(filename.c_str(), "wb"); if (fout == NULL) { diff --git a/modules/flann/include/opencv2/flann/general.h b/modules/flann/include/opencv2/flann/general.h index 87e7e2f28..9d5402a6f 100644 --- a/modules/flann/include/opencv2/flann/general.h +++ b/modules/flann/include/opencv2/flann/general.h @@ -31,19 +31,17 @@ #ifndef OPENCV_FLANN_GENERAL_H_ #define OPENCV_FLANN_GENERAL_H_ -#include "defines.h" -#include -#include +#include "opencv2/core.hpp" namespace cvflann { -class FLANNException : public std::runtime_error +class FLANNException : public cv::Exception { public: - FLANNException(const char* message) : std::runtime_error(message) { } + FLANNException(const char* message) : cv::Exception(0, message, "", __FILE__, __LINE__) { } - FLANNException(const std::string& message) : std::runtime_error(message) { } + FLANNException(const cv::String& message) : cv::Exception(0, message, "", __FILE__, __LINE__) { } }; } diff --git a/modules/flann/include/opencv2/flann/hdf5.h b/modules/flann/include/opencv2/flann/hdf5.h index ef3e99973..80d23b977 100644 --- a/modules/flann/include/opencv2/flann/hdf5.h +++ b/modules/flann/include/opencv2/flann/hdf5.h @@ -73,7 +73,7 @@ hid_t get_hdf5_type() { return H5T_NATIVE_DOUBLE; } #define CHECK_ERROR(x,y) if ((x)<0) throw FLANNException((y)); template -void save_to_file(const cvflann::Matrix& dataset, const std::string& filename, const std::string& name) +void save_to_file(const cvflann::Matrix& dataset, const String& filename, const String& name) { #if H5Eset_auto_vers == 2 @@ -125,7 +125,7 @@ void save_to_file(const cvflann::Matrix& dataset, const std::string& filename template -void load_from_file(cvflann::Matrix& dataset, const std::string& filename, const std::string& name) +void load_from_file(cvflann::Matrix& dataset, const String& filename, const String& name) { herr_t status; hid_t file_id = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT); @@ -166,7 +166,7 @@ namespace mpi * @param name Name of dataset inside file */ template -void load_from_file(cvflann::Matrix& dataset, const std::string& filename, const std::string& name) +void load_from_file(cvflann::Matrix& dataset, const String& filename, const String& name) { MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; diff --git a/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h b/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h index ce2d62245..b8b16941f 100644 --- a/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h +++ b/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h @@ -32,7 +32,6 @@ #define OPENCV_FLANN_HIERARCHICAL_CLUSTERING_INDEX_H_ #include -#include #include #include #include diff --git a/modules/flann/include/opencv2/flann/kmeans_index.h b/modules/flann/include/opencv2/flann/kmeans_index.h index 3fea956a7..c3b1fd5b8 100644 --- a/modules/flann/include/opencv2/flann/kmeans_index.h +++ b/modules/flann/include/opencv2/flann/kmeans_index.h @@ -32,7 +32,6 @@ #define OPENCV_FLANN_KMEANS_INDEX_H_ #include -#include #include #include #include diff --git a/modules/flann/include/opencv2/flann/lsh_table.h b/modules/flann/include/opencv2/flann/lsh_table.h index a30642a48..7f857ff3d 100644 --- a/modules/flann/include/opencv2/flann/lsh_table.h +++ b/modules/flann/include/opencv2/flann/lsh_table.h @@ -266,9 +266,7 @@ private: const size_t key_size_upper_bound = std::min(sizeof(BucketKey) * CHAR_BIT + 1, sizeof(size_t) * CHAR_BIT); if (key_size < key_size_lower_bound || key_size >= key_size_upper_bound) { - std::stringstream errorMessage; - errorMessage << "Invalid key_size (=" << key_size << "). Valid values for your system are " << key_size_lower_bound << " <= key_size < " << key_size_upper_bound << "."; - CV_Error(CV_StsBadArg, errorMessage.str()); + CV_Error(CV_StsBadArg, cv::format("Invalid key_size (=%d). Valid values for your system are %d <= key_size < %d.", (int)key_size, (int)key_size_lower_bound, (int)key_size_upper_bound)); } speed_level_ = kHash; diff --git a/modules/flann/include/opencv2/flann/miniflann.hpp b/modules/flann/include/opencv2/flann/miniflann.hpp index 475335ca3..d35f96136 100644 --- a/modules/flann/include/opencv2/flann/miniflann.hpp +++ b/modules/flann/include/opencv2/flann/miniflann.hpp @@ -59,20 +59,20 @@ struct CV_EXPORTS IndexParams IndexParams(); ~IndexParams(); - std::string getString(const std::string& key, const std::string& defaultVal=std::string()) const; - int getInt(const std::string& key, int defaultVal=-1) const; - double getDouble(const std::string& key, double defaultVal=-1) const; + String getString(const String& key, const String& defaultVal=String()) const; + int getInt(const String& key, int defaultVal=-1) const; + double getDouble(const String& key, double defaultVal=-1) const; - void setString(const std::string& key, const std::string& value); - void setInt(const std::string& key, int value); - void setDouble(const std::string& key, double value); - void setFloat(const std::string& key, float value); - void setBool(const std::string& key, bool value); + void setString(const String& key, const String& value); + void setInt(const String& key, int value); + void setDouble(const String& key, double value); + void setFloat(const String& key, float value); + void setBool(const String& key, bool value); void setAlgorithm(int value); - void getAll(std::vector& names, + void getAll(std::vector& names, std::vector& types, - std::vector& strValues, + std::vector& strValues, std::vector& numValues) const; void* params; @@ -119,7 +119,7 @@ struct CV_EXPORTS LshIndexParams : public IndexParams struct CV_EXPORTS SavedIndexParams : public IndexParams { - SavedIndexParams(const std::string& filename); + SavedIndexParams(const String& filename); }; struct CV_EXPORTS SearchParams : public IndexParams @@ -142,8 +142,8 @@ public: OutputArray dists, double radius, int maxResults, const SearchParams& params=SearchParams()); - CV_WRAP virtual void save(const std::string& filename) const; - CV_WRAP virtual bool load(InputArray features, const std::string& filename); + CV_WRAP virtual void save(const String& filename) const; + CV_WRAP virtual bool load(InputArray features, const String& filename); CV_WRAP virtual void release(); CV_WRAP cvflann::flann_distance_t getDistance() const; CV_WRAP cvflann::flann_algorithm_t getAlgorithm() const; diff --git a/modules/flann/include/opencv2/flann/nn_index.h b/modules/flann/include/opencv2/flann/nn_index.h index d14e83a92..381d4bc3c 100644 --- a/modules/flann/include/opencv2/flann/nn_index.h +++ b/modules/flann/include/opencv2/flann/nn_index.h @@ -31,8 +31,6 @@ #ifndef OPENCV_FLANN_NNINDEX_H #define OPENCV_FLANN_NNINDEX_H -#include - #include "general.h" #include "matrix.h" #include "result_set.h" diff --git a/modules/flann/include/opencv2/flann/params.h b/modules/flann/include/opencv2/flann/params.h index fc2a90619..2f1d5e7ca 100644 --- a/modules/flann/include/opencv2/flann/params.h +++ b/modules/flann/include/opencv2/flann/params.h @@ -39,7 +39,7 @@ namespace cvflann { -typedef std::map IndexParams; +typedef std::map IndexParams; struct SearchParams : public IndexParams { @@ -56,7 +56,7 @@ struct SearchParams : public IndexParams template -T get_param(const IndexParams& params, std::string name, const T& default_value) +T get_param(const IndexParams& params, cv::String name, const T& default_value) { IndexParams::const_iterator it = params.find(name); if (it != params.end()) { @@ -68,14 +68,14 @@ T get_param(const IndexParams& params, std::string name, const T& default_value) } template -T get_param(const IndexParams& params, std::string name) +T get_param(const IndexParams& params, cv::String name) { IndexParams::const_iterator it = params.find(name); if (it != params.end()) { return it->second.cast(); } else { - throw FLANNException(std::string("Missing parameter '")+name+std::string("' in the parameters given")); + throw FLANNException(cv::String("Missing parameter '")+name+cv::String("' in the parameters given")); } } diff --git a/modules/flann/src/miniflann.cpp b/modules/flann/src/miniflann.cpp index a7e476fde..c15a5ab38 100644 --- a/modules/flann/src/miniflann.cpp +++ b/modules/flann/src/miniflann.cpp @@ -26,7 +26,7 @@ IndexParams::IndexParams() } template -T getParam(const IndexParams& _p, const std::string& key, const T& defaultVal=T()) +T getParam(const IndexParams& _p, const String& key, const T& defaultVal=T()) { ::cvflann::IndexParams& p = get_params(_p); ::cvflann::IndexParams::const_iterator it = p.find(key); @@ -36,49 +36,49 @@ T getParam(const IndexParams& _p, const std::string& key, const T& defaultVal=T( } template -void setParam(IndexParams& _p, const std::string& key, const T& value) +void setParam(IndexParams& _p, const String& key, const T& value) { ::cvflann::IndexParams& p = get_params(_p); p[key] = value; } -std::string IndexParams::getString(const std::string& key, const std::string& defaultVal) const +String IndexParams::getString(const String& key, const String& defaultVal) const { return getParam(*this, key, defaultVal); } -int IndexParams::getInt(const std::string& key, int defaultVal) const +int IndexParams::getInt(const String& key, int defaultVal) const { return getParam(*this, key, defaultVal); } -double IndexParams::getDouble(const std::string& key, double defaultVal) const +double IndexParams::getDouble(const String& key, double defaultVal) const { return getParam(*this, key, defaultVal); } -void IndexParams::setString(const std::string& key, const std::string& value) +void IndexParams::setString(const String& key, const String& value) { setParam(*this, key, value); } -void IndexParams::setInt(const std::string& key, int value) +void IndexParams::setInt(const String& key, int value) { setParam(*this, key, value); } -void IndexParams::setDouble(const std::string& key, double value) +void IndexParams::setDouble(const String& key, double value) { setParam(*this, key, value); } -void IndexParams::setFloat(const std::string& key, float value) +void IndexParams::setFloat(const String& key, float value) { setParam(*this, key, value); } -void IndexParams::setBool(const std::string& key, bool value) +void IndexParams::setBool(const String& key, bool value) { setParam(*this, key, value); } @@ -88,9 +88,9 @@ void IndexParams::setAlgorithm(int value) setParam(*this, "algorithm", (cvflann::flann_algorithm_t)value); } -void IndexParams::getAll(std::vector& names, +void IndexParams::getAll(std::vector& names, std::vector& types, - std::vector& strValues, + std::vector& strValues, std::vector& numValues) const { names.clear(); @@ -106,7 +106,7 @@ void IndexParams::getAll(std::vector& names, names.push_back(it->first); try { - std::string val = it->second.cast(); + String val = it->second.cast(); types.push_back(CV_USRTYPE1); strValues.push_back(val); numValues.push_back(-1); @@ -285,9 +285,9 @@ LshIndexParams::LshIndexParams(int table_number, int key_size, int multi_probe_l p["multi_probe_level"] = multi_probe_level; } -SavedIndexParams::SavedIndexParams(const std::string& _filename) +SavedIndexParams::SavedIndexParams(const String& _filename) { - std::string filename = _filename; + String filename = _filename; ::cvflann::IndexParams& p = get_params(*this); p["algorithm"] = FLANN_INDEX_SAVED; @@ -357,7 +357,7 @@ void Index::build(InputArray _data, const IndexParams& params, flann_distance_t algo = getParam(params, "algorithm", FLANN_INDEX_LINEAR); if( algo == FLANN_INDEX_SAVED ) { - load(_data, getParam(params, "filename", std::string())); + load(_data, getParam(params, "filename", String())); return; } @@ -654,7 +654,7 @@ template void saveIndex(const Index* index0, const void* inde saveIndex_< ::cvflann::Index >(index0, index, fout); } -void Index::save(const std::string& filename) const +void Index::save(const String& filename) const { FILE* fout = fopen(filename.c_str(), "wb"); if (fout == NULL) @@ -720,7 +720,7 @@ bool loadIndex(Index* index0, void*& index, const Mat& data, FILE* fin, const Di return loadIndex_ >(index0, index, data, fin, dist); } -bool Index::load(InputArray _data, const std::string& filename) +bool Index::load(InputArray _data, const String& filename) { Mat data = _data.getMat(); bool ok = true; diff --git a/modules/gpu/doc/initalization_and_information.rst b/modules/gpu/doc/initalization_and_information.rst index fc7236dcf..ed34541bf 100644 --- a/modules/gpu/doc/initalization_and_information.rst +++ b/modules/gpu/doc/initalization_and_information.rst @@ -110,7 +110,7 @@ Class providing functionality for querying the specified GPU properties. :: DeviceInfo(); DeviceInfo(int device_id); - string name() const; + String name() const; int majorVersion() const; int minorVersion() const; @@ -146,7 +146,7 @@ gpu::DeviceInfo::name --------------------- Returns the device name. -.. ocv:function:: string gpu::DeviceInfo::name() const +.. ocv:function:: String gpu::DeviceInfo::name() const diff --git a/modules/gpu/doc/object_detection.rst b/modules/gpu/doc/object_detection.rst index fd0ac867e..010124410 100644 --- a/modules/gpu/doc/object_detection.rst +++ b/modules/gpu/doc/object_detection.rst @@ -209,11 +209,11 @@ Cascade classifier class used for object detection. Supports HAAR and LBP cascad { public: CascadeClassifier_GPU(); - CascadeClassifier_GPU(const string& filename); + CascadeClassifier_GPU(const String& filename); ~CascadeClassifier_GPU(); bool empty() const; - bool load(const string& filename); + bool load(const String& filename); void release(); /* Returns number of detected objects */ @@ -235,7 +235,7 @@ gpu::CascadeClassifier_GPU::CascadeClassifier_GPU ----------------------------------------------------- Loads the classifier from a file. Cascade type is detected automatically by constructor parameter. -.. ocv:function:: gpu::CascadeClassifier_GPU::CascadeClassifier_GPU(const string& filename) +.. ocv:function:: gpu::CascadeClassifier_GPU::CascadeClassifier_GPU(const String& filename) :param filename: Name of the file from which the classifier is loaded. Only the old ``haar`` classifier (trained by the ``haar`` training application) and NVIDIA's ``nvbin`` are supported for HAAR and only new type of OpenCV XML cascade supported for LBP. @@ -253,7 +253,7 @@ gpu::CascadeClassifier_GPU::load ------------------------------------ Loads the classifier from a file. The previous content is destroyed. -.. ocv:function:: bool gpu::CascadeClassifier_GPU::load(const string& filename) +.. ocv:function:: bool gpu::CascadeClassifier_GPU::load(const String& filename) :param filename: Name of the file from which the classifier is loaded. Only the old ``haar`` classifier (trained by the ``haar`` training application) and NVIDIA's ``nvbin`` are supported for HAAR and only new type of OpenCV XML cascade supported for LBP. diff --git a/modules/gpu/doc/video.rst b/modules/gpu/doc/video.rst index 284bb17fa..f96410037 100644 --- a/modules/gpu/doc/video.rst +++ b/modules/gpu/doc/video.rst @@ -704,8 +704,8 @@ gpu::VideoWriter_GPU::VideoWriter_GPU Constructors. .. ocv:function:: gpu::VideoWriter_GPU::VideoWriter_GPU() -.. ocv:function:: gpu::VideoWriter_GPU::VideoWriter_GPU(const std::string& fileName, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR) -.. ocv:function:: gpu::VideoWriter_GPU::VideoWriter_GPU(const std::string& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR) +.. ocv:function:: gpu::VideoWriter_GPU::VideoWriter_GPU(const String& fileName, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR) +.. ocv:function:: gpu::VideoWriter_GPU::VideoWriter_GPU(const String& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR) .. ocv:function:: gpu::VideoWriter_GPU::VideoWriter_GPU(const cv::Ptr& encoderCallback, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR) .. ocv:function:: gpu::VideoWriter_GPU::VideoWriter_GPU(const cv::Ptr& encoderCallback, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR) @@ -729,8 +729,8 @@ gpu::VideoWriter_GPU::open -------------------------- Initializes or reinitializes video writer. -.. ocv:function:: void gpu::VideoWriter_GPU::open(const std::string& fileName, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR) -.. ocv:function:: void gpu::VideoWriter_GPU::open(const std::string& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR) +.. ocv:function:: void gpu::VideoWriter_GPU::open(const String& fileName, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR) +.. ocv:function:: void gpu::VideoWriter_GPU::open(const String& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR) .. ocv:function:: void gpu::VideoWriter_GPU::open(const cv::Ptr& encoderCallback, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR) .. ocv:function:: void gpu::VideoWriter_GPU::open(const cv::Ptr& encoderCallback, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR) @@ -797,10 +797,10 @@ Different parameters for CUDA video encoder. :: int DisableSPSPPS; // NVVE_DISABLE_SPS_PPS EncoderParams(); - explicit EncoderParams(const std::string& configFile); + explicit EncoderParams(const String& configFile); - void load(const std::string& configFile); - void save(const std::string& configFile) const; + void load(const String& configFile); + void save(const String& configFile) const; }; @@ -810,7 +810,7 @@ gpu::VideoWriter_GPU::EncoderParams::EncoderParams Constructors. .. ocv:function:: gpu::VideoWriter_GPU::EncoderParams::EncoderParams() -.. ocv:function:: gpu::VideoWriter_GPU::EncoderParams::EncoderParams(const std::string& configFile) +.. ocv:function:: gpu::VideoWriter_GPU::EncoderParams::EncoderParams(const String& configFile) :param configFile: Config file name. @@ -822,7 +822,7 @@ gpu::VideoWriter_GPU::EncoderParams::load ----------------------------------------- Reads parameters from config file. -.. ocv:function:: void gpu::VideoWriter_GPU::EncoderParams::load(const std::string& configFile) +.. ocv:function:: void gpu::VideoWriter_GPU::EncoderParams::load(const String& configFile) :param configFile: Config file name. @@ -832,7 +832,7 @@ gpu::VideoWriter_GPU::EncoderParams::save ----------------------------------------- Saves parameters to config file. -.. ocv:function:: void gpu::VideoWriter_GPU::EncoderParams::save(const std::string& configFile) const +.. ocv:function:: void gpu::VideoWriter_GPU::EncoderParams::save(const String& configFile) const :param configFile: Config file name. @@ -982,7 +982,7 @@ gpu::VideoReader_GPU::VideoReader_GPU Constructors. .. ocv:function:: gpu::VideoReader_GPU::VideoReader_GPU() -.. ocv:function:: gpu::VideoReader_GPU::VideoReader_GPU(const std::string& filename) +.. ocv:function:: gpu::VideoReader_GPU::VideoReader_GPU(const String& filename) .. ocv:function:: gpu::VideoReader_GPU::VideoReader_GPU(const cv::Ptr& source) :param filename: Name of the input video file. @@ -997,7 +997,7 @@ gpu::VideoReader_GPU::open -------------------------- Initializes or reinitializes video reader. -.. ocv:function:: void gpu::VideoReader_GPU::open(const std::string& filename) +.. ocv:function:: void gpu::VideoReader_GPU::open(const String& filename) .. ocv:function:: void gpu::VideoReader_GPU::open(const cv::Ptr& source) The method opens video reader. Parameters are the same as in the constructor :ocv:func:`gpu::VideoReader_GPU::VideoReader_GPU` . The method throws :ocv:class:`Exception` if error occurs. diff --git a/modules/gpu/include/opencv2/gpu.hpp b/modules/gpu/include/opencv2/gpu.hpp index e0933342b..51e1c5f8d 100644 --- a/modules/gpu/include/opencv2/gpu.hpp +++ b/modules/gpu/include/opencv2/gpu.hpp @@ -1384,11 +1384,11 @@ class CV_EXPORTS CascadeClassifier_GPU { public: CascadeClassifier_GPU(); - CascadeClassifier_GPU(const std::string& filename); + CascadeClassifier_GPU(const String& filename); ~CascadeClassifier_GPU(); bool empty() const; - bool load(const std::string& filename); + bool load(const String& filename); void release(); /* returns number of detected objects */ @@ -2170,15 +2170,15 @@ public: }; VideoWriter_GPU(); - VideoWriter_GPU(const std::string& fileName, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR); - VideoWriter_GPU(const std::string& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR); + VideoWriter_GPU(const String& fileName, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR); + VideoWriter_GPU(const String& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR); VideoWriter_GPU(const cv::Ptr& encoderCallback, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR); VideoWriter_GPU(const cv::Ptr& encoderCallback, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR); ~VideoWriter_GPU(); // all methods throws cv::Exception if error occurs - void open(const std::string& fileName, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR); - void open(const std::string& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR); + void open(const String& fileName, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR); + void open(const String& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR); void open(const cv::Ptr& encoderCallback, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR); void open(const cv::Ptr& encoderCallback, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR); @@ -2210,10 +2210,10 @@ public: int DisableSPSPPS; // NVVE_DISABLE_SPS_PPS EncoderParams(); - explicit EncoderParams(const std::string& configFile); + explicit EncoderParams(const String& configFile); - void load(const std::string& configFile); - void save(const std::string& configFile) const; + void load(const String& configFile); + void save(const String& configFile) const; }; EncoderParams getParams() const; @@ -2301,12 +2301,12 @@ public: class VideoSource; VideoReader_GPU(); - explicit VideoReader_GPU(const std::string& filename); + explicit VideoReader_GPU(const String& filename); explicit VideoReader_GPU(const cv::Ptr& source); ~VideoReader_GPU(); - void open(const std::string& filename); + void open(const String& filename); void open(const cv::Ptr& source); bool isOpened() const; diff --git a/modules/gpu/src/cascadeclassifier.cpp b/modules/gpu/src/cascadeclassifier.cpp index e82ee9d33..ca9f2570e 100644 --- a/modules/gpu/src/cascadeclassifier.cpp +++ b/modules/gpu/src/cascadeclassifier.cpp @@ -50,10 +50,10 @@ using namespace cv::gpu; #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU() { throw_nogpu(); } -cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU(const std::string&) { throw_nogpu(); } +cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU(const String&) { throw_nogpu(); } cv::gpu::CascadeClassifier_GPU::~CascadeClassifier_GPU() { throw_nogpu(); } bool cv::gpu::CascadeClassifier_GPU::empty() const { throw_nogpu(); return true; } -bool cv::gpu::CascadeClassifier_GPU::load(const std::string&) { throw_nogpu(); return true; } +bool cv::gpu::CascadeClassifier_GPU::load(const String&) { throw_nogpu(); return true; } Size cv::gpu::CascadeClassifier_GPU::getClassifierSize() const { throw_nogpu(); return Size();} void cv::gpu::CascadeClassifier_GPU::release() { throw_nogpu(); } int cv::gpu::CascadeClassifier_GPU::detectMultiScale( const GpuMat&, GpuMat&, double, int, Size) {throw_nogpu(); return -1;} @@ -71,7 +71,7 @@ public: bool findLargestObject, bool visualizeInPlace, cv::Size ncvMinSize, cv::Size maxObjectSize) = 0; virtual cv::Size getClassifierCvSize() const = 0; - virtual bool read(const std::string& classifierAsXml) = 0; + virtual bool read(const String& classifierAsXml) = 0; }; struct cv::gpu::CascadeClassifier_GPU::HaarCascade : cv::gpu::CascadeClassifier_GPU::CascadeClassifierImpl @@ -82,7 +82,7 @@ public: ncvSetDebugOutputHandler(NCVDebugOutputHandler); } - bool read(const std::string& filename) + bool read(const String& filename) { ncvSafeCall( load(filename) ); return true; @@ -169,9 +169,9 @@ public: cv::Size getClassifierCvSize() const { return cv::Size(haar.ClassifierSize.width, haar.ClassifierSize.height); } private: - static void NCVDebugOutputHandler(const std::string &msg) { CV_Error(CV_GpuApiCallError, msg.c_str()); } + static void NCVDebugOutputHandler(const String &msg) { CV_Error(CV_GpuApiCallError, msg.c_str()); } - NCVStatus load(const std::string& classifierFile) + NCVStatus load(const String& classifierFile) { int devId = cv::gpu::getDevice(); ncvAssertCUDAReturn(cudaGetDeviceProperties(&devProp, devId), NCV_CUDA_ERROR); @@ -458,7 +458,7 @@ public: virtual cv::Size getClassifierCvSize() const { return NxM; } - bool read(const std::string& classifierAsXml) + bool read(const String& classifierAsXml) { FileStorage fs(classifierAsXml, FileStorage::READ); return fs.isOpened() ? read(fs.getFirstTopLevelNode()) : false; @@ -512,10 +512,10 @@ private: const char *GPU_CC_FEATURES = "features"; const char *GPU_CC_RECT = "rect"; - std::string stageTypeStr = (std::string)root[GPU_CC_STAGE_TYPE]; + String stageTypeStr = (String)root[GPU_CC_STAGE_TYPE]; CV_Assert(stageTypeStr == GPU_CC_BOOST); - std::string featureTypeStr = (std::string)root[GPU_CC_FEATURE_TYPE]; + String featureTypeStr = (String)root[GPU_CC_FEATURE_TYPE]; CV_Assert(featureTypeStr == GPU_CC_LBP); NxM.width = (int)root[GPU_CC_WIDTH]; @@ -662,7 +662,7 @@ private: cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU() : findLargestObject(false), visualizeInPlace(false), impl(0) {} -cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU(const std::string& filename) +cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU(const String& filename) : findLargestObject(false), visualizeInPlace(false), impl(0) { load(filename); } cv::gpu::CascadeClassifier_GPU::~CascadeClassifier_GPU() { release(); } @@ -688,11 +688,11 @@ int cv::gpu::CascadeClassifier_GPU::detectMultiScale(const GpuMat& image, GpuMat return impl->process(image, objectsBuf, (float)scaleFactor, minNeighbors, findLargestObject, visualizeInPlace, minSize, maxObjectSize); } -bool cv::gpu::CascadeClassifier_GPU::load(const std::string& filename) +bool cv::gpu::CascadeClassifier_GPU::load(const String& filename) { release(); - std::string fext = filename.substr(filename.find_last_of(".") + 1); + String fext = filename.substr(filename.find_last_of(".") + 1); std::transform(fext.begin(), fext.end(), fext.begin(), ::tolower); if (fext == "nvbin") @@ -710,7 +710,7 @@ bool cv::gpu::CascadeClassifier_GPU::load(const std::string& filename) } const char *GPU_CC_LBP = "LBP"; - std::string featureTypeStr = (std::string)fs.getFirstTopLevelNode()["featureType"]; + String featureTypeStr = (String)fs.getFirstTopLevelNode()["featureType"]; if (featureTypeStr == GPU_CC_LBP) impl = new LbpCascade(); else @@ -759,7 +759,7 @@ void groupRectangles(std::vector &hypotheses, int groupThreshold, do hypotheses.resize(rects.size()); } -NCVStatus loadFromXML(const std::string &filename, +NCVStatus loadFromXML(const String &filename, HaarClassifierCascadeDescriptor &haar, std::vector &haarStages, std::vector &haarClassifierNodes, diff --git a/modules/gpu/src/cu_safe_call.cpp b/modules/gpu/src/cu_safe_call.cpp index 7218873df..00880d85b 100644 --- a/modules/gpu/src/cu_safe_call.cpp +++ b/modules/gpu/src/cu_safe_call.cpp @@ -51,7 +51,7 @@ namespace struct ErrorEntry { int code; - std::string str; + String str; }; class ErrorEntryComparer @@ -65,11 +65,11 @@ namespace int code_; }; - std::string getErrorString(int code, const ErrorEntry* errors, size_t n) + String getErrorString(int code, const ErrorEntry* errors, size_t n) { size_t idx = std::find_if(errors, errors + n, ErrorEntryComparer(code)) - errors; - const std::string& msg = (idx != n) ? errors[idx].str : std::string("Unknown error code"); + const String& msg = (idx != n) ? errors[idx].str : String("Unknown error code"); std::ostringstream ostr; ostr << msg << " [Code = " << code << "]"; @@ -131,7 +131,7 @@ namespace const size_t cu_errors_num = sizeof(cu_errors) / sizeof(cu_errors[0]); } -std::string cv::gpu::detail::cuGetErrString(CUresult res) +String cv::gpu::detail::cuGetErrString(CUresult res) { return getErrorString(res, cu_errors, cu_errors_num); } diff --git a/modules/gpu/src/cu_safe_call.h b/modules/gpu/src/cu_safe_call.h index 6f93adc76..c52e81dea 100644 --- a/modules/gpu/src/cu_safe_call.h +++ b/modules/gpu/src/cu_safe_call.h @@ -50,7 +50,7 @@ namespace cv { namespace gpu { namespace detail { - std::string cuGetErrString(CUresult res); + String cuGetErrString(CUresult res); inline void cuSafeCall_impl(CUresult res, const char* file, int line) { diff --git a/modules/gpu/src/cuvid_video_source.cpp b/modules/gpu/src/cuvid_video_source.cpp index 7d45b8fee..38091e6c2 100644 --- a/modules/gpu/src/cuvid_video_source.cpp +++ b/modules/gpu/src/cuvid_video_source.cpp @@ -3,7 +3,7 @@ #if defined(HAVE_CUDA) && defined(HAVE_NVCUVID) -cv::gpu::detail::CuvidVideoSource::CuvidVideoSource(const std::string& fname) +cv::gpu::detail::CuvidVideoSource::CuvidVideoSource(const String& fname) { CUVIDSOURCEPARAMS params; std::memset(¶ms, 0, sizeof(CUVIDSOURCEPARAMS)); diff --git a/modules/gpu/src/cuvid_video_source.h b/modules/gpu/src/cuvid_video_source.h index 1c4c0e5e0..a541df72d 100644 --- a/modules/gpu/src/cuvid_video_source.h +++ b/modules/gpu/src/cuvid_video_source.h @@ -54,7 +54,7 @@ namespace cv { namespace gpu class CuvidVideoSource : public VideoReader_GPU::VideoSource { public: - explicit CuvidVideoSource(const std::string& fname); + explicit CuvidVideoSource(const String& fname); ~CuvidVideoSource() { cuvidDestroyVideoSource(videoSource_); } VideoReader_GPU::FormatInfo format() const; diff --git a/modules/gpu/src/error.cpp b/modules/gpu/src/error.cpp index e01be8010..771780ef7 100644 --- a/modules/gpu/src/error.cpp +++ b/modules/gpu/src/error.cpp @@ -54,7 +54,7 @@ namespace struct ErrorEntry { int code; - std::string str; + String str; }; struct ErrorEntryComparer @@ -64,11 +64,11 @@ namespace bool operator()(const ErrorEntry& e) const { return e.code == code; } }; - std::string getErrorString(int code, const ErrorEntry* errors, size_t n) + String getErrorString(int code, const ErrorEntry* errors, size_t n) { size_t idx = std::find_if(errors, errors + n, ErrorEntryComparer(code)) - errors; - const std::string& msg = (idx != n) ? errors[idx].str : std::string("Unknown error code"); + const String& msg = (idx != n) ? errors[idx].str : String("Unknown error code"); std::ostringstream ostr; ostr << msg << " [Code = " << code << "]"; @@ -221,25 +221,25 @@ namespace cv { void nppError(int code, const char *file, const int line, const char *func) { - std::string msg = getErrorString(code, npp_errors, npp_error_num); + String msg = getErrorString(code, npp_errors, npp_error_num); cv::gpu::error(msg.c_str(), file, line, func); } void ncvError(int code, const char *file, const int line, const char *func) { - std::string msg = getErrorString(code, ncv_errors, ncv_error_num); + String msg = getErrorString(code, ncv_errors, ncv_error_num); cv::gpu::error(msg.c_str(), file, line, func); } void cufftError(int code, const char *file, const int line, const char *func) { - std::string msg = getErrorString(code, cufft_errors, cufft_error_num); + String msg = getErrorString(code, cufft_errors, cufft_error_num); cv::gpu::error(msg.c_str(), file, line, func); } void cublasError(int code, const char *file, const int line, const char *func) { - std::string msg = getErrorString(code, cublas_errors, cublas_error_num); + String msg = getErrorString(code, cublas_errors, cublas_error_num); cv::gpu::error(msg.c_str(), file, line, func); } } diff --git a/modules/gpu/src/ffmpeg_video_source.cpp b/modules/gpu/src/ffmpeg_video_source.cpp index bd3d70058..9118cc320 100644 --- a/modules/gpu/src/ffmpeg_video_source.cpp +++ b/modules/gpu/src/ffmpeg_video_source.cpp @@ -96,7 +96,7 @@ namespace } } -cv::gpu::detail::FFmpegVideoSource::FFmpegVideoSource(const std::string& fname) : +cv::gpu::detail::FFmpegVideoSource::FFmpegVideoSource(const String& fname) : stream_(0) { CV_Assert( init_MediaStream_FFMPEG() ); diff --git a/modules/gpu/src/ffmpeg_video_source.h b/modules/gpu/src/ffmpeg_video_source.h index 41bf0cfd0..3795dfd2e 100644 --- a/modules/gpu/src/ffmpeg_video_source.h +++ b/modules/gpu/src/ffmpeg_video_source.h @@ -57,7 +57,7 @@ namespace cv { namespace gpu class FFmpegVideoSource : public VideoReader_GPU::VideoSource { public: - FFmpegVideoSource(const std::string& fname); + FFmpegVideoSource(const String& fname); ~FFmpegVideoSource(); VideoReader_GPU::FormatInfo format() const; diff --git a/modules/gpu/src/nvidia/NCVHaarObjectDetection.cu b/modules/gpu/src/nvidia/NCVHaarObjectDetection.cu index fb057ae79..fa3b626d9 100644 --- a/modules/gpu/src/nvidia/NCVHaarObjectDetection.cu +++ b/modules/gpu/src/nvidia/NCVHaarObjectDetection.cu @@ -2099,7 +2099,7 @@ NCVStatus ncvGrowDetectionsVector_host(NCVVector &pixelMask, } -NCVStatus loadFromXML(const std::string &filename, +NCVStatus loadFromXML(const String &filename, HaarClassifierCascadeDescriptor &haar, std::vector &haarStages, std::vector &haarClassifierNodes, @@ -2110,7 +2110,7 @@ NCVStatus loadFromXML(const std::string &filename, #define NVBIN_HAAR_VERSION 0x1 -static NCVStatus loadFromNVBIN(const std::string &filename, +static NCVStatus loadFromNVBIN(const String &filename, HaarClassifierCascadeDescriptor &haar, std::vector &haarStages, std::vector &haarClassifierNodes, @@ -2174,13 +2174,13 @@ static NCVStatus loadFromNVBIN(const std::string &filename, } -NCVStatus ncvHaarGetClassifierSize(const std::string &filename, Ncv32u &numStages, +NCVStatus ncvHaarGetClassifierSize(const String &filename, Ncv32u &numStages, Ncv32u &numNodes, Ncv32u &numFeatures) { size_t readCount; NCVStatus ncvStat; - std::string fext = filename.substr(filename.find_last_of(".") + 1); + String fext = filename.substr(filename.find_last_of(".") + 1); std::transform(fext.begin(), fext.end(), fext.begin(), ::tolower); if (fext == "nvbin") @@ -2226,7 +2226,7 @@ NCVStatus ncvHaarGetClassifierSize(const std::string &filename, Ncv32u &numStage } -NCVStatus ncvHaarLoadFromFile_host(const std::string &filename, +NCVStatus ncvHaarLoadFromFile_host(const String &filename, HaarClassifierCascadeDescriptor &haar, NCVVector &h_HaarStages, NCVVector &h_HaarNodes, @@ -2238,7 +2238,7 @@ NCVStatus ncvHaarLoadFromFile_host(const std::string &filename, NCVStatus ncvStat; - std::string fext = filename.substr(filename.find_last_of(".") + 1); + String fext = filename.substr(filename.find_last_of(".") + 1); std::transform(fext.begin(), fext.end(), fext.begin(), ::tolower); std::vector haarStages; @@ -2272,7 +2272,7 @@ NCVStatus ncvHaarLoadFromFile_host(const std::string &filename, } -NCVStatus ncvHaarStoreNVBIN_host(const std::string &filename, +NCVStatus ncvHaarStoreNVBIN_host(const String &filename, HaarClassifierCascadeDescriptor haar, NCVVector &h_HaarStages, NCVVector &h_HaarNodes, diff --git a/modules/gpu/src/nvidia/NCVHaarObjectDetection.hpp b/modules/gpu/src/nvidia/NCVHaarObjectDetection.hpp index 9f29206f0..a70d4b948 100644 --- a/modules/gpu/src/nvidia/NCVHaarObjectDetection.hpp +++ b/modules/gpu/src/nvidia/NCVHaarObjectDetection.hpp @@ -58,7 +58,6 @@ #ifndef _ncvhaarobjectdetection_hpp_ #define _ncvhaarobjectdetection_hpp_ -#include #include "NCV.hpp" @@ -439,18 +438,18 @@ NCV_EXPORTS NCVStatus ncvGrowDetectionsVector_host(NCVVector &pixelMask, Ncv32f curScale); -NCV_EXPORTS NCVStatus ncvHaarGetClassifierSize(const std::string &filename, Ncv32u &numStages, +NCV_EXPORTS NCVStatus ncvHaarGetClassifierSize(const String &filename, Ncv32u &numStages, Ncv32u &numNodes, Ncv32u &numFeatures); -NCV_EXPORTS NCVStatus ncvHaarLoadFromFile_host(const std::string &filename, +NCV_EXPORTS NCVStatus ncvHaarLoadFromFile_host(const String &filename, HaarClassifierCascadeDescriptor &haar, NCVVector &h_HaarStages, NCVVector &h_HaarNodes, NCVVector &h_HaarFeatures); -NCV_EXPORTS NCVStatus ncvHaarStoreNVBIN_host(const std::string &filename, +NCV_EXPORTS NCVStatus ncvHaarStoreNVBIN_host(const String &filename, HaarClassifierCascadeDescriptor haar, NCVVector &h_HaarStages, NCVVector &h_HaarNodes, diff --git a/modules/gpu/src/nvidia/core/NCV.cu b/modules/gpu/src/nvidia/core/NCV.cu index 77e59cc5c..e99cc9dfd 100644 --- a/modules/gpu/src/nvidia/core/NCV.cu +++ b/modules/gpu/src/nvidia/core/NCV.cu @@ -41,7 +41,6 @@ #include -#include #include #include "NCV.hpp" @@ -53,7 +52,7 @@ //============================================================================== -static void stdDebugOutput(const std::string &msg) +static void stdDebugOutput(const String &msg) { std::cout << msg; } @@ -62,7 +61,7 @@ static void stdDebugOutput(const std::string &msg) static NCVDebugOutputHandler *debugOutputHandler = stdDebugOutput; -void ncvDebugOutput(const std::string &msg) +void ncvDebugOutput(const String &msg) { debugOutputHandler(msg); } diff --git a/modules/gpu/src/nvidia/core/NCV.hpp b/modules/gpu/src/nvidia/core/NCV.hpp index 703cb827b..b40388491 100644 --- a/modules/gpu/src/nvidia/core/NCV.hpp +++ b/modules/gpu/src/nvidia/core/NCV.hpp @@ -243,10 +243,10 @@ const Ncv32u K_LOG2_WARP_SIZE = 5; //============================================================================== -NCV_EXPORTS void ncvDebugOutput(const std::string &msg); +NCV_EXPORTS void ncvDebugOutput(const String &msg); -typedef void NCVDebugOutputHandler(const std::string &msg); +typedef void NCVDebugOutputHandler(const String &msg); NCV_EXPORTS void ncvSetDebugOutputHandler(NCVDebugOutputHandler* func); diff --git a/modules/gpu/src/optical_flow.cpp b/modules/gpu/src/optical_flow.cpp index 3d8fc05ec..2982003f4 100644 --- a/modules/gpu/src/optical_flow.cpp +++ b/modules/gpu/src/optical_flow.cpp @@ -68,7 +68,7 @@ namespace namespace { - static void outputHandler(const std::string &msg) { CV_Error(CV_GpuApiCallError, msg.c_str()); } + static void outputHandler(const String &msg) { CV_Error(CV_GpuApiCallError, msg.c_str()); } } void cv::gpu::BroxOpticalFlow::operator ()(const GpuMat& frame0, const GpuMat& frame1, GpuMat& u, GpuMat& v, Stream& s) diff --git a/modules/gpu/src/precomp.hpp b/modules/gpu/src/precomp.hpp index caa46cfc8..41f5af5c5 100644 --- a/modules/gpu/src/precomp.hpp +++ b/modules/gpu/src/precomp.hpp @@ -64,7 +64,6 @@ #include #include #include -#include #include "opencv2/gpu.hpp" #include "opencv2/imgproc.hpp" diff --git a/modules/gpu/src/video_reader.cpp b/modules/gpu/src/video_reader.cpp index 3224902c6..036845d4b 100644 --- a/modules/gpu/src/video_reader.cpp +++ b/modules/gpu/src/video_reader.cpp @@ -49,10 +49,10 @@ class cv::gpu::VideoReader_GPU::Impl }; cv::gpu::VideoReader_GPU::VideoReader_GPU() { throw_nogpu(); } -cv::gpu::VideoReader_GPU::VideoReader_GPU(const std::string&) { throw_nogpu(); } +cv::gpu::VideoReader_GPU::VideoReader_GPU(const String&) { throw_nogpu(); } cv::gpu::VideoReader_GPU::VideoReader_GPU(const cv::Ptr&) { throw_nogpu(); } cv::gpu::VideoReader_GPU::~VideoReader_GPU() { } -void cv::gpu::VideoReader_GPU::open(const std::string&) { throw_nogpu(); } +void cv::gpu::VideoReader_GPU::open(const String&) { throw_nogpu(); } void cv::gpu::VideoReader_GPU::open(const cv::Ptr&) { throw_nogpu(); } bool cv::gpu::VideoReader_GPU::isOpened() const { return false; } void cv::gpu::VideoReader_GPU::close() { } @@ -294,7 +294,7 @@ cv::gpu::VideoReader_GPU::VideoReader_GPU() { } -cv::gpu::VideoReader_GPU::VideoReader_GPU(const std::string& filename) +cv::gpu::VideoReader_GPU::VideoReader_GPU(const String& filename) { open(filename); } @@ -309,7 +309,7 @@ cv::gpu::VideoReader_GPU::~VideoReader_GPU() close(); } -void cv::gpu::VideoReader_GPU::open(const std::string& filename) +void cv::gpu::VideoReader_GPU::open(const String& filename) { CV_Assert( !filename.empty() ); diff --git a/modules/gpu/src/video_writer.cpp b/modules/gpu/src/video_writer.cpp index fe44a16f7..3a97fb309 100644 --- a/modules/gpu/src/video_writer.cpp +++ b/modules/gpu/src/video_writer.cpp @@ -49,13 +49,13 @@ class cv::gpu::VideoWriter_GPU::Impl }; cv::gpu::VideoWriter_GPU::VideoWriter_GPU() { throw_nogpu(); } -cv::gpu::VideoWriter_GPU::VideoWriter_GPU(const std::string&, cv::Size, double, SurfaceFormat) { throw_nogpu(); } -cv::gpu::VideoWriter_GPU::VideoWriter_GPU(const std::string&, cv::Size, double, const EncoderParams&, SurfaceFormat) { throw_nogpu(); } +cv::gpu::VideoWriter_GPU::VideoWriter_GPU(const String&, cv::Size, double, SurfaceFormat) { throw_nogpu(); } +cv::gpu::VideoWriter_GPU::VideoWriter_GPU(const String&, cv::Size, double, const EncoderParams&, SurfaceFormat) { throw_nogpu(); } cv::gpu::VideoWriter_GPU::VideoWriter_GPU(const cv::Ptr&, cv::Size, double, SurfaceFormat) { throw_nogpu(); } cv::gpu::VideoWriter_GPU::VideoWriter_GPU(const cv::Ptr&, cv::Size, double, const EncoderParams&, SurfaceFormat) { throw_nogpu(); } cv::gpu::VideoWriter_GPU::~VideoWriter_GPU() {} -void cv::gpu::VideoWriter_GPU::open(const std::string&, cv::Size, double, SurfaceFormat) { throw_nogpu(); } -void cv::gpu::VideoWriter_GPU::open(const std::string&, cv::Size, double, const EncoderParams&, SurfaceFormat) { throw_nogpu(); } +void cv::gpu::VideoWriter_GPU::open(const String&, cv::Size, double, SurfaceFormat) { throw_nogpu(); } +void cv::gpu::VideoWriter_GPU::open(const String&, cv::Size, double, const EncoderParams&, SurfaceFormat) { throw_nogpu(); } void cv::gpu::VideoWriter_GPU::open(const cv::Ptr&, cv::Size, double, SurfaceFormat) { throw_nogpu(); } void cv::gpu::VideoWriter_GPU::open(const cv::Ptr&, cv::Size, double, const EncoderParams&, SurfaceFormat) { throw_nogpu(); } bool cv::gpu::VideoWriter_GPU::isOpened() const { return false; } @@ -64,9 +64,9 @@ void cv::gpu::VideoWriter_GPU::write(const cv::gpu::GpuMat&, bool) { throw_nogpu cv::gpu::VideoWriter_GPU::EncoderParams cv::gpu::VideoWriter_GPU::getParams() const { EncoderParams params; throw_nogpu(); return params; } cv::gpu::VideoWriter_GPU::EncoderParams::EncoderParams() { throw_nogpu(); } -cv::gpu::VideoWriter_GPU::EncoderParams::EncoderParams(const std::string&) { throw_nogpu(); } -void cv::gpu::VideoWriter_GPU::EncoderParams::load(const std::string&) { throw_nogpu(); } -void cv::gpu::VideoWriter_GPU::EncoderParams::save(const std::string&) const { throw_nogpu(); } +cv::gpu::VideoWriter_GPU::EncoderParams::EncoderParams(const String&) { throw_nogpu(); } +void cv::gpu::VideoWriter_GPU::EncoderParams::load(const String&) { throw_nogpu(); } +void cv::gpu::VideoWriter_GPU::EncoderParams::save(const String&) const { throw_nogpu(); } #else // !defined HAVE_CUDA || !defined WIN32 @@ -736,7 +736,7 @@ void NVENCAPI cv::gpu::VideoWriter_GPU::Impl::HandleOnEndFrame(const NVVE_EndFra class EncoderCallBackFFMPEG : public cv::gpu::VideoWriter_GPU::EncoderCallBack { public: - EncoderCallBackFFMPEG(const std::string& fileName, cv::Size frameSize, double fps); + EncoderCallBackFFMPEG(const String& fileName, cv::Size frameSize, double fps); ~EncoderCallBackFFMPEG(); unsigned char* acquireBitStream(int* bufferSize); @@ -799,7 +799,7 @@ namespace } } -EncoderCallBackFFMPEG::EncoderCallBackFFMPEG(const std::string& fileName, cv::Size frameSize, double fps) : +EncoderCallBackFFMPEG::EncoderCallBackFFMPEG(const String& fileName, cv::Size frameSize, double fps) : stream_(0), isKeyFrame_(false) { int buf_size = std::max(frameSize.area() * 4, 1024 * 1024); @@ -843,12 +843,12 @@ cv::gpu::VideoWriter_GPU::VideoWriter_GPU() { } -cv::gpu::VideoWriter_GPU::VideoWriter_GPU(const std::string& fileName, cv::Size frameSize, double fps, SurfaceFormat format) +cv::gpu::VideoWriter_GPU::VideoWriter_GPU(const String& fileName, cv::Size frameSize, double fps, SurfaceFormat format) { open(fileName, frameSize, fps, format); } -cv::gpu::VideoWriter_GPU::VideoWriter_GPU(const std::string& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format) +cv::gpu::VideoWriter_GPU::VideoWriter_GPU(const String& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format) { open(fileName, frameSize, fps, params, format); } @@ -868,14 +868,14 @@ cv::gpu::VideoWriter_GPU::~VideoWriter_GPU() close(); } -void cv::gpu::VideoWriter_GPU::open(const std::string& fileName, cv::Size frameSize, double fps, SurfaceFormat format) +void cv::gpu::VideoWriter_GPU::open(const String& fileName, cv::Size frameSize, double fps, SurfaceFormat format) { close(); cv::Ptr encoderCallback(new EncoderCallBackFFMPEG(fileName, frameSize, fps)); open(encoderCallback, frameSize, fps, format); } -void cv::gpu::VideoWriter_GPU::open(const std::string& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format) +void cv::gpu::VideoWriter_GPU::open(const String& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format) { close(); cv::Ptr encoderCallback(new EncoderCallBackFFMPEG(fileName, frameSize, fps)); @@ -944,12 +944,12 @@ cv::gpu::VideoWriter_GPU::EncoderParams::EncoderParams() DisableSPSPPS = 0; } -cv::gpu::VideoWriter_GPU::EncoderParams::EncoderParams(const std::string& configFile) +cv::gpu::VideoWriter_GPU::EncoderParams::EncoderParams(const String& configFile) { load(configFile); } -void cv::gpu::VideoWriter_GPU::EncoderParams::load(const std::string& configFile) +void cv::gpu::VideoWriter_GPU::EncoderParams::load(const String& configFile) { cv::FileStorage fs(configFile, cv::FileStorage::READ); CV_Assert( fs.isOpened() ); @@ -975,7 +975,7 @@ void cv::gpu::VideoWriter_GPU::EncoderParams::load(const std::string& configFile cv::read(fs["DisableSPSPPS" ], DisableSPSPPS, 0); } -void cv::gpu::VideoWriter_GPU::EncoderParams::save(const std::string& configFile) const +void cv::gpu::VideoWriter_GPU::EncoderParams::save(const String& configFile) const { cv::FileStorage fs(configFile, cv::FileStorage::WRITE); CV_Assert( fs.isOpened() ); diff --git a/modules/highgui/doc/qt_new_functions.rst b/modules/highgui/doc/qt_new_functions.rst index bd889db8a..671b55823 100644 --- a/modules/highgui/doc/qt_new_functions.rst +++ b/modules/highgui/doc/qt_new_functions.rst @@ -61,7 +61,7 @@ setWindowProperty --------------------- Changes parameters of a window dynamically. -.. ocv:function:: void setWindowProperty( const string& winname, int prop_id, double prop_value ) +.. ocv:function:: void setWindowProperty( const String& winname, int prop_id, double prop_value ) .. ocv:pyfunction:: cv2.setWindowProperty(winname, prop_id, prop_value) -> None @@ -97,7 +97,7 @@ getWindowProperty --------------------- Provides parameters of a window. -.. ocv:function:: double getWindowProperty( const string& winname, int prop_id ) +.. ocv:function:: double getWindowProperty( const String& winname, int prop_id ) .. ocv:pyfunction:: cv2.getWindowProperty(winname, prop_id) -> retval @@ -123,7 +123,7 @@ fontQt ---------- Creates the font to draw a text on an image. -.. ocv:function:: CvFont fontQt(const string& nameFont, int pointSize = -1, Scalar color = Scalar::all(0), int weight = CV_FONT_NORMAL, int style = CV_STYLE_NORMAL, int spacing = 0) +.. ocv:function:: CvFont fontQt(const String& nameFont, int pointSize = -1, Scalar color = Scalar::all(0), int weight = CV_FONT_NORMAL, int style = CV_STYLE_NORMAL, int spacing = 0) .. ocv:cfunction:: CvFont cvFontQt(const char* nameFont, int pointSize=-1, CvScalar color=cvScalarAll(0), int weight=CV_FONT_NORMAL, int style=CV_STYLE_NORMAL, int spacing=0) @@ -169,7 +169,7 @@ addText ----------- Creates the font to draw a text on an image. -.. ocv:function:: void addText( const Mat& img, const string& text, Point org, CvFont font ) +.. ocv:function:: void addText( const Mat& img, const String& text, Point org, CvFont font ) .. ocv:cfunction:: void cvAddText( const CvArr* img, const char* text, CvPoint org, CvFont * arg2 ) @@ -195,7 +195,7 @@ displayOverlay ------------------ Displays a text on a window image as an overlay for a specified duration. -.. ocv:function:: void displayOverlay( const string& winname, const string& text, int delayms=0 ) +.. ocv:function:: void displayOverlay( const String& winname, const String& text, int delayms=0 ) .. ocv:cfunction:: void cvDisplayOverlay(const char* name, const char* text, int delayms = 0) @@ -212,7 +212,7 @@ displayStatusBar -------------------- Displays a text on the window statusbar during the specified period of time. -.. ocv:function:: void displayStatusBar( const string& winname, const string& text, int delayms=0 ) +.. ocv:function:: void displayStatusBar( const String& winname, const String& text, int delayms=0 ) .. ocv:cfunction:: void cvDisplayStatusBar(const char* name, const char* text, int delayms = 0) @@ -230,7 +230,7 @@ setOpenGlDrawCallback ------------------------ Sets a callback function to be called to draw on top of displayed image. -.. ocv:function:: void setOpenGlDrawCallback( const string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata=0 ) +.. ocv:function:: void setOpenGlDrawCallback( const String& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata=0 ) .. ocv:cfunction:: void cvSetOpenGlDrawCallback( const char* window_name, CvOpenGlDrawCallback callback, void* userdata=NULL ) @@ -276,7 +276,7 @@ saveWindowParameters ------------------------ Saves parameters of the specified window. -.. ocv:function:: void saveWindowParameters( const string& windowName ) +.. ocv:function:: void saveWindowParameters( const String& windowName ) .. ocv:cfunction:: void cvSaveWindowParameters(const char* name) @@ -289,7 +289,7 @@ loadWindowParameters ------------------------ Loads parameters of the specified window. -.. ocv:function:: void loadWindowParameters( const string& windowName ) +.. ocv:function:: void loadWindowParameters( const String& windowName ) .. ocv:cfunction:: void cvLoadWindowParameters(const char* name) @@ -302,7 +302,7 @@ createButton ---------------- Attaches a button to the control panel. -.. ocv:function:: int createButton( const string& bar_name, ButtonCallback on_change, void* userdata=NULL, int type=CV_PUSH_BUTTON, bool initial_button_state=0 ) +.. ocv:function:: int createButton( const String& bar_name, ButtonCallback on_change, void* userdata=NULL, int type=CV_PUSH_BUTTON, bool initial_button_state=0 ) .. ocv:cfunction:: int cvCreateButton( const char* button_name=NULL, CvButtonCallback on_change=NULL, void* userdata=NULL, int button_type=CV_PUSH_BUTTON, int initial_button_state=0 ) diff --git a/modules/highgui/doc/reading_and_writing_images_and_video.rst b/modules/highgui/doc/reading_and_writing_images_and_video.rst index d1829a01d..178026c0b 100644 --- a/modules/highgui/doc/reading_and_writing_images_and_video.rst +++ b/modules/highgui/doc/reading_and_writing_images_and_video.rst @@ -35,7 +35,7 @@ imencode -------- Encodes an image into a memory buffer. -.. ocv:function:: bool imencode( const string& ext, InputArray img, vector& buf, const vector& params=vector()) +.. ocv:function:: bool imencode( const String& ext, InputArray img, vector& buf, const vector& params=vector()) .. ocv:cfunction:: CvMat* cvEncodeImage( const char* ext, const CvArr* image, const int* params=0 ) @@ -59,7 +59,7 @@ imread ------ Loads an image from a file. -.. ocv:function:: Mat imread( const string& filename, int flags=1 ) +.. ocv:function:: Mat imread( const String& filename, int flags=1 ) .. ocv:pyfunction:: cv2.imread(filename[, flags]) -> retval @@ -120,7 +120,7 @@ imwrite ----------- Saves an image to a specified file. -.. ocv:function:: bool imwrite( const string& filename, InputArray img, const vector& params=vector() ) +.. ocv:function:: bool imwrite( const String& filename, InputArray img, const vector& params=vector() ) .. ocv:pyfunction:: cv2.imwrite(filename, img[, params]) -> retval @@ -236,7 +236,7 @@ VideoCapture constructors. .. ocv:function:: VideoCapture::VideoCapture() -.. ocv:function:: VideoCapture::VideoCapture(const string& filename) +.. ocv:function:: VideoCapture::VideoCapture(const String& filename) .. ocv:function:: VideoCapture::VideoCapture(int device) @@ -260,7 +260,7 @@ VideoCapture::open --------------------- Open video file or a capturing device for video capturing -.. ocv:function:: bool VideoCapture::open(const string& filename) +.. ocv:function:: bool VideoCapture::open(const String& filename) .. ocv:function:: bool VideoCapture::open(int device) .. ocv:pyfunction:: cv2.VideoCapture.open(filename) -> retval @@ -479,7 +479,7 @@ VideoWriter constructors .. ocv:function:: VideoWriter::VideoWriter() -.. ocv:function:: VideoWriter::VideoWriter(const string& filename, int fourcc, double fps, Size frameSize, bool isColor=true) +.. ocv:function:: VideoWriter::VideoWriter(const String& filename, int fourcc, double fps, Size frameSize, bool isColor=true) .. ocv:pyfunction:: cv2.VideoWriter([filename, fourcc, fps, frameSize[, isColor]]) -> @@ -517,7 +517,7 @@ VideoWriter::open ----------------- Initializes or reinitializes video writer. -.. ocv:function:: bool VideoWriter::open(const string& filename, int fourcc, double fps, Size frameSize, bool isColor=true) +.. ocv:function:: bool VideoWriter::open(const String& filename, int fourcc, double fps, Size frameSize, bool isColor=true) .. ocv:pyfunction:: cv2.VideoWriter.open(filename, fourcc, fps, frameSize[, isColor]) -> retval diff --git a/modules/highgui/doc/user_interface.rst b/modules/highgui/doc/user_interface.rst index def8451a2..ad960100c 100644 --- a/modules/highgui/doc/user_interface.rst +++ b/modules/highgui/doc/user_interface.rst @@ -7,7 +7,7 @@ createTrackbar ------------------ Creates a trackbar and attaches it to the specified window. -.. ocv:function:: int createTrackbar( const string& trackbarname, const string& winname, int* value, int count, TrackbarCallback onChange=0, void* userdata=0) +.. ocv:function:: int createTrackbar( const String& trackbarname, const String& winname, int* value, int count, TrackbarCallback onChange=0, void* userdata=0) .. ocv:cfunction:: int cvCreateTrackbar( const char* trackbar_name, const char* window_name, int* value, int count, CvTrackbarCallback on_change=NULL ) @@ -37,7 +37,7 @@ getTrackbarPos ------------------ Returns the trackbar position. -.. ocv:function:: int getTrackbarPos( const string& trackbarname, const string& winname ) +.. ocv:function:: int getTrackbarPos( const String& trackbarname, const String& winname ) .. ocv:pyfunction:: cv2.getTrackbarPos(trackbarname, winname) -> retval @@ -59,7 +59,7 @@ imshow ---------- Displays an image in the specified window. -.. ocv:function:: void imshow( const string& winname, InputArray mat ) +.. ocv:function:: void imshow( const String& winname, InputArray mat ) .. ocv:pyfunction:: cv2.imshow(winname, mat) -> None @@ -84,7 +84,7 @@ namedWindow --------------- Creates a window. -.. ocv:function:: void namedWindow( const string& winname, int flags=WINDOW_AUTOSIZE ) +.. ocv:function:: void namedWindow( const String& winname, int flags=WINDOW_AUTOSIZE ) .. ocv:pyfunction:: cv2.namedWindow(winname[, flags]) -> None @@ -119,7 +119,7 @@ destroyWindow ------------- Destroys a window. -.. ocv:function:: void destroyWindow( const string& winname ) +.. ocv:function:: void destroyWindow( const String& winname ) .. ocv:pyfunction:: cv2.destroyWindow(winname) -> None @@ -151,7 +151,7 @@ MoveWindow ---------- Moves window to the specified position -.. ocv:function:: void moveWindow( const string& winname, int x, int y ) +.. ocv:function:: void moveWindow( const String& winname, int x, int y ) .. ocv:pyfunction:: cv2.moveWindow(winname, x, y) -> None @@ -170,7 +170,7 @@ ResizeWindow ------------ Resizes window to the specified size -.. ocv:function:: void resizeWindow( const string& winname, int width, int height ) +.. ocv:function:: void resizeWindow( const String& winname, int width, int height ) .. ocv:pyfunction:: cv2.resizeWindow(winname, width, height) -> None @@ -195,7 +195,7 @@ SetMouseCallback ---------------- Sets mouse handler for the specified window -.. ocv:function:: void setMouseCallback( const string& winname, MouseCallback onMouse, void* userdata=0 ) +.. ocv:function:: void setMouseCallback( const String& winname, MouseCallback onMouse, void* userdata=0 ) .. ocv:cfunction:: void cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse, void* param=NULL ) @@ -212,7 +212,7 @@ setTrackbarPos ------------------ Sets the trackbar position. -.. ocv:function:: void setTrackbarPos( const string& trackbarname, const string& winname, int pos ) +.. ocv:function:: void setTrackbarPos( const String& trackbarname, const String& winname, int pos ) .. ocv:pyfunction:: cv2.setTrackbarPos(trackbarname, winname, pos) -> None diff --git a/modules/highgui/include/opencv2/highgui.hpp b/modules/highgui/include/opencv2/highgui.hpp index 0b1c617cd..ecec175f6 100644 --- a/modules/highgui/include/opencv2/highgui.hpp +++ b/modules/highgui/include/opencv2/highgui.hpp @@ -67,21 +67,21 @@ enum { WND_PROP_OPENGL = CV_WND_PROP_OPENGL // opengl support }; -CV_EXPORTS_W void namedWindow(const std::string& winname, int flags = WINDOW_AUTOSIZE); -CV_EXPORTS_W void destroyWindow(const std::string& winname); +CV_EXPORTS_W void namedWindow(const String& winname, int flags = WINDOW_AUTOSIZE); +CV_EXPORTS_W void destroyWindow(const String& winname); CV_EXPORTS_W void destroyAllWindows(); CV_EXPORTS_W int startWindowThread(); CV_EXPORTS_W int waitKey(int delay = 0); -CV_EXPORTS_W void imshow(const std::string& winname, InputArray mat); +CV_EXPORTS_W void imshow(const String& winname, InputArray mat); -CV_EXPORTS_W void resizeWindow(const std::string& winname, int width, int height); -CV_EXPORTS_W void moveWindow(const std::string& winname, int x, int y); +CV_EXPORTS_W void resizeWindow(const String& winname, int width, int height); +CV_EXPORTS_W void moveWindow(const String& winname, int x, int y); -CV_EXPORTS_W void setWindowProperty(const std::string& winname, int prop_id, double prop_value);//YV -CV_EXPORTS_W double getWindowProperty(const std::string& winname, int prop_id);//YV +CV_EXPORTS_W void setWindowProperty(const String& winname, int prop_id, double prop_value);//YV +CV_EXPORTS_W double getWindowProperty(const String& winname, int prop_id);//YV enum { @@ -110,45 +110,45 @@ enum typedef void (*MouseCallback)(int event, int x, int y, int flags, void* userdata); //! assigns callback for mouse events -CV_EXPORTS void setMouseCallback(const std::string& winname, MouseCallback onMouse, void* userdata = 0); +CV_EXPORTS void setMouseCallback(const String& winname, MouseCallback onMouse, void* userdata = 0); typedef void (CV_CDECL *TrackbarCallback)(int pos, void* userdata); -CV_EXPORTS int createTrackbar(const std::string& trackbarname, const std::string& winname, +CV_EXPORTS int createTrackbar(const String& trackbarname, const String& winname, int* value, int count, TrackbarCallback onChange = 0, void* userdata = 0); -CV_EXPORTS_W int getTrackbarPos(const std::string& trackbarname, const std::string& winname); -CV_EXPORTS_W void setTrackbarPos(const std::string& trackbarname, const std::string& winname, int pos); +CV_EXPORTS_W int getTrackbarPos(const String& trackbarname, const String& winname); +CV_EXPORTS_W void setTrackbarPos(const String& trackbarname, const String& winname, int pos); // OpenGL support typedef void (*OpenGlDrawCallback)(void* userdata); -CV_EXPORTS void setOpenGlDrawCallback(const std::string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0); +CV_EXPORTS void setOpenGlDrawCallback(const String& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0); -CV_EXPORTS void setOpenGlContext(const std::string& winname); +CV_EXPORTS void setOpenGlContext(const String& winname); -CV_EXPORTS void updateWindow(const std::string& winname); +CV_EXPORTS void updateWindow(const String& winname); //Only for Qt -CV_EXPORTS CvFont fontQt(const std::string& nameFont, int pointSize=-1, +CV_EXPORTS CvFont fontQt(const String& nameFont, int pointSize=-1, Scalar color=Scalar::all(0), int weight=CV_FONT_NORMAL, int style=CV_STYLE_NORMAL, int spacing=0); -CV_EXPORTS void addText( const Mat& img, const std::string& text, Point org, CvFont font); +CV_EXPORTS void addText( const Mat& img, const String& text, Point org, CvFont font); -CV_EXPORTS void displayOverlay(const std::string& winname, const std::string& text, int delayms CV_DEFAULT(0)); -CV_EXPORTS void displayStatusBar(const std::string& winname, const std::string& text, int delayms CV_DEFAULT(0)); +CV_EXPORTS void displayOverlay(const String& winname, const String& text, int delayms CV_DEFAULT(0)); +CV_EXPORTS void displayStatusBar(const String& winname, const String& text, int delayms CV_DEFAULT(0)); -CV_EXPORTS void saveWindowParameters(const std::string& windowName); -CV_EXPORTS void loadWindowParameters(const std::string& windowName); +CV_EXPORTS void saveWindowParameters(const String& windowName); +CV_EXPORTS void loadWindowParameters(const String& windowName); CV_EXPORTS int startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]); CV_EXPORTS void stopLoop(); typedef void (CV_CDECL *ButtonCallback)(int state, void* userdata); -CV_EXPORTS int createButton( const std::string& bar_name, ButtonCallback on_change, +CV_EXPORTS int createButton( const String& bar_name, ButtonCallback on_change, void* userdata=NULL, int type=CV_PUSH_BUTTON, bool initial_button_state=0); @@ -182,12 +182,12 @@ enum IMWRITE_PXM_BINARY =32 }; -CV_EXPORTS_W Mat imread( const std::string& filename, int flags=1 ); -CV_EXPORTS_W bool imwrite( const std::string& filename, InputArray img, +CV_EXPORTS_W Mat imread( const String& filename, int flags=1 ); +CV_EXPORTS_W bool imwrite( const String& filename, InputArray img, const std::vector& params=std::vector()); CV_EXPORTS_W Mat imdecode( InputArray buf, int flags ); CV_EXPORTS Mat imdecode( InputArray buf, int flags, Mat* dst ); -CV_EXPORTS_W bool imencode( const std::string& ext, InputArray img, +CV_EXPORTS_W bool imencode( const String& ext, InputArray img, CV_OUT std::vector& buf, const std::vector& params=std::vector()); @@ -200,11 +200,11 @@ class CV_EXPORTS_W VideoCapture { public: CV_WRAP VideoCapture(); - CV_WRAP VideoCapture(const std::string& filename); + CV_WRAP VideoCapture(const String& filename); CV_WRAP VideoCapture(int device); virtual ~VideoCapture(); - CV_WRAP virtual bool open(const std::string& filename); + CV_WRAP virtual bool open(const String& filename); CV_WRAP virtual bool open(int device); CV_WRAP virtual bool isOpened() const; CV_WRAP virtual void release(); @@ -226,11 +226,11 @@ class CV_EXPORTS_W VideoWriter { public: CV_WRAP VideoWriter(); - CV_WRAP VideoWriter(const std::string& filename, int fourcc, double fps, + CV_WRAP VideoWriter(const String& filename, int fourcc, double fps, Size frameSize, bool isColor=true); virtual ~VideoWriter(); - CV_WRAP virtual bool open(const std::string& filename, int fourcc, double fps, + CV_WRAP virtual bool open(const String& filename, int fourcc, double fps, Size frameSize, bool isColor=true); CV_WRAP virtual bool isOpened() const; CV_WRAP virtual void release(); diff --git a/modules/highgui/src/bitstrm.cpp b/modules/highgui/src/bitstrm.cpp index 89f46fb59..c47744bb3 100644 --- a/modules/highgui/src/bitstrm.cpp +++ b/modules/highgui/src/bitstrm.cpp @@ -110,7 +110,7 @@ void RBaseStream::readBlock() } -bool RBaseStream::open( const std::string& filename ) +bool RBaseStream::open( const String& filename ) { close(); allocate(); @@ -388,7 +388,7 @@ void WBaseStream::writeBlock() } -bool WBaseStream::open( const std::string& filename ) +bool WBaseStream::open( const String& filename ) { close(); allocate(); diff --git a/modules/highgui/src/bitstrm.hpp b/modules/highgui/src/bitstrm.hpp index 221c2c709..df72e7373 100644 --- a/modules/highgui/src/bitstrm.hpp +++ b/modules/highgui/src/bitstrm.hpp @@ -66,7 +66,7 @@ public: RBaseStream(); virtual ~RBaseStream(); - virtual bool open( const std::string& filename ); + virtual bool open( const String& filename ); virtual bool open( const Mat& buf ); virtual void close(); bool isOpened(); @@ -123,7 +123,7 @@ public: WBaseStream(); virtual ~WBaseStream(); - virtual bool open( const std::string& filename ); + virtual bool open( const String& filename ); virtual bool open( std::vector& buf ); virtual void close(); bool isOpened(); diff --git a/modules/highgui/src/cap.cpp b/modules/highgui/src/cap.cpp index 012f712dc..936d213ef 100644 --- a/modules/highgui/src/cap.cpp +++ b/modules/highgui/src/cap.cpp @@ -445,7 +445,7 @@ namespace cv VideoCapture::VideoCapture() {} -VideoCapture::VideoCapture(const std::string& filename) +VideoCapture::VideoCapture(const String& filename) { open(filename); } @@ -460,7 +460,7 @@ VideoCapture::~VideoCapture() cap.release(); } -bool VideoCapture::open(const std::string& filename) +bool VideoCapture::open(const String& filename) { if (!isOpened()) cap = cvCreateFileCapture(filename.c_str()); @@ -532,7 +532,7 @@ double VideoCapture::get(int propId) VideoWriter::VideoWriter() {} -VideoWriter::VideoWriter(const std::string& filename, int fourcc, double fps, Size frameSize, bool isColor) +VideoWriter::VideoWriter(const String& filename, int fourcc, double fps, Size frameSize, bool isColor) { open(filename, fourcc, fps, frameSize, isColor); } @@ -547,7 +547,7 @@ VideoWriter::~VideoWriter() release(); } -bool VideoWriter::open(const std::string& filename, int fourcc, double fps, Size frameSize, bool isColor) +bool VideoWriter::open(const String& filename, int fourcc, double fps, Size frameSize, bool isColor) { writer = cvCreateVideoWriter(filename.c_str(), fourcc, fps, frameSize, isColor); return isOpened(); diff --git a/modules/highgui/src/cap_openni.cpp b/modules/highgui/src/cap_openni.cpp index fed59de74..1ca140634 100644 --- a/modules/highgui/src/cap_openni.cpp +++ b/modules/highgui/src/cap_openni.cpp @@ -48,7 +48,6 @@ # undef HAVE_TBB #endif -#include #include #ifndef i386 @@ -66,7 +65,7 @@ #include "XnCppWrapper.h" -const std::string XMLConfig = +const cv::String XMLConfig = "" "" "" @@ -558,8 +557,7 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.Init(); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to initialize the context: " - << std::string(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to initialize the context: %s\n", xnGetStatusString(status)); return; } @@ -568,17 +566,16 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.EnumerateProductionTrees( XN_NODE_TYPE_DEVICE, NULL, devicesList, 0 ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: " - << std::string(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: %s\n", xnGetStatusString(status)); return; } // Chose device according to index xn::NodeInfoList::Iterator it = devicesList.Begin(); - for( int i = 0; i < index && it!=devicesList.End(); ++i ) it++; + for( int i = 0; i < index && it!=devicesList.End(); ++i ) it++; if ( it == devicesList.End() ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed device with index " << index << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed device with index %d\n", index); return; } @@ -586,8 +583,7 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.CreateProductionTree( deviceNode, productionNode ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create production tree: " - << std::string(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create production tree: %s\n", xnGetStatusString(status)); return; } @@ -595,8 +591,7 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.RunXmlScript( XMLConfig.c_str(), scriptNode ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to run xml script: " - << std::string(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to run xml script: %s\n", xnGetStatusString(status)); return; } @@ -606,20 +601,18 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.EnumerateExistingNodes( depthList, XN_NODE_TYPE_DEPTH ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate depth generators: " - << std::string(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate depth generators: %s\n", xnGetStatusString(status)); return; } if( depthList.IsEmpty() ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : The device doesn't have depth generator. Such devices aren't supported now." << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : The device doesn't have depth generator. Such devices aren't supported now.\n"); return; } status = depthGenerator.Create( context ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create depth generator: " - << std::string(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create depth generator: %s\n", xnGetStatusString(status)); return; } @@ -628,8 +621,7 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.EnumerateExistingNodes( imageList, XN_NODE_TYPE_IMAGE ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate image generators: " - << std::string(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate image generators: %s\n", xnGetStatusString(status)); return; } @@ -638,8 +630,7 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = imageGenerator.Create( context ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create image generator: " - << std::string(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create image generator: %s\n", xnGetStatusString(status)); return; } } @@ -666,14 +657,13 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.StartGeneratingAll(); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to start generating OpenNI data: " - << std::string(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to start generating OpenNI data: %s\n", xnGetStatusString(status)); return; } if( !readCamerasParams() ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Could not read cameras parameters" << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Could not read cameras parameters\n"); return; } @@ -697,8 +687,7 @@ CvCapture_OpenNI::CvCapture_OpenNI(const char * filename) status = context.Init(); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to initialize the context: " - << std::string(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to initialize the context: %s\n", xnGetStatusString(status)); return; } @@ -706,8 +695,7 @@ CvCapture_OpenNI::CvCapture_OpenNI(const char * filename) status = context.OpenFileRecording( filename, productionNode ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to open input file (" << filename << "): " - << std::string(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to open input file (%s): %s\n", filename, xnGetStatusString(status)); return; } @@ -716,7 +704,7 @@ CvCapture_OpenNI::CvCapture_OpenNI(const char * filename) if( !readCamerasParams() ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Could not read cameras parameters" << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Could not read cameras parameters\n"); return; } @@ -736,7 +724,7 @@ bool CvCapture_OpenNI::readCamerasParams() XnDouble pixelSize = 0; if( depthGenerator.GetRealProperty( "ZPPS", pixelSize ) != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::readCamerasParams : Could not read pixel size!" << std::endl; + fprintf(stderr, "CvCapture_OpenNI::readCamerasParams : Could not read pixel size!\n"); return false; } @@ -747,13 +735,13 @@ bool CvCapture_OpenNI::readCamerasParams() XnUInt64 zeroPlanDistance; // in mm if( depthGenerator.GetIntProperty( "ZPD", zeroPlanDistance ) != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::readCamerasParams : Could not read virtual plane distance!" << std::endl; + fprintf(stderr, "CvCapture_OpenNI::readCamerasParams : Could not read virtual plane distance!\n"); return false; } if( depthGenerator.GetRealProperty( "LDDIS", baseline ) != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::readCamerasParams : Could not read base line!" << std::endl; + fprintf(stderr, "CvCapture_OpenNI::readCamerasParams : Could not read base line!\n"); return false; } @@ -765,13 +753,13 @@ bool CvCapture_OpenNI::readCamerasParams() if( depthGenerator.GetIntProperty( "ShadowValue", shadowValue ) != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::readCamerasParams : Could not read property \"ShadowValue\"!" << std::endl; + fprintf(stderr, "CvCapture_OpenNI::readCamerasParams : Could not read property \"ShadowValue\"!\n"); return false; } if( depthGenerator.GetIntProperty("NoSampleValue", noSampleValue ) != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::readCamerasParams : Could not read property \"NoSampleValue\"!" <setMaxTimeDuration(maxTimeDuration); break; default: - { - std::stringstream ss; - ss << "Such parameter (propIdx=" << propIdx << ") isn't supported for setting.\n"; - CV_Error( CV_StsBadArg, ss.str().c_str() ); - } + CV_Error( CV_StsBadArg, cv::format("Such parameter (propIdx=%d) isn't supported for setting.\n", propIdx) ); } return isSet; @@ -977,11 +957,7 @@ double CvCapture_OpenNI::getDepthGeneratorProperty( int propIdx ) propValue = depthGenerator.GetFrameID(); break; default : - { - std::stringstream ss; - ss << "Depth generator does not support such parameter (propIdx=" << propIdx << ") for getting.\n"; - CV_Error( CV_StsBadArg, ss.str().c_str() ); - } + CV_Error( CV_StsBadArg, cv::format("Depth generator does not support such parameter (propIdx=%d) for getting.\n", propIdx) ); } return propValue; @@ -1009,12 +985,12 @@ bool CvCapture_OpenNI::setDepthGeneratorProperty( int propIdx, double propValue { XnStatus status = depthGenerator.GetAlternativeViewPointCap().SetViewPoint(imageGenerator); if( status != XN_STATUS_OK ) - std::cerr << "CvCapture_OpenNI::setDepthGeneratorProperty : " << xnGetStatusString(status) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::setDepthGeneratorProperty : %s\n", xnGetStatusString(status)); else isSet = true; } else - std::cerr << "CvCapture_OpenNI::setDepthGeneratorProperty : Unsupported viewpoint." << std::endl; + fprintf(stderr, "CvCapture_OpenNI::setDepthGeneratorProperty : Unsupported viewpoint.\n"); } else isSet = true; @@ -1024,18 +1000,14 @@ bool CvCapture_OpenNI::setDepthGeneratorProperty( int propIdx, double propValue { XnStatus status = depthGenerator.GetAlternativeViewPointCap().ResetViewPoint(); if( status != XN_STATUS_OK ) - std::cerr << "CvCapture_OpenNI::setDepthGeneratorProperty : " << xnGetStatusString(status) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::setDepthGeneratorProperty : %s\n", xnGetStatusString(status)); else isSet = true; } } break; default: - { - std::stringstream ss; - ss << "Depth generator does not support such parameter (propIdx=" << propIdx << ") for setting.\n"; - CV_Error( CV_StsBadArg, ss.str().c_str() ); - } + CV_Error( CV_StsBadArg, cv::format("Depth generator does not support such parameter (propIdx=%d) for setting.\n", propIdx) ); } return isSet; @@ -1073,11 +1045,7 @@ double CvCapture_OpenNI::getImageGeneratorProperty( int propIdx ) propValue = imageGenerator.GetFrameID(); break; default : - { - std::stringstream ss; - ss << "Image generator does not support such parameter (propIdx=" << propIdx << ") for getting.\n"; - CV_Error( CV_StsBadArg, ss.str().c_str() ); - } + CV_Error( CV_StsBadArg, cv::format("Image generator does not support such parameter (propIdx=%d) for getting.\n", propIdx) ); } return propValue; @@ -1128,17 +1096,13 @@ bool CvCapture_OpenNI::setImageGeneratorProperty( int propIdx, double propValue XnStatus status = imageGenerator.SetMapOutputMode( mode ); if( status != XN_STATUS_OK ) - std::cerr << "CvCapture_OpenNI::setImageGeneratorProperty : " << xnGetStatusString(status) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::setImageGeneratorProperty : %s\n", xnGetStatusString(status)); else isSet = true; break; } default: - { - std::stringstream ss; - ss << "Image generator does not support such parameter (propIdx=" << propIdx << ") for setting.\n"; - CV_Error( CV_StsBadArg, ss.str().c_str() ); - } + CV_Error( CV_StsBadArg, cv::format("Image generator does not support such parameter (propIdx=%d) for setting.\n", propIdx) ); } return isSet; diff --git a/modules/highgui/src/cap_pvapi.cpp b/modules/highgui/src/cap_pvapi.cpp index 8d4a4a2b4..6ed3aea84 100644 --- a/modules/highgui/src/cap_pvapi.cpp +++ b/modules/highgui/src/cap_pvapi.cpp @@ -63,7 +63,6 @@ # include #endif -#include //#include #define MAX_CAMERAS 10 @@ -356,7 +355,7 @@ bool CvCaptureCAM_PvAPI::setProperty( int property_id, double value ) } else { - std::string ip=cv::format("%d.%d.%d.%d", ((int)value>>24)&255, ((int)value>>16)&255, ((int)value>>8)&255, (int)value&255); + cv::String ip=cv::format("%d.%d.%d.%d", ((int)value>>24)&255, ((int)value>>16)&255, ((int)value>>8)&255, (int)value&255); if ((PvAttrEnumSet(Camera.Handle,"MulticastEnable", "On")==ePvErrSuccess) && (PvAttrStringSet(Camera.Handle, "MulticastIPAddress", ip.c_str())==ePvErrSuccess)) break; diff --git a/modules/highgui/src/grfmt_base.cpp b/modules/highgui/src/grfmt_base.cpp index 0fe798ea8..267cb31b5 100644 --- a/modules/highgui/src/grfmt_base.cpp +++ b/modules/highgui/src/grfmt_base.cpp @@ -54,7 +54,7 @@ BaseImageDecoder::BaseImageDecoder() m_buf_supported = false; } -bool BaseImageDecoder::setSource( const std::string& filename ) +bool BaseImageDecoder::setSource( const String& filename ) { m_filename = filename; m_buf.release(); @@ -65,7 +65,7 @@ bool BaseImageDecoder::setSource( const Mat& buf ) { if( !m_buf_supported ) return false; - m_filename = std::string(); + m_filename = String(); m_buf = buf; return true; } @@ -75,7 +75,7 @@ size_t BaseImageDecoder::signatureLength() const return m_signature.size(); } -bool BaseImageDecoder::checkSignature( const std::string& signature ) const +bool BaseImageDecoder::checkSignature( const String& signature ) const { size_t len = signatureLength(); return signature.size() >= len && memcmp( signature.c_str(), m_signature.c_str(), len ) == 0; @@ -96,12 +96,12 @@ bool BaseImageEncoder::isFormatSupported( int depth ) const return depth == CV_8U; } -std::string BaseImageEncoder::getDescription() const +String BaseImageEncoder::getDescription() const { return m_description; } -bool BaseImageEncoder::setDestination( const std::string& filename ) +bool BaseImageEncoder::setDestination( const String& filename ) { m_filename = filename; m_buf = 0; @@ -114,7 +114,7 @@ bool BaseImageEncoder::setDestination( std::vector& buf ) return false; m_buf = &buf; m_buf->clear(); - m_filename = std::string(); + m_filename = String(); return true; } @@ -127,7 +127,7 @@ void BaseImageEncoder::throwOnEror() const { if(!m_last_error.empty()) { - std::string msg = "Raw image encoder error: " + m_last_error; + String msg = "Raw image encoder error: " + m_last_error; CV_Error( CV_BadImageSize, msg.c_str() ); } } diff --git a/modules/highgui/src/grfmt_base.hpp b/modules/highgui/src/grfmt_base.hpp index a97fa2919..f7fde90cf 100644 --- a/modules/highgui/src/grfmt_base.hpp +++ b/modules/highgui/src/grfmt_base.hpp @@ -65,21 +65,21 @@ public: int height() const { return m_height; }; virtual int type() const { return m_type; }; - virtual bool setSource( const std::string& filename ); + virtual bool setSource( const String& filename ); virtual bool setSource( const Mat& buf ); virtual bool readHeader() = 0; virtual bool readData( Mat& img ) = 0; virtual size_t signatureLength() const; - virtual bool checkSignature( const std::string& signature ) const; + virtual bool checkSignature( const String& signature ) const; virtual ImageDecoder newDecoder() const; protected: int m_width; // width of the image ( filled by readHeader ) int m_height; // height of the image ( filled by readHeader ) int m_type; - std::string m_filename; - std::string m_signature; + String m_filename; + String m_signature; Mat m_buf; bool m_buf_supported; }; @@ -93,23 +93,23 @@ public: virtual ~BaseImageEncoder() {}; virtual bool isFormatSupported( int depth ) const; - virtual bool setDestination( const std::string& filename ); + virtual bool setDestination( const String& filename ); virtual bool setDestination( std::vector& buf ); virtual bool write( const Mat& img, const std::vector& params ) = 0; - virtual std::string getDescription() const; + virtual String getDescription() const; virtual ImageEncoder newEncoder() const; virtual void throwOnEror() const; protected: - std::string m_description; + String m_description; - std::string m_filename; + String m_filename; std::vector* m_buf; bool m_buf_supported; - std::string m_last_error; + String m_last_error; }; } diff --git a/modules/highgui/src/grfmt_jpeg2000.cpp b/modules/highgui/src/grfmt_jpeg2000.cpp index e09eccc90..7be2c259b 100644 --- a/modules/highgui/src/grfmt_jpeg2000.cpp +++ b/modules/highgui/src/grfmt_jpeg2000.cpp @@ -82,7 +82,7 @@ static JasperInitializer initialize_jasper; Jpeg2KDecoder::Jpeg2KDecoder() { - m_signature = '\0' + std::string() + '\0' + std::string() + '\0' + std::string("\x0cjP \r\n\x87\n"); + m_signature = '\0' + String() + '\0' + String() + '\0' + String("\x0cjP \r\n\x87\n"); m_stream = 0; m_image = 0; } diff --git a/modules/highgui/src/grfmt_pxm.cpp b/modules/highgui/src/grfmt_pxm.cpp index c2eb100d7..0acf195dd 100644 --- a/modules/highgui/src/grfmt_pxm.cpp +++ b/modules/highgui/src/grfmt_pxm.cpp @@ -107,7 +107,7 @@ size_t PxMDecoder::signatureLength() const return 3; } -bool PxMDecoder::checkSignature( const std::string& signature ) const +bool PxMDecoder::checkSignature( const String& signature ) const { return signature.size() >= 3 && signature[0] == 'P' && '1' <= signature[1] && signature[1] <= '6' && diff --git a/modules/highgui/src/grfmt_pxm.hpp b/modules/highgui/src/grfmt_pxm.hpp index 59c669414..5460e1100 100644 --- a/modules/highgui/src/grfmt_pxm.hpp +++ b/modules/highgui/src/grfmt_pxm.hpp @@ -61,7 +61,7 @@ public: void close(); size_t signatureLength() const; - bool checkSignature( const std::string& signature ) const; + bool checkSignature( const String& signature ) const; ImageDecoder newDecoder() const; protected: diff --git a/modules/highgui/src/grfmt_tiff.cpp b/modules/highgui/src/grfmt_tiff.cpp index 35ab2f81a..a0d53f3db 100644 --- a/modules/highgui/src/grfmt_tiff.cpp +++ b/modules/highgui/src/grfmt_tiff.cpp @@ -94,7 +94,7 @@ size_t TiffDecoder::signatureLength() const return 4; } -bool TiffDecoder::checkSignature( const std::string& signature ) const +bool TiffDecoder::checkSignature( const String& signature ) const { return signature.size() >= 4 && (memcmp(signature.c_str(), fmtSignTiffII, 4) == 0 || diff --git a/modules/highgui/src/grfmt_tiff.hpp b/modules/highgui/src/grfmt_tiff.hpp index 3fa0ab497..d3745a9f8 100644 --- a/modules/highgui/src/grfmt_tiff.hpp +++ b/modules/highgui/src/grfmt_tiff.hpp @@ -102,7 +102,7 @@ public: void close(); size_t signatureLength() const; - bool checkSignature( const std::string& signature ) const; + bool checkSignature( const String& signature ) const; ImageDecoder newDecoder() const; protected: diff --git a/modules/highgui/src/grfmt_webp.cpp b/modules/highgui/src/grfmt_webp.cpp index 981e7a5eb..3db4369fe 100644 --- a/modules/highgui/src/grfmt_webp.cpp +++ b/modules/highgui/src/grfmt_webp.cpp @@ -71,7 +71,7 @@ ImageDecoder WebPDecoder::newDecoder() const return new WebPDecoder; } -bool WebPDecoder::checkSignature( const std::string& signature ) const +bool WebPDecoder::checkSignature( const String& signature ) const { size_t len = signatureLength(); bool ret = false; diff --git a/modules/highgui/src/grfmt_webp.hpp b/modules/highgui/src/grfmt_webp.hpp index 15033d120..f37e6e9f4 100644 --- a/modules/highgui/src/grfmt_webp.hpp +++ b/modules/highgui/src/grfmt_webp.hpp @@ -60,7 +60,7 @@ public: bool readData( Mat& img ); bool readHeader(); void close(); - bool checkSignature( const std::string& signature ) const; + bool checkSignature( const String& signature ) const; ImageDecoder newDecoder() const; diff --git a/modules/highgui/src/loadsave.cpp b/modules/highgui/src/loadsave.cpp index a27f3399d..a548df54d 100644 --- a/modules/highgui/src/loadsave.cpp +++ b/modules/highgui/src/loadsave.cpp @@ -96,7 +96,7 @@ struct ImageCodecInitializer static ImageCodecInitializer codecs; -static ImageDecoder findDecoder( const std::string& filename ) +static ImageDecoder findDecoder( const String& filename ) { size_t i, maxlen = 0; for( i = 0; i < codecs.decoders.size(); i++ ) @@ -108,8 +108,8 @@ static ImageDecoder findDecoder( const std::string& filename ) FILE* f= fopen( filename.c_str(), "rb" ); if( !f ) return ImageDecoder(); - std::string signature(maxlen, ' '); - maxlen = fread( &signature[0], 1, maxlen, f ); + String signature(maxlen, ' '); + maxlen = fread( (void*)signature.c_str(), 1, maxlen, f ); fclose(f); signature = signature.substr(0, maxlen); @@ -137,8 +137,8 @@ static ImageDecoder findDecoder( const Mat& buf ) size_t bufSize = buf.rows*buf.cols*buf.elemSize(); maxlen = std::min(maxlen, bufSize); - std::string signature(maxlen, ' '); - memcpy( &signature[0], buf.data, maxlen ); + String signature(maxlen, ' '); + memcpy( (void*)signature.c_str(), buf.data, maxlen ); for( i = 0; i < codecs.decoders.size(); i++ ) { @@ -149,7 +149,7 @@ static ImageDecoder findDecoder( const Mat& buf ) return ImageDecoder(); } -static ImageEncoder findEncoder( const std::string& _ext ) +static ImageEncoder findEncoder( const String& _ext ) { if( _ext.size() <= 1 ) return ImageEncoder(); @@ -163,7 +163,7 @@ static ImageEncoder findEncoder( const std::string& _ext ) for( size_t i = 0; i < codecs.encoders.size(); i++ ) { - std::string description = codecs.encoders[i]->getDescription(); + String description = codecs.encoders[i]->getDescription(); const char* descr = strchr( description.c_str(), '(' ); while( descr ) @@ -191,7 +191,7 @@ static ImageEncoder findEncoder( const std::string& _ext ) enum { LOAD_CVMAT=0, LOAD_IMAGE=1, LOAD_MAT=2 }; static void* -imread_( const std::string& filename, int flags, int hdrtype, Mat* mat=0 ) +imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 ) { IplImage* image = 0; CvMat *matrix = 0; @@ -253,14 +253,14 @@ imread_( const std::string& filename, int flags, int hdrtype, Mat* mat=0 ) hdrtype == LOAD_IMAGE ? (void*)image : (void*)mat; } -Mat imread( const std::string& filename, int flags ) +Mat imread( const String& filename, int flags ) { Mat img; imread_( filename, flags, LOAD_MAT, &img ); return img; } -static bool imwrite_( const std::string& filename, const Mat& image, +static bool imwrite_( const String& filename, const Mat& image, const std::vector& params, bool flipv ) { Mat temp; @@ -292,7 +292,7 @@ static bool imwrite_( const std::string& filename, const Mat& image, return code; } -bool imwrite( const std::string& filename, InputArray _img, +bool imwrite( const String& filename, InputArray _img, const std::vector& params ) { Mat img = _img.getMat(); @@ -306,7 +306,7 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 ) IplImage* image = 0; CvMat *matrix = 0; Mat temp, *data = &temp; - std::string filename; + String filename; ImageDecoder decoder = findDecoder(buf); if( decoder.empty() ) @@ -400,7 +400,7 @@ Mat imdecode( InputArray _buf, int flags, Mat* dst ) return *dst; } -bool imencode( const std::string& ext, InputArray _image, +bool imencode( const String& ext, InputArray _image, std::vector& buf, const std::vector& params ) { Mat image = _image.getMat(); @@ -429,7 +429,7 @@ bool imencode( const std::string& ext, InputArray _image, } else { - std::string filename = tempfile(); + String filename = tempfile(); code = encoder->setDestination(filename); CV_Assert( code ); diff --git a/modules/highgui/src/window.cpp b/modules/highgui/src/window.cpp index c89a0a514..5e499c28a 100644 --- a/modules/highgui/src/window.cpp +++ b/modules/highgui/src/window.cpp @@ -153,12 +153,12 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id) } } -void cv::namedWindow( const std::string& winname, int flags ) +void cv::namedWindow( const String& winname, int flags ) { cvNamedWindow( winname.c_str(), flags ); } -void cv::destroyWindow( const std::string& winname ) +void cv::destroyWindow( const String& winname ) { cvDestroyWindow( winname.c_str() ); } @@ -168,22 +168,22 @@ void cv::destroyAllWindows() cvDestroyAllWindows(); } -void cv::resizeWindow( const std::string& winname, int width, int height ) +void cv::resizeWindow( const String& winname, int width, int height ) { cvResizeWindow( winname.c_str(), width, height ); } -void cv::moveWindow( const std::string& winname, int x, int y ) +void cv::moveWindow( const String& winname, int x, int y ) { cvMoveWindow( winname.c_str(), x, y ); } -void cv::setWindowProperty(const std::string& winname, int prop_id, double prop_value) +void cv::setWindowProperty(const String& winname, int prop_id, double prop_value) { cvSetWindowProperty( winname.c_str(), prop_id, prop_value); } -double cv::getWindowProperty(const std::string& winname, int prop_id) +double cv::getWindowProperty(const String& winname, int prop_id) { return cvGetWindowProperty(winname.c_str(), prop_id); } @@ -193,7 +193,7 @@ int cv::waitKey(int delay) return cvWaitKey(delay); } -int cv::createTrackbar(const std::string& trackbarName, const std::string& winName, +int cv::createTrackbar(const String& trackbarName, const String& winName, int* value, int count, TrackbarCallback callback, void* userdata) { @@ -201,17 +201,17 @@ int cv::createTrackbar(const std::string& trackbarName, const std::string& winNa value, count, callback, userdata); } -void cv::setTrackbarPos( const std::string& trackbarName, const std::string& winName, int value ) +void cv::setTrackbarPos( const String& trackbarName, const String& winName, int value ) { cvSetTrackbarPos(trackbarName.c_str(), winName.c_str(), value ); } -int cv::getTrackbarPos( const std::string& trackbarName, const std::string& winName ) +int cv::getTrackbarPos( const String& trackbarName, const String& winName ) { return cvGetTrackbarPos(trackbarName.c_str(), winName.c_str()); } -void cv::setMouseCallback( const std::string& windowName, MouseCallback onMouse, void* param) +void cv::setMouseCallback( const String& windowName, MouseCallback onMouse, void* param) { cvSetMouseCallback(windowName.c_str(), onMouse, param); } @@ -223,17 +223,17 @@ int cv::startWindowThread() // OpenGL support -void cv::setOpenGlDrawCallback(const std::string& name, OpenGlDrawCallback callback, void* userdata) +void cv::setOpenGlDrawCallback(const String& name, OpenGlDrawCallback callback, void* userdata) { cvSetOpenGlDrawCallback(name.c_str(), callback, userdata); } -void cv::setOpenGlContext(const std::string& windowName) +void cv::setOpenGlContext(const String& windowName) { cvSetOpenGlContext(windowName.c_str()); } -void cv::updateWindow(const std::string& windowName) +void cv::updateWindow(const String& windowName) { cvUpdateWindow(windowName.c_str()); } @@ -241,9 +241,9 @@ void cv::updateWindow(const std::string& windowName) #ifdef HAVE_OPENGL namespace { - std::map wndTexs; - std::map ownWndTexs; - std::map ownWndBufs; + std::map wndTexs; + std::map ownWndTexs; + std::map ownWndBufs; void glDrawTextureCallback(void* userdata) { @@ -254,7 +254,7 @@ namespace } #endif // HAVE_OPENGL -void cv::imshow( const std::string& winname, InputArray _img ) +void cv::imshow( const String& winname, InputArray _img ) { #ifndef HAVE_OPENGL Mat img = _img.getMat(); @@ -342,23 +342,23 @@ CV_IMPL void cvUpdateWindow(const char*) #if defined (HAVE_QT) -CvFont cv::fontQt(const std::string& nameFont, int pointSize, Scalar color, int weight, int style, int /*spacing*/) +CvFont cv::fontQt(const String& nameFont, int pointSize, Scalar color, int weight, int style, int /*spacing*/) { return cvFontQt(nameFont.c_str(), pointSize,color,weight, style); } -void cv::addText( const Mat& img, const std::string& text, Point org, CvFont font) +void cv::addText( const Mat& img, const String& text, Point org, CvFont font) { CvMat _img = img; cvAddText( &_img, text.c_str(), org,&font); } -void cv::displayStatusBar(const std::string& name, const std::string& text, int delayms) +void cv::displayStatusBar(const String& name, const String& text, int delayms) { cvDisplayStatusBar(name.c_str(),text.c_str(), delayms); } -void cv::displayOverlay(const std::string& name, const std::string& text, int delayms) +void cv::displayOverlay(const String& name, const String& text, int delayms) { cvDisplayOverlay(name.c_str(),text.c_str(), delayms); } @@ -373,40 +373,40 @@ void cv::stopLoop() cvStopLoop(); } -void cv::saveWindowParameters(const std::string& windowName) +void cv::saveWindowParameters(const String& windowName) { cvSaveWindowParameters(windowName.c_str()); } -void cv::loadWindowParameters(const std::string& windowName) +void cv::loadWindowParameters(const String& windowName) { cvLoadWindowParameters(windowName.c_str()); } -int cv::createButton(const std::string& button_name, ButtonCallback on_change, void* userdata, int button_type , bool initial_button_state ) +int cv::createButton(const String& button_name, ButtonCallback on_change, void* userdata, int button_type , bool initial_button_state ) { return cvCreateButton(button_name.c_str(), on_change, userdata, button_type , initial_button_state ); } #else -CvFont cv::fontQt(const std::string&, int, Scalar, int, int, int) +CvFont cv::fontQt(const String&, int, Scalar, int, int, int) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); return CvFont(); } -void cv::addText( const Mat&, const std::string&, Point, CvFont) +void cv::addText( const Mat&, const String&, Point, CvFont) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); } -void cv::displayStatusBar(const std::string&, const std::string&, int) +void cv::displayStatusBar(const String&, const String&, int) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); } -void cv::displayOverlay(const std::string&, const std::string&, int ) +void cv::displayOverlay(const String&, const String&, int ) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); } @@ -422,17 +422,17 @@ void cv::stopLoop() CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); } -void cv::saveWindowParameters(const std::string&) +void cv::saveWindowParameters(const String&) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); } -void cv::loadWindowParameters(const std::string&) +void cv::loadWindowParameters(const String&) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); } -int cv::createButton(const std::string&, ButtonCallback, void*, int , bool ) +int cv::createButton(const String&, ButtonCallback, void*, int , bool ) { CV_Error(CV_StsNotImplemented, "The library is compiled without QT support"); return 0; diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index 50f2b9e78..7717bde54 100644 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -949,7 +949,7 @@ void GuiReceiver::showImage(QString name, void* arr) mat = cvGetMat(arr, &stub); cv::Mat im(mat); - cv::imshow(name.toStdString(), im); + cv::imshow(name.toUtf8().data(), im); } else { diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt index cf99226ee..694e960d2 100644 --- a/modules/java/CMakeLists.txt +++ b/modules/java/CMakeLists.txt @@ -272,6 +272,8 @@ endif(ANDROID) add_library(${the_module} SHARED ${handwrittren_h_sources} ${handwrittren_cpp_sources} ${generated_cpp_sources} ${copied_files} "${JAR_FILE}" "${JAR_FILE}.dephelper") +set_target_properties(${the_module} PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL) + if(BUILD_FAT_JAVA_LIB) set(__deps ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULES_BUILD}) list(REMOVE_ITEM __deps ${the_module} opencv_ts) diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index 030f6c897..7447be91d 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -285,13 +285,13 @@ type_dict = { "CvSlice" : { "j_type" : "Range", "jn_args" : (("int", ".start"), ("int", ".end")), "jni_var" : "Range %(n)s(%(n)s_start, %(n)s_end)", "jni_type" : "jdoubleArray", "suffix" : "II"}, - "string" : { "j_type" : "String", "jn_type" : "String", + "String" : { "j_type" : "String", "jn_type" : "String", "jni_type" : "jstring", "jni_name" : "n_%(n)s", - "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); std::string n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)', + "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); String n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)', "suffix" : "Ljava_lang_String_2"}, "c_string": { "j_type" : "String", "jn_type" : "String", "jni_type" : "jstring", "jni_name" : "n_%(n)s.c_str()", - "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); std::string n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)', + "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); String n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)', "suffix" : "Ljava_lang_String_2"}, "TermCriteria": { "j_type" : "TermCriteria", "jn_args" : (("int", ".type"), ("int", ".maxCount"), ("double", ".epsilon")), "jni_var" : "TermCriteria %(n)s(%(n)s_type, %(n)s_maxCount, %(n)s_epsilon)", "jni_type" : "jdoubleArray", @@ -417,7 +417,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual { 'j_code' : """ - // C++: Size getTextSize(const std::string& text, int fontFace, double fontScale, int thickness, int* baseLine); + // C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine); //javadoc:getTextSize(text, fontFace, fontScale, thickness, baseLine) public static Size getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine) { if(baseLine != null && baseLine.length != 1) @@ -430,7 +430,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual """ private static native double[] n_getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine);\n""", 'cpp_code' : """ -// C++: Size getTextSize(const std::string& text, int fontFace, double fontScale, int thickness, int* baseLine); +// C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine); JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize (JNIEnv*, jclass, jstring, jint, jdouble, jint, jintArray); JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize @@ -445,7 +445,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize } const char* utf_text = env->GetStringUTFChars(text, 0); - std::string n_text( utf_text ? utf_text : "" ); + String n_text( utf_text ? utf_text : "" ); env->ReleaseStringUTFChars(text, utf_text); int _baseLine; @@ -1196,7 +1196,7 @@ extern "C" { ret = "return (jlong) _retval_;" elif fi.ctype.startswith('vector'): # c-tor ret = "return (jlong) _retval_;" - elif fi.ctype == "string": + elif fi.ctype == "String": ret = "return env->NewStringUTF(_retval_.c_str());" default = 'return env->NewStringUTF("");' elif fi.ctype in self.classes: # wrapped class: @@ -1218,8 +1218,8 @@ extern "C" { retval = fi.ctype + " _retval_ = " if fi.ctype == "void": retval = "" - elif fi.ctype == "string": - retval = "std::" + retval + elif fi.ctype == "String": + retval = "cv::" + retval elif fi.ctype.startswith('vector'): retval = type_dict[fi.ctype]['jni_var'] % {"n" : '_ret_val_vector_'} + " = " c_epilogue.append("Mat* _retval_ = new Mat();") diff --git a/modules/java/generator/src/cpp/features2d_manual.hpp b/modules/java/generator/src/cpp/features2d_manual.hpp index 39fcafa2d..266bec46e 100644 --- a/modules/java/generator/src/cpp/features2d_manual.hpp +++ b/modules/java/generator/src/cpp/features2d_manual.hpp @@ -84,7 +84,7 @@ public: //not supported: SimpleBlob, Dense CV_WRAP static javaFeatureDetector* create( int detectorType ) { - std::string name; + String name; if (detectorType > DYNAMICDETECTOR) { name = "Dynamic"; @@ -104,37 +104,37 @@ public: switch(detectorType) { case FAST: - name += "FAST"; + name = name + "FAST"; break; case STAR: - name += "STAR"; + name = name + "STAR"; break; case SIFT: - name += "SIFT"; + name = name + "SIFT"; break; case SURF: - name += "SURF"; + name = name + "SURF"; break; case ORB: - name += "ORB"; + name = name + "ORB"; break; case MSER: - name += "MSER"; + name = name + "MSER"; break; case GFTT: - name += "GFTT"; + name = name + "GFTT"; break; case HARRIS: - name += "HARRIS"; + name = name + "HARRIS"; break; case SIMPLEBLOB: - name += "SimpleBlob"; + name = name + "SimpleBlob"; break; case DENSE: - name += "Dense"; + name = name + "Dense"; break; case BRISK: - name += "BRISK"; + name = name + "BRISK"; break; default: CV_Error( CV_StsBadArg, "Specified feature detector type is not supported." ); @@ -146,14 +146,14 @@ public: return (javaFeatureDetector*)((FeatureDetector*) detector); } - CV_WRAP void write( const std::string& fileName ) const + CV_WRAP void write( const String& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); ((FeatureDetector*)this)->write(fs); fs.release(); } - CV_WRAP void read( const std::string& fileName ) + CV_WRAP void read( const String& fileName ) { FileStorage fs(fileName, FileStorage::READ); ((FeatureDetector*)this)->read(fs.root()); @@ -208,7 +208,7 @@ public: //supported: FlannBased, BruteForce, BruteForce-L1, BruteForce-Hamming, BruteForce-HammingLUT CV_WRAP static javaDescriptorMatcher* create( int matcherType ) { - std::string name; + String name; switch(matcherType) { @@ -240,14 +240,14 @@ public: return (javaDescriptorMatcher*)((DescriptorMatcher*) matcher); } - CV_WRAP void write( const std::string& fileName ) const + CV_WRAP void write( const String& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); ((DescriptorMatcher*)this)->write(fs); fs.release(); } - CV_WRAP void read( const std::string& fileName ) + CV_WRAP void read( const String& fileName ) { FileStorage fs(fileName, FileStorage::READ); ((DescriptorMatcher*)this)->read(fs.root()); @@ -294,7 +294,7 @@ public: //not supported: Calonder CV_WRAP static javaDescriptorExtractor* create( int extractorType ) { - std::string name; + String name; if (extractorType > OPPONENTEXTRACTOR) { @@ -305,22 +305,22 @@ public: switch(extractorType) { case SIFT: - name += "SIFT"; + name = name + "SIFT"; break; case SURF: - name += "SURF"; + name = name + "SURF"; break; case ORB: - name += "ORB"; + name = name + "ORB"; break; case BRIEF: - name += "BRIEF"; + name = name + "BRIEF"; break; case BRISK: - name += "BRISK"; + name = name + "BRISK"; break; case FREAK: - name += "FREAK"; + name = name + "FREAK"; break; default: CV_Error( CV_StsBadArg, "Specified descriptor extractor type is not supported." ); @@ -332,14 +332,14 @@ public: return (javaDescriptorExtractor*)((DescriptorExtractor*) extractor); } - CV_WRAP void write( const std::string& fileName ) const + CV_WRAP void write( const String& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); ((DescriptorExtractor*)this)->write(fs); fs.release(); } - CV_WRAP void read( const std::string& fileName ) + CV_WRAP void read( const String& fileName ) { FileStorage fs(fileName, FileStorage::READ); ((DescriptorExtractor*)this)->read(fs.root()); @@ -401,7 +401,7 @@ public: //unsupported: Vector CV_WRAP static javaGenericDescriptorMatcher* create( int matcherType ) { - std::string name; + String name; switch(matcherType) { @@ -421,14 +421,14 @@ public: return (javaGenericDescriptorMatcher*)((GenericDescriptorMatcher*) matcher); } - CV_WRAP void write( const std::string& fileName ) const + CV_WRAP void write( const String& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); ((GenericDescriptorMatcher*)this)->write(fs); fs.release(); } - CV_WRAP void read( const std::string& fileName ) + CV_WRAP void read( const String& fileName ) { FileStorage fs(fileName, FileStorage::READ); ((GenericDescriptorMatcher*)this)->read(fs.root()); diff --git a/modules/legacy/doc/common_interfaces_of_descriptor_extractors.rst b/modules/legacy/doc/common_interfaces_of_descriptor_extractors.rst index dc5d81db3..f13f742f1 100644 --- a/modules/legacy/doc/common_interfaces_of_descriptor_extractors.rst +++ b/modules/legacy/doc/common_interfaces_of_descriptor_extractors.rst @@ -22,7 +22,7 @@ Wrapping class for computing descriptors by using the class CalonderDescriptorExtractor : public DescriptorExtractor { public: - CalonderDescriptorExtractor( const string& classifierFile ); + CalonderDescriptorExtractor( const String& classifierFile ); virtual void read( const FileNode &fn ); virtual void write( FileStorage &fs ) const; diff --git a/modules/legacy/doc/common_interfaces_of_generic_descriptor_matchers.rst b/modules/legacy/doc/common_interfaces_of_generic_descriptor_matchers.rst index a2abfa3e4..3c3835937 100644 --- a/modules/legacy/doc/common_interfaces_of_generic_descriptor_matchers.rst +++ b/modules/legacy/doc/common_interfaces_of_generic_descriptor_matchers.rst @@ -26,7 +26,7 @@ and finding the nearest closest descriptor to an input feature. :: const char* pca_hr_config = 0, const char* pca_desc_config = 0, int pyr_levels = 1, int pca_dim_high = 100, int pca_dim_low = 100); - OneWayDescriptorBase(CvSize patch_size, int pose_count, const string &pca_filename, const string &train_path = string(), const string &images_list = string(), + OneWayDescriptorBase(CvSize patch_size, int pose_count, const String &pca_filename, const String &train_path = String(), const String &images_list = String(), float _scale_min = 0.7f, float _scale_max=1.5f, float _scale_step=1.2f, int pyr_levels = 1, int pca_dim_high = 100, int pca_dim_low = 100); @@ -160,7 +160,7 @@ and finding the nearest closest descriptor to an input feature. :: void ConvertDescriptorsArrayToTree(); // Converting pca_descriptors array to KD tree // GetPCAFilename: get default PCA filename - static string GetPCAFilename () { return "pca.yml"; } + static String GetPCAFilename () { return "pca.yml"; } virtual bool empty() const { return m_train_feature_count <= 0 ? true : false; } @@ -190,16 +190,16 @@ Wrapping class for computing, matching, and classifying descriptors using the Params( int poseCount = POSE_COUNT, Size patchSize = Size(PATCH_WIDTH, PATCH_HEIGHT), - string pcaFilename = string(), - string trainPath = string(), string trainImagesList = string(), + String pcaFilename = String(), + String trainPath = String(), String trainImagesList = String(), float minScale = GET_MIN_SCALE(), float maxScale = GET_MAX_SCALE(), float stepScale = GET_STEP_SCALE() ); int poseCount; Size patchSize; - string pcaFilename; - string trainPath; - string trainImagesList; + String pcaFilename; + String trainPath; + String trainImagesList; float minScale, maxScale, stepScale; }; @@ -330,7 +330,7 @@ Wrapping class for computing, matching, and classifying descriptors using the int compressionMethod=FernClassifier::COMPRESSION_NONE, const PatchGenerator& patchGenerator=PatchGenerator() ); - Params( const string& filename ); + Params( const String& filename ); int nclasses; int patchSize; @@ -341,7 +341,7 @@ Wrapping class for computing, matching, and classifying descriptors using the int compressionMethod; PatchGenerator patchGenerator; - string filename; + String filename; }; FernDescriptorMatcher( const Params& params=Params() ); diff --git a/modules/legacy/include/opencv2/legacy.hpp b/modules/legacy/include/opencv2/legacy.hpp index 7b765b0c8..499566c05 100644 --- a/modules/legacy/include/opencv2/legacy.hpp +++ b/modules/legacy/include/opencv2/legacy.hpp @@ -1887,7 +1887,7 @@ public: void setVerbose(bool verbose); void read(const FileNode& node); - void write(FileStorage& fs, const std::string& name=std::string()) const; + void write(FileStorage& fs, const String& name=String()) const; int radius; int threshold; @@ -1918,7 +1918,7 @@ public: const PatchGenerator& patchGenerator=PatchGenerator()); virtual ~FernClassifier(); virtual void read(const FileNode& n); - virtual void write(FileStorage& fs, const std::string& name=std::string()) const; + virtual void write(FileStorage& fs, const String& name=String()) const; virtual void trainFromSingleView(const Mat& image, const std::vector& keypoints, int _patchSize=PATCH_SIZE, @@ -2062,8 +2062,8 @@ public: inline void applyQuantization(int num_quant_bits) { makePosteriors2(num_quant_bits); } // debug - void savePosteriors(std::string url, bool append=false); - void savePosteriors2(std::string url, bool append=false); + void savePosteriors(String url, bool append=false); + void savePosteriors2(String url, bool append=false); private: int classes_; @@ -2181,9 +2181,9 @@ public: void write(std::ostream &os) const; // experimental and debug - void saveAllFloatPosteriors(std::string file_url); - void saveAllBytePosteriors(std::string file_url); - void setFloatPosteriorsFromTextfile_176(std::string url); + void saveAllFloatPosteriors(String file_url); + void saveAllBytePosteriors(String file_url); + void setFloatPosteriorsFromTextfile_176(String url); float countZeroElements(); std::vector trees_; @@ -2356,7 +2356,7 @@ protected: CvAffinePose* m_affine_poses; // an array of poses CvMat** m_transforms; // an array of affine transforms corresponding to poses - std::string m_feature_name; // the name of the feature associated with the descriptor + String m_feature_name; // the name of the feature associated with the descriptor CvPoint m_center; // the coordinates of the feature (the center of the input image ROI) int m_pca_dim_high; // the number of descriptor pca components to use for generating affine poses @@ -2382,7 +2382,7 @@ public: const char* pca_hr_config = 0, const char* pca_desc_config = 0, int pyr_levels = 1, int pca_dim_high = 100, int pca_dim_low = 100); - OneWayDescriptorBase(CvSize patch_size, int pose_count, const std::string &pca_filename, const std::string &train_path = std::string(), const std::string &images_list = std::string(), + OneWayDescriptorBase(CvSize patch_size, int pose_count, const String &pca_filename, const String &train_path = String(), const String &images_list = String(), float _scale_min = 0.7f, float _scale_max=1.5f, float _scale_step=1.2f, int pyr_levels = 1, int pca_dim_high = 100, int pca_dim_low = 100); @@ -2516,7 +2516,7 @@ public: void ConvertDescriptorsArrayToTree(); // Converting pca_descriptors array to KD tree // GetPCAFilename: get default PCA filename - static std::string GetPCAFilename () { return "pca.yml"; } + static String GetPCAFilename () { return "pca.yml"; } virtual bool empty() const { return m_train_feature_count <= 0 ? true : false; } @@ -2568,8 +2568,8 @@ public: OneWayDescriptorObject(CvSize patch_size, int pose_count, const char* train_path, const char* pca_config, const char* pca_hr_config = 0, const char* pca_desc_config = 0, int pyr_levels = 1); - OneWayDescriptorObject(CvSize patch_size, int pose_count, const std::string &pca_filename, - const std::string &train_path = std::string (), const std::string &images_list = std::string (), + OneWayDescriptorObject(CvSize patch_size, int pose_count, const String &pca_filename, + const String &train_path = String (), const String &images_list = String (), float _scale_min = 0.7f, float _scale_max=1.5f, float _scale_step=1.2f, int pyr_levels = 1); @@ -2633,16 +2633,16 @@ public: Params( int poseCount = POSE_COUNT, Size patchSize = Size(PATCH_WIDTH, PATCH_HEIGHT), - std::string pcaFilename = std::string(), - std::string trainPath = std::string(), std::string trainImagesList = std::string(), + String pcaFilename = String(), + String trainPath = String(), String trainImagesList = String(), float minScale = GET_MIN_SCALE(), float maxScale = GET_MAX_SCALE(), float stepScale = GET_STEP_SCALE() ); int poseCount; Size patchSize; - std::string pcaFilename; - std::string trainPath; - std::string trainImagesList; + String pcaFilename; + String trainPath; + String trainImagesList; float minScale, maxScale, stepScale; }; @@ -2706,7 +2706,7 @@ public: int compressionMethod=FernClassifier::COMPRESSION_NONE, const PatchGenerator& patchGenerator=PatchGenerator() ); - Params( const std::string& filename ); + Params( const String& filename ); int nclasses; int patchSize; @@ -2717,7 +2717,7 @@ public: int compressionMethod; PatchGenerator patchGenerator; - std::string filename; + String filename; }; FernDescriptorMatcher( const Params& params=Params() ); @@ -2759,7 +2759,7 @@ template class CV_EXPORTS CalonderDescriptorExtractor : public DescriptorExtractor { public: - CalonderDescriptorExtractor( const std::string& classifierFile ); + CalonderDescriptorExtractor( const String& classifierFile ); virtual void read( const FileNode &fn ); virtual void write( FileStorage &fs ) const; @@ -2777,7 +2777,7 @@ protected: }; template -CalonderDescriptorExtractor::CalonderDescriptorExtractor(const std::string& classifier_file) +CalonderDescriptorExtractor::CalonderDescriptorExtractor(const String& classifier_file) { classifier_.read( classifier_file.c_str() ); } @@ -2867,7 +2867,7 @@ public: void setVerbose(bool verbose); void read(const FileNode& node); - void write(FileStorage& fs, const std::string& name=std::string()) const; + void write(FileStorage& fs, const String& name=String()) const; bool operator()(const Mat& image, CV_OUT Mat& H, CV_OUT std::vector& corners) const; bool operator()(const std::vector& pyr, const std::vector& keypoints, CV_OUT Mat& H, CV_OUT std::vector& corners, diff --git a/modules/legacy/src/calonder.cpp b/modules/legacy/src/calonder.cpp index 73f274862..f062f74ad 100644 --- a/modules/legacy/src/calonder.cpp +++ b/modules/legacy/src/calonder.cpp @@ -626,7 +626,7 @@ void RandomizedTree::write(std::ostream &os) const } -void RandomizedTree::savePosteriors(std::string url, bool append) +void RandomizedTree::savePosteriors(String url, bool append) { std::ofstream file(url.c_str(), (append?std::ios::app:std::ios::out)); for (int i=0; iwrite(os); } -void RTreeClassifier::saveAllFloatPosteriors(std::string url) +void RTreeClassifier::saveAllFloatPosteriors(String url) { printf("[DEBUG] writing all float posteriors to %s...\n", url.c_str()); for (int i=0; i<(int)trees_.size(); ++i) @@ -923,7 +923,7 @@ void RTreeClassifier::saveAllFloatPosteriors(std::string url) printf("[DEBUG] done\n"); } -void RTreeClassifier::saveAllBytePosteriors(std::string url) +void RTreeClassifier::saveAllBytePosteriors(String url) { printf("[DEBUG] writing all byte posteriors to %s...\n", url.c_str()); for (int i=0; i<(int)trees_.size(); ++i) @@ -932,7 +932,7 @@ void RTreeClassifier::saveAllBytePosteriors(std::string url) } -void RTreeClassifier::setFloatPosteriorsFromTextfile_176(std::string url) +void RTreeClassifier::setFloatPosteriorsFromTextfile_176(String url) { std::ifstream ifs(url.c_str()); diff --git a/modules/legacy/src/oneway.cpp b/modules/legacy/src/oneway.cpp index eae17a5d4..c7bb51336 100644 --- a/modules/legacy/src/oneway.cpp +++ b/modules/legacy/src/oneway.cpp @@ -465,7 +465,7 @@ namespace cv{ void OneWayDescriptor::Initialize(int pose_count, IplImage* frontal, const char* feature_name, int norm) { - m_feature_name = std::string(feature_name); + m_feature_name = String(feature_name); CvRect roi = cvGetImageROI(frontal); m_center = rect_center(roi); @@ -482,7 +482,7 @@ namespace cv{ Initialize(pose_count, frontal, feature_name, 1); return; } - m_feature_name = std::string(feature_name); + m_feature_name = String(feature_name); CvRect roi = cvGetImageROI(frontal); m_center = rect_center(roi); @@ -1287,8 +1287,8 @@ namespace cv{ } - OneWayDescriptorBase::OneWayDescriptorBase(CvSize patch_size, int pose_count, const std::string &pca_filename, - const std::string &train_path, const std::string &images_list, float _scale_min, float _scale_max, + OneWayDescriptorBase::OneWayDescriptorBase(CvSize patch_size, int pose_count, const String &pca_filename, + const String &train_path, const String &images_list, float _scale_min, float _scale_max, float _scale_step, int pyr_levels, int pca_dim_high, int pca_dim_low) : m_pca_dim_high(pca_dim_high), m_pca_dim_low(pca_dim_low), scale_min(_scale_min), scale_max(_scale_max), scale_step(_scale_step) @@ -2080,8 +2080,8 @@ namespace cv{ m_part_id = 0; } - OneWayDescriptorObject::OneWayDescriptorObject(CvSize patch_size, int pose_count, const std::string &pca_filename, - const std::string &train_path, const std::string &images_list, float _scale_min, float _scale_max, float _scale_step, int pyr_levels) : + OneWayDescriptorObject::OneWayDescriptorObject(CvSize patch_size, int pose_count, const String &pca_filename, + const String &train_path, const String &images_list, float _scale_min, float _scale_max, float _scale_step, int pyr_levels) : OneWayDescriptorBase(patch_size, pose_count, pca_filename, train_path, images_list, _scale_min, _scale_max, _scale_step, pyr_levels) { m_part_id = 0; @@ -2145,7 +2145,7 @@ namespace cv{ void readPCAFeatures(const FileNode &fn, CvMat** avg, CvMat** eigenvectors, const char* postfix) { - std::string str = std::string ("avg") + postfix; + String str = String ("avg") + postfix; CvMat* _avg = reinterpret_cast (fn[str].readObj()); if (_avg != 0) { @@ -2153,7 +2153,7 @@ namespace cv{ cvReleaseMat(&_avg); } - str = std::string ("eigenvectors") + postfix; + str = String ("eigenvectors") + postfix; CvMat* _eigenvectors = reinterpret_cast (fn[str].readObj()); if (_eigenvectors != 0) { @@ -2166,8 +2166,8 @@ namespace cv{ * OneWayDescriptorMatcher * \****************************************************************************************/ - OneWayDescriptorMatcher::Params::Params( int _poseCount, Size _patchSize, std::string _pcaFilename, - std::string _trainPath, std::string _trainImagesList, + OneWayDescriptorMatcher::Params::Params( int _poseCount, Size _patchSize, String _pcaFilename, + String _trainPath, String _trainImagesList, float _minScale, float _maxScale, float _stepScale ) : poseCount(_poseCount), patchSize(_patchSize), pcaFilename(_pcaFilename), trainPath(_trainPath), trainImagesList(_trainImagesList), @@ -2271,7 +2271,7 @@ namespace cv{ void OneWayDescriptorMatcher::read( const FileNode &fn ) { - base = new OneWayDescriptorObject( params.patchSize, params.poseCount, std::string (), std::string (), std::string (), + base = new OneWayDescriptorObject( params.patchSize, params.poseCount, String (), String (), String (), params.minScale, params.maxScale, params.stepScale ); base->Read (fn); } diff --git a/modules/legacy/src/planardetect.cpp b/modules/legacy/src/planardetect.cpp index 6c5e96ff8..ce0572013 100644 --- a/modules/legacy/src/planardetect.cpp +++ b/modules/legacy/src/planardetect.cpp @@ -617,7 +617,7 @@ void LDetector::read(const FileNode& objnode) clusteringDistance = (int)objnode["clustering-distance"]; } -void LDetector::write(FileStorage& fs, const std::string& name) const +void LDetector::write(FileStorage& fs, const String& name) const { WriteStructContext ws(fs, name, CV_NODE_MAP); @@ -707,7 +707,7 @@ FernClassifier::FernClassifier(const std::vector >& points, } -void FernClassifier::write(FileStorage& fs, const std::string& objname) const +void FernClassifier::write(FileStorage& fs, const String& objname) const { WriteStructContext ws(fs, objname, CV_NODE_MAP); @@ -1228,7 +1228,7 @@ nstructs(_nstructs), structSize(_structSize), nviews(_nviews), compressionMethod(_compressionMethod), patchGenerator(_patchGenerator) {} -FernDescriptorMatcher::Params::Params( const std::string& _filename ) +FernDescriptorMatcher::Params::Params( const String& _filename ) { filename = _filename; } @@ -1476,7 +1476,7 @@ void PlanarObjectDetector::read(const FileNode& node) } -void PlanarObjectDetector::write(FileStorage& fs, const std::string& objname) const +void PlanarObjectDetector::write(FileStorage& fs, const String& objname) const { WriteStructContext ws(fs, objname, CV_NODE_MAP); diff --git a/modules/legacy/test/test_stereomatching.cpp b/modules/legacy/test/test_stereomatching.cpp index a6524bb71..726224984 100644 --- a/modules/legacy/test/test_stereomatching.cpp +++ b/modules/legacy/test/test_stereomatching.cpp @@ -593,10 +593,10 @@ int CV_StereoMatchingTest::readDatasetsParams( FileStorage& fs ) assert(fn.isSeq()); for( int i = 0; i < (int)fn.size(); i+=3 ) { - string nm = fn[i]; + String nm = fn[i]; DatasetParams params; - string sf = fn[i+1]; params.dispScaleFactor = atoi(sf.c_str()); - string uv = fn[i+2]; params.dispUnknVal = atoi(uv.c_str()); + String sf = fn[i+1]; params.dispScaleFactor = atoi(sf.c_str()); + String uv = fn[i+2]; params.dispUnknVal = atoi(uv.c_str()); datasetsParams[nm] = params; } return cvtest::TS::OK; @@ -684,10 +684,10 @@ protected: assert(fn.isSeq()); for( int i = 0; i < (int)fn.size(); i+=4 ) { - string caseName = fn[i], datasetName = fn[i+1]; + String caseName = fn[i], datasetName = fn[i+1]; RunParams params; - string ndisp = fn[i+2]; params.ndisp = atoi(ndisp.c_str()); - string iterCount = fn[i+3]; params.iterCount = atoi(iterCount.c_str()); + String ndisp = fn[i+2]; params.ndisp = atoi(ndisp.c_str()); + String iterCount = fn[i+3]; params.iterCount = atoi(iterCount.c_str()); caseNames.push_back( caseName ); caseDatasets.push_back( datasetName ); caseRunParams.push_back( params ); diff --git a/modules/ml/doc/mldata.rst b/modules/ml/doc/mldata.rst index bae342e49..c3092d149 100644 --- a/modules/ml/doc/mldata.rst +++ b/modules/ml/doc/mldata.rst @@ -48,7 +48,7 @@ Class for loading the data from a ``.csv`` file. void set_miss_ch( char ch ); char get_miss_ch() const; - const std::map& get_class_labels_map() const; + const std::map& get_class_labels_map() const; protected: ... @@ -245,7 +245,7 @@ CvMLData::get_class_labels_map ------------------------------- Returns a map that converts strings to labels. -.. ocv:function:: const std::map& CvMLData::get_class_labels_map() const +.. ocv:function:: const std::map& CvMLData::get_class_labels_map() const The method returns a map that converts string class labels to the numerical class labels. It can be used to get an original class label as in a file. diff --git a/modules/ml/include/opencv2/ml.hpp b/modules/ml/include/opencv2/ml.hpp index d1812c2a0..5c1591a7e 100644 --- a/modules/ml/include/opencv2/ml.hpp +++ b/modules/ml/include/opencv2/ml.hpp @@ -47,7 +47,6 @@ #ifdef __cplusplus #include -#include #include // Apple defines a check() macro somewhere in the debug headers @@ -1043,7 +1042,7 @@ public: CvForestTree* get_tree(int i) const; protected: - virtual std::string getName() const; + virtual cv::String getName() const; virtual bool grow_forest( const CvTermCriteria term_crit ); @@ -1115,7 +1114,7 @@ public: CvRTParams params=CvRTParams()); virtual bool train( CvMLData* data, CvRTParams params=CvRTParams() ); protected: - virtual std::string getName() const; + virtual cv::String getName() const; virtual bool grow_forest( const CvTermCriteria term_crit ); }; @@ -2072,7 +2071,7 @@ public: void set_miss_ch( char ch ); char get_miss_ch() const; - const std::map& get_class_labels_map() const; + const std::map& get_class_labels_map() const; protected: virtual void clear(); @@ -2101,7 +2100,7 @@ protected: bool mix; int total_class_count; - std::map class_map; + std::map class_map; CvMat* train_sample_idx; CvMat* test_sample_idx; diff --git a/modules/ml/src/data.cpp b/modules/ml/src/data.cpp index 7d9cceac4..f4e401cb8 100644 --- a/modules/ml/src/data.cpp +++ b/modules/ml/src/data.cpp @@ -285,7 +285,7 @@ const CvMat* CvMLData::get_missing() const return missing; } -const std::map& CvMLData::get_class_labels_map() const +const std::map& CvMLData::get_class_labels_map() const { return class_map; } diff --git a/modules/ml/src/ertrees.cpp b/modules/ml/src/ertrees.cpp index 31d20398a..8b7091c33 100644 --- a/modules/ml/src/ertrees.cpp +++ b/modules/ml/src/ertrees.cpp @@ -1537,7 +1537,7 @@ CvERTrees::~CvERTrees() { } -std::string CvERTrees::getName() const +cv::String CvERTrees::getName() const { return CV_TYPE_NAME_ML_ERTREES; } diff --git a/modules/ml/src/gbt.cpp b/modules/ml/src/gbt.cpp index a409b7ab3..04e7a0fe3 100644 --- a/modules/ml/src/gbt.cpp +++ b/modules/ml/src/gbt.cpp @@ -1117,7 +1117,7 @@ void CvGBTrees::write( CvFileStorage* fs, const char* name ) const CvSeqReader reader; int i; - std::string s; + cv::String s; cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_ML_GBT ); @@ -1167,7 +1167,7 @@ void CvGBTrees::read( CvFileStorage* fs, CvFileNode* node ) CvFileNode* trees_fnode; CvMemStorage* storage; int i, ntrees; - std::string s; + cv::String s; clear(); read_params( fs, node ); diff --git a/modules/ml/src/precomp.hpp b/modules/ml/src/precomp.hpp index c18024465..281ff11af 100644 --- a/modules/ml/src/precomp.hpp +++ b/modules/ml/src/precomp.hpp @@ -45,6 +45,7 @@ #include "cvconfig.h" #endif +#include "opencv2/core.hpp" #include "opencv2/ml.hpp" #include "opencv2/core/core_c.h" #include "opencv2/core/utility.hpp" diff --git a/modules/ml/src/rtrees.cpp b/modules/ml/src/rtrees.cpp index d88611bef..8e287864a 100644 --- a/modules/ml/src/rtrees.cpp +++ b/modules/ml/src/rtrees.cpp @@ -246,7 +246,7 @@ CvRTrees::~CvRTrees() clear(); } -std::string CvRTrees::getName() const +cv::String CvRTrees::getName() const { return CV_TYPE_NAME_ML_RTREES; } @@ -730,7 +730,7 @@ void CvRTrees::write( CvFileStorage* fs, const char* name ) const if( ntrees < 1 || !trees || nsamples < 1 ) CV_Error( CV_StsBadArg, "Invalid CvRTrees object" ); - std::string modelNodeName = this->getName(); + cv::String modelNodeName = this->getName(); cvStartWriteStruct( fs, name, CV_NODE_MAP, modelNodeName.c_str() ); cvWriteInt( fs, "nclasses", nclasses ); diff --git a/modules/ml/src/svm.cpp b/modules/ml/src/svm.cpp index 76e0c41bc..47fc6c354 100644 --- a/modules/ml/src/svm.cpp +++ b/modules/ml/src/svm.cpp @@ -1924,7 +1924,7 @@ bool CvSVM::train_auto( const CvMat* _train_data, const CvMat* _responses, qsort(ratios, k_fold, sizeof(ratios[0]), icvCmpIndexedratio); double old_dist = 0.0; for (int k=0; k 0.0) @@ -1941,7 +1941,7 @@ bool CvSVM::train_auto( const CvMat* _train_data, const CvMat* _responses, qsort(ratios, k_fold, sizeof(ratios[0]), icvCmpIndexedratio); new_dist = 0.0; for (int k=0; k *resp // 4. em // 5. ann -int str_to_ann_train_method( string& str ) +int str_to_ann_train_method( String& str ) { if( !str.compare("BACKPROP") ) return CvANN_MLP_TrainParams::BACKPROP; @@ -412,7 +412,7 @@ float ann_calc_error( CvANN_MLP* ann, CvMLData* _data, map& cls_map, i // 6. dtree // 7. boost -int str_to_boost_type( string& str ) +int str_to_boost_type( String& str ) { if ( !str.compare("DISCRETE") ) return CvBoost::DISCRETE; @@ -546,7 +546,7 @@ void CV_MLBaseTest::run( int ) int CV_MLBaseTest::prepare_test_case( int test_case_idx ) { int trainSampleCount, respIdx; - string varTypes; + String varTypes; clear(); string dataPath = ts->get_data_path(); @@ -605,7 +605,7 @@ int CV_MLBaseTest::train( int testCaseIdx ) } else if( !modelName.compare(CV_SVM) ) { - string svm_type_str, kernel_type_str; + String svm_type_str, kernel_type_str; modelParamsNode["svm_type"] >> svm_type_str; modelParamsNode["kernel_type"] >> kernel_type_str; CvSVMParams params; @@ -625,7 +625,7 @@ int CV_MLBaseTest::train( int testCaseIdx ) } else if( !modelName.compare(CV_ANN) ) { - string train_method_str; + String train_method_str; double param1, param2; modelParamsNode["train_method"] >> train_method_str; modelParamsNode["param1"] >> param1; @@ -659,7 +659,7 @@ int CV_MLBaseTest::train( int testCaseIdx ) int BOOST_TYPE, WEAK_COUNT, MAX_DEPTH; float WEIGHT_TRIM_RATE; bool USE_SURROGATE; - string typeStr; + String typeStr; modelParamsNode["type"] >> typeStr; BOOST_TYPE = str_to_boost_type( typeStr ); modelParamsNode["weak_count"] >> WEAK_COUNT; diff --git a/modules/nonfree/src/surf.ocl.cpp b/modules/nonfree/src/surf.ocl.cpp index 420a5f6ae..b08f9ec7b 100644 --- a/modules/nonfree/src/surf.ocl.cpp +++ b/modules/nonfree/src/surf.ocl.cpp @@ -58,7 +58,7 @@ namespace cv const char* noImage2dOption = "-D DISABLE_IMAGE2D"; - static void openCLExecuteKernelSURF(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3], + static void openCLExecuteKernelSURF(Context *clCxt , const char **source, String kernelName, size_t globalThreads[3], size_t localThreads[3], std::vector< std::pair > &args, int channels, int depth) { if(support_image2d()) @@ -480,7 +480,7 @@ void SURF_OCL_Invoker::icvCalcLayerDetAndTrace_gpu(oclMat &det, oclMat &trace, i const int max_samples_j = 1 + ((img_cols - min_size) >> octave); Context *clCxt = det.clCxt; - std::string kernelName = "icvCalcLayerDetAndTrace"; + String kernelName = "icvCalcLayerDetAndTrace"; std::vector< std::pair > args; if(sumTex) @@ -518,7 +518,7 @@ void SURF_OCL_Invoker::icvFindMaximaInLayer_gpu(const oclMat &det, const oclMat const int min_margin = ((calcSize(octave, 2) >> 1) >> octave) + 1; Context *clCxt = det.clCxt; - std::string kernelName = use_mask ? "icvFindMaximaInLayer_withmask" : "icvFindMaximaInLayer"; + String kernelName = use_mask ? "icvFindMaximaInLayer_withmask" : "icvFindMaximaInLayer"; std::vector< std::pair > args; args.push_back( std::make_pair( sizeof(cl_mem), (void *)&det.data)); @@ -562,7 +562,7 @@ void SURF_OCL_Invoker::icvInterpolateKeypoint_gpu(const oclMat &det, const oclMa oclMat &keypoints, oclMat &counters_, int octave, int layer_rows, int max_features) { Context *clCxt = det.clCxt; - std::string kernelName = "icvInterpolateKeypoint"; + String kernelName = "icvInterpolateKeypoint"; std::vector< std::pair > args; args.push_back( std::make_pair( sizeof(cl_mem), (void *)&det.data)); @@ -586,7 +586,7 @@ void SURF_OCL_Invoker::icvInterpolateKeypoint_gpu(const oclMat &det, const oclMa void SURF_OCL_Invoker::icvCalcOrientation_gpu(const oclMat &keypoints, int nFeatures) { Context *clCxt = counters.clCxt; - std::string kernelName = "icvCalcOrientation"; + String kernelName = "icvCalcOrientation"; std::vector< std::pair > args; @@ -613,7 +613,7 @@ void SURF_OCL_Invoker::icvCalcOrientation_gpu(const oclMat &keypoints, int nFeat void SURF_OCL_Invoker::icvSetUpright_gpu(const oclMat &keypoints, int nFeatures) { Context *clCxt = counters.clCxt; - std::string kernelName = "icvSetUpright"; + String kernelName = "icvSetUpright"; std::vector< std::pair > args; @@ -632,7 +632,7 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const { // compute unnormalized descriptors, then normalize them - odd indexing since grid must be 2D Context *clCxt = descriptors.clCxt; - std::string kernelName; + String kernelName; std::vector< std::pair > args; size_t localThreads[3] = {1, 1, 1}; size_t globalThreads[3] = {1, 1, 1}; diff --git a/modules/objdetect/doc/cascade_classification.rst b/modules/objdetect/doc/cascade_classification.rst index 60b9a2696..2809ab32b 100644 --- a/modules/objdetect/doc/cascade_classification.rst +++ b/modules/objdetect/doc/cascade_classification.rst @@ -146,7 +146,7 @@ CascadeClassifier::CascadeClassifier ---------------------------------------- Loads a classifier from a file. -.. ocv:function:: CascadeClassifier::CascadeClassifier(const string& filename) +.. ocv:function:: CascadeClassifier::CascadeClassifier(const String& filename) .. ocv:pyfunction:: cv2.CascadeClassifier([filename]) -> @@ -167,7 +167,7 @@ CascadeClassifier::load --------------------------- Loads a classifier from a file. -.. ocv:function:: bool CascadeClassifier::load(const string& filename) +.. ocv:function:: bool CascadeClassifier::load(const String& filename) .. ocv:pyfunction:: cv2.CascadeClassifier.load(filename) -> retval diff --git a/modules/objdetect/doc/latent_svm.rst b/modules/objdetect/doc/latent_svm.rst index 86fb0edc1..8362dfb11 100644 --- a/modules/objdetect/doc/latent_svm.rst +++ b/modules/objdetect/doc/latent_svm.rst @@ -204,7 +204,7 @@ Two types of constructors. .. ocv:function:: LatentSvmDetector::LatentSvmDetector() -.. ocv:function:: LatentSvmDetector::LatentSvmDetector(const vector& filenames, const vector& classNames=vector()) +.. ocv:function:: LatentSvmDetector::LatentSvmDetector(const vector& filenames, const vector& classNames=vector()) @@ -228,7 +228,7 @@ LatentSvmDetector::load ----------------------- Load the trained models from given ``.xml`` files and return ``true`` if at least one model was loaded. -.. ocv:function:: bool LatentSvmDetector::load( const vector& filenames, const vector& classNames=vector() ) +.. ocv:function:: bool LatentSvmDetector::load( const vector& filenames, const vector& classNames=vector() ) :param filenames: A set of filenames storing the trained detectors (models). Each file contains one model. See examples of such files here /opencv_extra/testdata/cv/latentsvmdetector/models_VOC2007/. @@ -250,7 +250,7 @@ LatentSvmDetector::getClassNames -------------------------------- Return the class (model) names that were passed in constructor or method ``load`` or extracted from models filenames in those methods. -.. ocv:function:: const vector& LatentSvmDetector::getClassNames() const +.. ocv:function:: const vector& LatentSvmDetector::getClassNames() const LatentSvmDetector::getClassCount -------------------------------- diff --git a/modules/objdetect/include/opencv2/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect.hpp index a8c2955e1..c2ba8cedf 100644 --- a/modules/objdetect/include/opencv2/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect.hpp @@ -307,24 +307,24 @@ public: }; LatentSvmDetector(); - LatentSvmDetector( const std::vector& filenames, const std::vector& classNames=std::vector() ); + LatentSvmDetector( const std::vector& filenames, const std::vector& classNames=std::vector() ); virtual ~LatentSvmDetector(); virtual void clear(); virtual bool empty() const; - bool load( const std::vector& filenames, const std::vector& classNames=std::vector() ); + bool load( const std::vector& filenames, const std::vector& classNames=std::vector() ); virtual void detect( const Mat& image, std::vector& objectDetections, float overlapThreshold=0.5f, int numThreads=-1 ); - const std::vector& getClassNames() const; + const std::vector& getClassNames() const; size_t getClassCount() const; private: std::vector detectors; - std::vector classNames; + std::vector classNames; }; CV_EXPORTS void groupRectangles(CV_OUT CV_IN_OUT std::vector& rectList, int groupThreshold, double eps=0.2); @@ -369,11 +369,11 @@ class CV_EXPORTS_W CascadeClassifier { public: CV_WRAP CascadeClassifier(); - CV_WRAP CascadeClassifier( const std::string& filename ); + CV_WRAP CascadeClassifier( const String& filename ); virtual ~CascadeClassifier(); CV_WRAP virtual bool empty() const; - CV_WRAP bool load( const std::string& filename ); + CV_WRAP bool load( const String& filename ); virtual bool read( const FileNode& node ); CV_WRAP virtual void detectMultiScale( const Mat& image, CV_OUT std::vector& objects, @@ -524,7 +524,7 @@ public: gammaCorrection(_gammaCorrection), nlevels(_nlevels) {} - CV_WRAP HOGDescriptor(const std::string& filename) + CV_WRAP HOGDescriptor(const String& filename) { load(filename); } @@ -543,10 +543,10 @@ public: CV_WRAP virtual void setSVMDetector(InputArray _svmdetector); virtual bool read(FileNode& fn); - virtual void write(FileStorage& fs, const std::string& objname) const; + virtual void write(FileStorage& fs, const String& objname) const; - CV_WRAP virtual bool load(const std::string& filename, const std::string& objname=std::string()); - CV_WRAP virtual void save(const std::string& filename, const std::string& objname=std::string()) const; + CV_WRAP virtual bool load(const String& filename, const String& objname=String()); + CV_WRAP virtual void save(const String& filename, const String& objname=String()) const; virtual void copyTo(HOGDescriptor& c) const; CV_WRAP virtual void compute(const Mat& img, @@ -609,16 +609,16 @@ public: int groupThreshold = 0) const; // read/parse Dalal's alt model file - void readALTModel(std::string modelfile); + void readALTModel(String modelfile); }; CV_EXPORTS_W void findDataMatrix(InputArray image, - CV_OUT std::vector& codes, + CV_OUT std::vector& codes, OutputArray corners=noArray(), OutputArrayOfArrays dmtx=noArray()); CV_EXPORTS_W void drawDataMatrixCodes(InputOutputArray image, - const std::vector& codes, + const std::vector& codes, InputArray corners); } @@ -758,7 +758,7 @@ public: return processImpl(src, mask); } - virtual std::string name() const =0; + virtual String name() const =0; virtual void read(const FileNode& fn) =0; virtual void write(FileStorage& fs) const =0; @@ -770,7 +770,7 @@ public: * - "ColorGradient" * - "DepthNormal" */ - static Ptr create(const std::string& modality_type); + static Ptr create(const String& modality_type); /** * \brief Load a modality from file. @@ -804,7 +804,7 @@ public: */ ColorGradient(float weak_threshold, size_t num_features, float strong_threshold); - virtual std::string name() const; + virtual String name() const; virtual void read(const FileNode& fn); virtual void write(FileStorage& fs) const; @@ -842,7 +842,7 @@ public: DepthNormal(int distance_threshold, int difference_threshold, size_t num_features, int extract_threshold); - virtual std::string name() const; + virtual String name() const; virtual void read(const FileNode& fn); virtual void write(FileStorage& fs) const; @@ -871,7 +871,7 @@ struct CV_EXPORTS Match { } - Match(int x, int y, float similarity, const std::string& class_id, int template_id); + Match(int x, int y, float similarity, const String& class_id, int template_id); /// Sort matches with high similarity to the front bool operator<(const Match& rhs) const @@ -891,11 +891,11 @@ struct CV_EXPORTS Match int x; int y; float similarity; - std::string class_id; + String class_id; int template_id; }; -inline Match::Match(int _x, int _y, float _similarity, const std::string& _class_id, int _template_id) +inline Match::Match(int _x, int _y, float _similarity, const String& _class_id, int _template_id) : x(_x), y(_y), similarity(_similarity), class_id(_class_id), template_id(_template_id) { } @@ -937,7 +937,7 @@ public: * empty or the same size as its corresponding source. */ void match(const std::vector& sources, float threshold, std::vector& matches, - const std::vector& class_ids = std::vector(), + const std::vector& class_ids = std::vector(), OutputArrayOfArrays quantized_images = noArray(), const std::vector& masks = std::vector()) const; @@ -951,13 +951,13 @@ public: * * \return Template ID, or -1 if failed to extract a valid template. */ - int addTemplate(const std::vector& sources, const std::string& class_id, + int addTemplate(const std::vector& sources, const String& class_id, const Mat& object_mask, Rect* bounding_box = NULL); /** * \brief Add a new object template computed by external means. */ - int addSyntheticTemplate(const std::vector