From 17fd1c7c610c2bbf83cb482d4ccf3e9610db6e77 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 29 Jun 2012 07:52:34 +0000 Subject: [PATCH] Merged recent changes from trunk - 8833,8848,8850 --- modules/core/include/opencv2/core/core.hpp | 10 +++++++ .../core/include/opencv2/core/operations.hpp | 24 ++++++++++++++-- modules/core/src/lapack.cpp | 17 +++++------ modules/core/test/test_operations.cpp | 28 +++++++++++++++++++ modules/features2d/src/features2d_init.cpp | 2 +- modules/highgui/CMakeLists.txt | 2 +- modules/highgui/src/cap_avfoundation.mm | 8 +++--- modules/highgui/src/window.cpp | 2 +- modules/highgui/src/window_QT.cpp | 18 ++++++------ 9 files changed, 84 insertions(+), 27 deletions(-) diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index e5be8f70d4..d3f173d031 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -4406,6 +4406,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/core/src/lapack.cpp b/modules/core/src/lapack.cpp index 12ad27832f..c66923d7e6 100644 --- a/modules/core/src/lapack.cpp +++ b/modules/core/src/lapack.cpp @@ -527,7 +527,7 @@ template<> inline int VBLAS::givensx(double* a, double* b, int n, double #endif template void -JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep, int m, int n, int n1) +JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep, int m, int n, int n1, double minval) { VBLAS<_Tp> vblas; AutoBuffer Wbuf(n); @@ -587,11 +587,11 @@ JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep, int m, int delta = p*p*0.5/(gamma + beta); } - if( iter % 2 ) + W[i] += delta; + W[j] -= delta; + + if( iter % 2 != 0 && W[i] > 0 && W[j] > 0 ) { - W[i] += delta; - W[j] -= delta; - k = vblas.givens(Ai, Aj, m, c, s); for( ; k < m; k++ ) @@ -671,12 +671,13 @@ JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep, int m, int if( !Vt ) return; + RNG rng(0x12345678); for( i = 0; i < n1; i++ ) { sd = i < n ? W[i] : 0; - while( sd == 0 ) + while( sd <= minval ) { // if we got a zero singular value, then in order to get the corresponding left singular vector // we generate a random vector, project it to the previously computed left singular vectors, @@ -724,12 +725,12 @@ JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep, int m, int static void JacobiSVD(float* At, size_t astep, float* W, float* Vt, size_t vstep, int m, int n, int n1=-1) { - JacobiSVDImpl_(At, astep, W, Vt, vstep, m, n, !Vt ? 0 : n1 < 0 ? n : n1); + JacobiSVDImpl_(At, astep, W, Vt, vstep, m, n, !Vt ? 0 : n1 < 0 ? n : n1, FLT_MIN); } static void JacobiSVD(double* At, size_t astep, double* W, double* Vt, size_t vstep, int m, int n, int n1=-1) { - JacobiSVDImpl_(At, astep, W, Vt, vstep, m, n, !Vt ? 0 : n1 < 0 ? n : n1); + JacobiSVDImpl_(At, astep, W, Vt, vstep, m, n, !Vt ? 0 : n1 < 0 ? n : n1, DBL_MIN); } /* y[0:m,0:n] += diag(a[0:1,0:m]) * x[0:m,0:n] */ diff --git a/modules/core/test/test_operations.cpp b/modules/core/test/test_operations.cpp index 092ffb7980..b7440b08f9 100644 --- a/modules/core/test/test_operations.cpp +++ b/modules/core/test/test_operations.cpp @@ -940,6 +940,34 @@ bool CV_OperationsTest::TestSVD() SVD svd(A, SVD::FULL_UV); if( norm(A*svd.vt.row(3).t(), CV_C) > FLT_EPSILON ) throw test_excep(); + + Mat Dp(3,3,CV_32FC1); + Mat Dc(3,3,CV_32FC1); + Mat Q(3,3,CV_32FC1); + Mat U,Vt,R,T,W; + + Dp.at(0,0)=0.86483884; Dp.at(0,1)= -0.3077251; Dp.at(0,2)=-0.55711365; + Dp.at(1,0)=0.49294353; Dp.at(1,1)=-0.24209651; Dp.at(1,2)=-0.25084701; + Dp.at(2,0)=0; Dp.at(2,1)=0; Dp.at(2,2)=0; + + Dc.at(0,0)=0.75632739; Dc.at(0,1)= -0.38859656; Dc.at(0,2)=-0.36773083; + Dc.at(1,0)=0.9699229; Dc.at(1,1)=-0.49858192; Dc.at(1,2)=-0.47134098; + Dc.at(2,0)=0.10566688; Dc.at(2,1)=-0.060333252; Dc.at(2,2)=-0.045333147; + + Q=Dp*Dc.t(); + SVD decomp; + decomp=SVD(Q); + U=decomp.u; + Vt=decomp.vt; + W=decomp.w; + Mat I = Mat::eye(3, 3, CV_32F); + + if( norm(U*U.t(), I, CV_C) > FLT_EPSILON || + norm(Vt*Vt.t(), I, CV_C) > FLT_EPSILON || + W.at(2) < 0 || W.at(1) < W.at(2) || + W.at(0) < W.at(1) || + norm(U*Mat::diag(W)*Vt, Q, CV_C) > FLT_EPSILON ) + throw test_excep(); } catch(const test_excep&) { 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/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 947d76d460..6b9341b32e 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -160,7 +160,7 @@ if(HAVE_FFMPEG) list(APPEND HIGHGUI_LIBRARIES ${BZIP2_LIBRARIES}) endif() if(APPLE) - list(APPEND HIGHGUI_LIBRARIES "-framework VideoDecodeAcceleration") + list(APPEND HIGHGUI_LIBRARIES "-framework VideoDecodeAcceleration" bz2) endif() endif(HAVE_FFMPEG) diff --git a/modules/highgui/src/cap_avfoundation.mm b/modules/highgui/src/cap_avfoundation.mm index 620a97eae0..0241c0d1ec 100644 --- a/modules/highgui/src/cap_avfoundation.mm +++ b/modules/highgui/src/cap_avfoundation.mm @@ -720,7 +720,7 @@ fromConnection:(AVCaptureConnection *)connection{ image->height = height; image->nChannels = 4; image->depth = IPL_DEPTH_8U; - image->widthStep = rowBytes; + image->widthStep = (int)rowBytes; image->imageData = imagedata; image->imageSize = currSize; @@ -731,7 +731,7 @@ fromConnection:(AVCaptureConnection *)connection{ bgr_image->height = height; bgr_image->nChannels = 3; bgr_image->depth = IPL_DEPTH_8U; - bgr_image->widthStep = rowBytes; + bgr_image->widthStep = (int)rowBytes; bgr_image->imageData = bgr_imagedata; bgr_image->imageSize = currSize; @@ -949,7 +949,7 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { image->height = height; image->nChannels = 4; image->depth = IPL_DEPTH_8U; - image->widthStep = width*4; + image->widthStep = rowBytes; image->imageData = imagedata; image->imageSize = currSize; @@ -962,7 +962,7 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { bgr_image->height = height; bgr_image->nChannels = 3; bgr_image->depth = IPL_DEPTH_8U; - bgr_image->widthStep = width*4; + bgr_image->widthStep = rowBytes; bgr_image->imageData = bgr_imagedata; bgr_image->imageSize = currSize; 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 ebc90def80..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,7 +3350,7 @@ 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" ); -- GitLab