1. Input/OutputArray optimizations;

2. Algorithm::load/save added (moved from StatModel)
3. copyrights updated; added copyright/licensing info for ffmpeg
4. some warnings from Xcode 6.x are fixed
This commit is contained in:
Vadim Pisarevsky
2015-04-07 16:44:26 +03:00
parent 44f112a9de
commit 052593c760
34 changed files with 888 additions and 207 deletions

View File

@@ -10,8 +10,10 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2000-2015, Intel Corporation, all rights reserved.
// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
// Copyright (C) 2015, OpenCV Foundation, all rights reserved.
// Copyright (C) 2015, Itseez Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -2921,6 +2923,10 @@ public:
Algorithm();
virtual ~Algorithm();
/** @brief Clears the algorithm state
*/
CV_WRAP virtual void clear() {}
/** @brief Stores algorithm parameters in a file storage
*/
virtual void write(FileStorage& fs) const { (void)fs; }
@@ -2928,6 +2934,71 @@ public:
/** @brief Reads algorithm parameters from a file storage
*/
virtual void read(const FileNode& fn) { (void)fn; }
/** @brief Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
*/
virtual bool empty() const { return false; }
/** @brief Reads algorithm from the file node
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
Ptr<SVM> svm = Algorithm::read<SVM>(fn);
@endcode
In order to make this method work, the derived class must overwrite Algorithm::read(const
FileNode& fn) and also have static create() method without parameters
(or with all the optional parameters)
*/
template<typename _Tp> static Ptr<_Tp> read(const FileNode& fn)
{
Ptr<_Tp> obj = _Tp::create();
obj->read(fn);
return !obj->empty() ? obj : Ptr<_Tp>();
}
/** @brief Loads algorithm from the file
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
Ptr<SVM> svm = Algorithm::load<SVM>("my_svm_model.xml");
@endcode
In order to make this method work, the derived class must overwrite Algorithm::read(const
FileNode& fn).
*/
template<typename _Tp> static Ptr<_Tp> load(const String& filename, const String& objname=String())
{
FileStorage fs(filename, FileStorage::READ);
FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
Ptr<_Tp> obj = _Tp::create();
obj->read(fn);
return !obj->empty() ? obj : Ptr<_Tp>();
}
/** @brief Loads algorithm from a String
@param strModel The string variable containing the model you want to load.
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
Ptr<SVM> svm = Algorithm::loadFromString<SVM>(myStringModel);
@endcode
*/
template<typename _Tp> static Ptr<_Tp> loadFromString(const String& strModel, const String& objname=String())
{
FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY);
FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
Ptr<_Tp> obj = _Tp::create();
obj->read(fn);
return !obj->empty() ? obj : Ptr<_Tp>();
}
/** Saves the algorithm to a file.
In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs). */
CV_WRAP virtual void save(const String& filename) const;
/** Returns the algorithm string identifier.
This string is used as top level xml/yml node tag when the object is saved to a file or string. */
CV_WRAP virtual String getDefaultName() const;
};
struct Param {