From 4d09d62f85d5154af8ab5463f2d511379c886e69 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 29 Jun 2012 07:46:53 +0000 Subject: [PATCH] Added Ptr support to AlgorithmInfo; fixed some warnings --- modules/core/include/opencv2/core/core.hpp | 10 ++++++++ .../core/include/opencv2/core/operations.hpp | 24 ++++++++++++++++--- modules/features2d/src/features2d_init.cpp | 2 +- modules/highgui/src/window.cpp | 2 +- modules/highgui/src/window_QT.cpp | 20 ++++++++-------- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index ba9da11bae..2c988279f6 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -4409,6 +4409,16 @@ public: Ptr (Algorithm::*getter)()=0, void (Algorithm::*setter)(const Ptr&)=0, 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 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 string& help=string()); protected: AlgorithmInfoData* data; void set(Algorithm* algo, const char* name, int argType, diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 1f81848904..1f96722fc6 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -3843,7 +3843,7 @@ template inline Ptr<_Tp> Algorithm::create(const string& name) } template -void Algorithm::set(const char* _name, const Ptr<_Tp>& value) +inline void Algorithm::set(const char* _name, const Ptr<_Tp>& value) { Ptr algo_ptr = value. template ptr(); if (algo_ptr.empty()) { @@ -3851,12 +3851,12 @@ void Algorithm::set(const char* _name, const Ptr<_Tp>& value) } info()->set(this, _name, ParamType::type, &algo_ptr); } + template -void Algorithm::set(const string& _name, const Ptr<_Tp>& value) +inline void Algorithm::set(const string& _name, const Ptr<_Tp>& value) { this->set<_Tp>(_name.c_str(), value); } - template inline typename ParamType<_Tp>::member_type Algorithm::get(const string& _name) const { @@ -3872,6 +3872,24 @@ template inline typename ParamType<_Tp>::member_type Algorithm::ge return value; } +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 string& help) +{ + //TODO: static assert: _Tp inherits from _Base + addParam_(algo, parameter, ParamType<_Base>::type, &value, readOnly, + (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); +} + +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 string& help) +{ + //TODO: static assert: _Tp inherits from Algorithm + addParam_(algo, parameter, ParamType::type, &value, readOnly, + (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); +} + } #endif // __cplusplus diff --git a/modules/features2d/src/features2d_init.cpp b/modules/features2d/src/features2d_init.cpp index 72db8d1091..0d884ef678 100644 --- a/modules/features2d/src/features2d_init.cpp +++ b/modules/features2d/src/features2d_init.cpp @@ -144,7 +144,7 @@ CV_INIT_ALGORITHM(DenseFeatureDetector, "Feature2D.Dense", obj.info()->addParam(obj, "varyImgBoundWithScale", obj.varyImgBoundWithScale)); CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid", - obj.info()->addParam(obj, "detector", (Ptr&)obj.detector); + obj.info()->addParam(obj, "detector", obj.detector); obj.info()->addParam(obj, "maxTotalKeypoints", obj.maxTotalKeypoints); obj.info()->addParam(obj, "gridRows", obj.gridRows); obj.info()->addParam(obj, "gridCols", obj.gridCols)); diff --git a/modules/highgui/src/window.cpp b/modules/highgui/src/window.cpp index e0d6525dd7..28ed2f1e19 100644 --- a/modules/highgui/src/window.cpp +++ b/modules/highgui/src/window.cpp @@ -521,7 +521,7 @@ void icvSetOpenGlCleanCallback(const char*, CvOpenGlCleanCallback, void*) #if defined (HAVE_QT) -CvFont cv::fontQt(const 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); } diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index abbbd9c5e4..b96988e6f3 100755 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -2414,13 +2414,13 @@ void DefaultViewPort::startDisplayInfo(QString text, int delayms) } -void DefaultViewPort::setOpenGlDrawCallback(CvOpenGlDrawCallback callback, void* userdata) +void DefaultViewPort::setOpenGlDrawCallback(CvOpenGlDrawCallback /*callback*/, void* /*userdata*/) { CV_Error(CV_OpenGlNotSupported, "Window doesn't support OpenGL"); } -void DefaultViewPort::setOpenGlCleanCallback(CvOpenGlCleanCallback callback, void* userdata) +void DefaultViewPort::setOpenGlCleanCallback(CvOpenGlCleanCallback /*callback*/, void* /*userdata*/) { CV_Error(CV_OpenGlNotSupported, "Window doesn't support OpenGL"); } @@ -3058,7 +3058,7 @@ void DefaultViewPort::drawInstructions(QPainter *painter) } -void DefaultViewPort::setSize(QSize size_) +void DefaultViewPort::setSize(QSize /*size_*/) { } @@ -3101,11 +3101,11 @@ void OpenGlViewPort::setMouseCallBack(CvMouseCallback callback, void* param) mouseData = param; } -void OpenGlViewPort::writeSettings(QSettings& settings) +void OpenGlViewPort::writeSettings(QSettings& /*settings*/) { } -void OpenGlViewPort::readSettings(QSettings& settings) +void OpenGlViewPort::readSettings(QSettings& /*settings*/) { } @@ -3114,15 +3114,15 @@ double OpenGlViewPort::getRatio() return (double)width() / height(); } -void OpenGlViewPort::setRatio(int flags) +void OpenGlViewPort::setRatio(int /*flags*/) { } -void OpenGlViewPort::updateImage(const CvArr* arr) +void OpenGlViewPort::updateImage(const CvArr* /*arr*/) { } -void OpenGlViewPort::startDisplayInfo(QString text, int delayms) +void OpenGlViewPort::startDisplayInfo(QString /*text*/, int /*delayms*/) { } @@ -3350,9 +3350,9 @@ void GlFuncTab_QT::unmapBuffer(unsigned int target) const __END__; } -void GlFuncTab_QT::generateBitmapFont(const std::string& family, int height, int weight, bool italic, bool underline, int start, int count, int base) const +void GlFuncTab_QT::generateBitmapFont(const std::string& family, int height, int weight, bool italic, bool /*underline*/, int start, int count, int base) const { - CV_FUNCNAME( "GlFuncTab_QT::generateBitmapFont" ); + //CV_FUNCNAME( "GlFuncTab_QT::generateBitmapFont" ); QFont font(QString(family.c_str()), height, weight, italic);