From 8271bd5f14ef8d19c5f7aea3a55be5108743b933 Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Mon, 7 Apr 2014 11:24:27 +0300 Subject: [PATCH 01/12] fix condition in CV_OperationsTest::operations1() --- modules/core/test/test_operations.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/test/test_operations.cpp b/modules/core/test/test_operations.cpp index 6b36883cfe..fd14920a04 100644 --- a/modules/core/test/test_operations.cpp +++ b/modules/core/test/test_operations.cpp @@ -965,7 +965,7 @@ bool CV_OperationsTest::operations1() Vec v10dzero; for (int ii = 0; ii < 10; ++ii) { - if (!v10dzero[ii] == 0.0) + if (v10dzero[ii] != 0.0) throw test_excep(); } From 267241b8895baffc4913323afa8681ffcacdd168 Mon Sep 17 00:00:00 2001 From: Martin Chodakowski Date: Thu, 3 Apr 2014 17:07:05 -0400 Subject: [PATCH 02/12] Fix typos in old python wrapper documentation(Bug #3628) Fixed spelling of CV_INTER_LINEAR flag in geometric_transformations.rst --- modules/imgproc/doc/geometric_transformations.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/imgproc/doc/geometric_transformations.rst b/modules/imgproc/doc/geometric_transformations.rst index 229183e5f2..b3bb37c796 100644 --- a/modules/imgproc/doc/geometric_transformations.rst +++ b/modules/imgproc/doc/geometric_transformations.rst @@ -264,7 +264,7 @@ Remaps an image to log-polar space. .. ocv:cfunction:: void cvLogPolar( const CvArr* src, CvArr* dst, CvPoint2D32f center, double M, int flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS ) -.. ocv:pyoldfunction:: cv.LogPolar(src, dst, center, M, flags=CV_INNER_LINEAR+CV_WARP_FILL_OUTLIERS)-> None +.. ocv:pyoldfunction:: cv.LogPolar(src, dst, center, M, flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS)-> None :param src: Source image @@ -320,7 +320,7 @@ Applies a generic geometrical transformation to an image. .. ocv:pyfunction:: cv2.remap(src, map1, map2, interpolation[, dst[, borderMode[, borderValue]]]) -> dst .. ocv:cfunction:: void cvRemap( const CvArr* src, CvArr* dst, const CvArr* mapx, const CvArr* mapy, int flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, CvScalar fillval=cvScalarAll(0) ) -.. ocv:pyoldfunction:: cv.Remap(src, dst, mapx, mapy, flags=CV_INNER_LINEAR+CV_WARP_FILL_OUTLIERS, fillval=(0, 0, 0, 0))-> None +.. ocv:pyoldfunction:: cv.Remap(src, dst, mapx, mapy, flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, fillval=(0, 0, 0, 0))-> None :param src: Source image. @@ -488,7 +488,7 @@ Applies a perspective transformation to an image. .. ocv:cfunction:: void cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix, int flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, CvScalar fillval=cvScalarAll(0) ) -.. ocv:pyoldfunction:: cv.WarpPerspective(src, dst, mapMatrix, flags=CV_INNER_LINEAR+CV_WARP_FILL_OUTLIERS, fillval=(0, 0, 0, 0))-> None +.. ocv:pyoldfunction:: cv.WarpPerspective(src, dst, mapMatrix, flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, fillval=(0, 0, 0, 0))-> None :param src: input image. From 3f9581825225d2a8a878d1e05a34eb2f45da473f Mon Sep 17 00:00:00 2001 From: Anatoly Baksheev Date: Tue, 8 Apr 2014 20:26:56 +0400 Subject: [PATCH 03/12] Added cloud shading support - additional normals array is used --- modules/viz/doc/widget.rst | 20 +++++++++++++++++ modules/viz/include/opencv2/viz/widgets.hpp | 7 ++++++ modules/viz/src/clouds.cpp | 25 ++++++++++++++++----- modules/viz/test/tests_simple.cpp | 16 +++++++++++++ 4 files changed, 62 insertions(+), 6 deletions(-) diff --git a/modules/viz/doc/widget.rst b/modules/viz/doc/widget.rst index 0601ba1b72..751838d75e 100644 --- a/modules/viz/doc/widget.rst +++ b/modules/viz/doc/widget.rst @@ -897,6 +897,10 @@ This 3D Widget defines a point cloud. :: WCloud(InputArray cloud, InputArray colors); //! All points in cloud have the same color WCloud(InputArray cloud, const Color &color = Color::white()); + //! Each point in cloud is mapped to a color in colors, normals are used for shading + WCloud(InputArray cloud, InputArray colors, InputArray normals); + //! All points in cloud have the same color, normals are used for shading + WCloud(InputArray cloud, const Color &color, InputArray normals); }; viz::WCloud::WCloud @@ -917,6 +921,22 @@ Constructs a WCloud. Points in the cloud belong to mask when they are set to (NaN, NaN, NaN). +.. ocv:function:: WCloud(InputArray cloud, InputArray colors, InputArray normals) + + :param cloud: Set of points which can be of type: ``CV_32FC3``, ``CV_32FC4``, ``CV_64FC3``, ``CV_64FC4``. + :param colors: Set of colors. It has to be of the same size with cloud. + :param normals: Normals for each point in cloud. Size and type should match with the cloud parameter. + + Points in the cloud belong to mask when they are set to (NaN, NaN, NaN). + +.. ocv:function:: WCloud(InputArray cloud, const Color &color, InputArray normals) + + :param cloud: Set of points which can be of type: ``CV_32FC3``, ``CV_32FC4``, ``CV_64FC3``, ``CV_64FC4``. + :param color: A single :ocv:class:`Color` for the whole cloud. + :param normals: Normals for each point in cloud. Size and type should match with the cloud parameter. + + Points in the cloud belong to mask when they are set to (NaN, NaN, NaN). + .. note:: In case there are four channels in the cloud, fourth channel is ignored. viz::WCloudCollection diff --git a/modules/viz/include/opencv2/viz/widgets.hpp b/modules/viz/include/opencv2/viz/widgets.hpp index 2949598c54..611db54499 100644 --- a/modules/viz/include/opencv2/viz/widgets.hpp +++ b/modules/viz/include/opencv2/viz/widgets.hpp @@ -320,8 +320,15 @@ namespace cv public: //! Each point in cloud is mapped to a color in colors WCloud(InputArray cloud, InputArray colors); + //! All points in cloud have the same color WCloud(InputArray cloud, const Color &color = Color::white()); + + //! Each point in cloud is mapped to a color in colors, normals are used for shading + WCloud(InputArray cloud, InputArray colors, InputArray normals); + + //! All points in cloud have the same color, normals are used for shading + WCloud(InputArray cloud, const Color &color, InputArray normals); }; class CV_EXPORTS WPaintedCloud: public Widget3D diff --git a/modules/viz/src/clouds.cpp b/modules/viz/src/clouds.cpp index eec02639e5..48d057d2a8 100644 --- a/modules/viz/src/clouds.cpp +++ b/modules/viz/src/clouds.cpp @@ -49,11 +49,29 @@ /// Point Cloud Widget implementation cv::viz::WCloud::WCloud(InputArray cloud, InputArray colors) +{ + WCloud cloud_widget(cloud, colors, cv::noArray()); + *this = cloud_widget; +} + +cv::viz::WCloud::WCloud(InputArray cloud, const Color &color) +{ + WCloud cloud_widget(cloud, Mat(cloud.size(), CV_8UC3, color)); + *this = cloud_widget; +} + +cv::viz::WCloud::WCloud(InputArray cloud, const Color &color, InputArray normals) +{ + WCloud cloud_widget(cloud, Mat(cloud.size(), CV_8UC3, color), normals); + *this = cloud_widget; +} + +cv::viz::WCloud::WCloud(cv::InputArray cloud, cv::InputArray colors, cv::InputArray normals) { CV_Assert(!cloud.empty() && !colors.empty()); vtkSmartPointer cloud_source = vtkSmartPointer::New(); - cloud_source->SetColorCloud(cloud, colors); + cloud_source->SetColorCloudNormals(cloud, colors, normals); cloud_source->Update(); vtkSmartPointer mapper = vtkSmartPointer::New(); @@ -69,12 +87,7 @@ cv::viz::WCloud::WCloud(InputArray cloud, InputArray colors) actor->SetMapper(mapper); WidgetAccessor::setProp(*this, actor); -} -cv::viz::WCloud::WCloud(InputArray cloud, const Color &color) -{ - WCloud cloud_widget(cloud, Mat(cloud.size(), CV_8UC3, color)); - *this = cloud_widget; } diff --git a/modules/viz/test/tests_simple.cpp b/modules/viz/test/tests_simple.cpp index d1b059cf67..f8f63c35b7 100644 --- a/modules/viz/test/tests_simple.cpp +++ b/modules/viz/test/tests_simple.cpp @@ -248,6 +248,22 @@ TEST(Viz, show_sampled_normals) viz.spin(); } +TEST(Viz, show_cloud_shaded_by_normals) +{ + Mesh mesh = Mesh::load(get_dragon_ply_file_path()); + computeNormals(mesh, mesh.normals); + + Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0)); + + WCloud cloud(mesh.cloud, Color::white(), mesh.normals); + cloud.setRenderingProperty(SHADING, SHADING_GOURAUD); + + Viz3d viz("show_cloud_shaded_by_normals"); + viz.showWidget("cloud", cloud, pose); + viz.showWidget("text2d", WText("Cloud shaded by normals", Point(20, 20), 20, Color::green())); + viz.spin(); +} + TEST(Viz, show_trajectories) { std::vector path = generate_test_trajectory(), sub0, sub1, sub2, sub3, sub4, sub5; From cb8ddb11799e54037921d42b8445f9ecf7c46413 Mon Sep 17 00:00:00 2001 From: David Rolland Date: Sun, 6 Apr 2014 21:32:01 +1200 Subject: [PATCH 04/12] Corrected bug #1437. Corrected the cast of two short values from an lParam. lParam contains two signed-short, the position can be negative when another mouse event happens with a mouse_move (mouse_click, etc.) The Microsoft documentation specifies NOT to use LOWORD and HIWORD macros to extract the x/y positions as it won't work correctly with multiple monitors. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms645607(v=vs.85).aspx. --- modules/highgui/src/window_w32.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/highgui/src/window_w32.cpp b/modules/highgui/src/window_w32.cpp index 59d66b100a..48f3aab23e 100644 --- a/modules/highgui/src/window_w32.cpp +++ b/modules/highgui/src/window_w32.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #ifdef HAVE_OPENGL #include @@ -1459,8 +1460,8 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM if( uMsg == WM_LBUTTONUP || uMsg == WM_RBUTTONUP || uMsg == WM_MBUTTONUP ) ReleaseCapture(); - pt.x = LOWORD( lParam ); - pt.y = HIWORD( lParam ); + pt.x = GET_X_LPARAM( lParam ); + pt.y = GET_Y_LPARAM( lParam ); GetClientRect( window->hwnd, &rect ); icvGetBitmapData( window, &size, 0, 0 ); From b033a63e6332d164fdd1d14672f770544e53d33d Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Wed, 9 Apr 2014 14:41:16 +0300 Subject: [PATCH 05/12] fix typo in test_cameracalibration --- modules/calib3d/test/test_cameracalibration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/calib3d/test/test_cameracalibration.cpp b/modules/calib3d/test/test_cameracalibration.cpp index 7e409517bb..bf978bfb0f 100644 --- a/modules/calib3d/test/test_cameracalibration.cpp +++ b/modules/calib3d/test/test_cameracalibration.cpp @@ -1605,7 +1605,7 @@ void CV_StereoCalibrationTest::run( int ) Mat _M1, _M2, _D1, _D2; vector _R1, _R2, _T1, _T2; calibrateCamera( objpt, imgpt1, imgsize, _M1, _D1, _R1, _T1, 0 ); - calibrateCamera( objpt, imgpt2, imgsize, _M2, _D2, _R2, _T1, 0 ); + calibrateCamera( objpt, imgpt2, imgsize, _M2, _D2, _R2, _T2, 0 ); undistortPoints( _imgpt1, _imgpt1, _M1, _D1, Mat(), _M1 ); undistortPoints( _imgpt2, _imgpt2, _M2, _D2, Mat(), _M2 ); From a01659825c485e060537837a1942c599c9dd8060 Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Wed, 9 Apr 2014 22:53:36 +0300 Subject: [PATCH 06/12] remove unused variable in loadFromXML() --- modules/gpu/src/cascadeclassifier.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/gpu/src/cascadeclassifier.cpp b/modules/gpu/src/cascadeclassifier.cpp index 7b95b69091..65b74a4338 100644 --- a/modules/gpu/src/cascadeclassifier.cpp +++ b/modules/gpu/src/cascadeclassifier.cpp @@ -778,8 +778,6 @@ NCVStatus loadFromXML(const std::string &filename, haar.bNeedsTiltedII = false; Ncv32u curMaxTreeDepth; - std::vector xmlFileCont; - std::vector h_TmpClassifierNotRootNodes; haarStages.resize(0); haarClassifierNodes.resize(0); From 9b52b614516a0a7286fee08dddf574e1ec6e6188 Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Wed, 9 Apr 2014 22:56:19 +0300 Subject: [PATCH 07/12] remove unused variable in HOGDescriptor::groupRectangles() --- modules/objdetect/src/hog.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp index 41744f6d5f..c140f3bf72 100644 --- a/modules/objdetect/src/hog.cpp +++ b/modules/objdetect/src/hog.cpp @@ -2651,7 +2651,6 @@ void HOGDescriptor::groupRectangles(vector& rectList, vector& vector > rrects(nclasses); vector numInClass(nclasses, 0); vector foundWeights(nclasses, DBL_MIN); - vector totalFactorsPerClass(nclasses, 1); int i, j, nlabels = (int)labels.size(); for( i = 0; i < nlabels; i++ ) From eb45cf0c93e08cbb392f239417007d9fd71985e7 Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Wed, 9 Apr 2014 22:59:52 +0300 Subject: [PATCH 08/12] remove unused variable in findCorners_caller() --- modules/ocl/src/gftt.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ocl/src/gftt.cpp b/modules/ocl/src/gftt.cpp index 57ed12f009..4f204d6f43 100644 --- a/modules/ocl/src/gftt.cpp +++ b/modules/ocl/src/gftt.cpp @@ -110,7 +110,6 @@ static void findCorners_caller( oclMat& counter) //output value with number of detected corners, have to be 0 before call { string opt; - std::vector k; Context * cxt = Context::getContext(); std::vector< std::pair > args; From befbe89bdfa0ccccb7499aee16c265ceff551f65 Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Wed, 9 Apr 2014 23:01:49 +0300 Subject: [PATCH 09/12] remove unused variable in ocl_moments() --- modules/ocl/src/moments.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ocl/src/moments.cpp b/modules/ocl/src/moments.cpp index f11d381c98..216e9ab29a 100644 --- a/modules/ocl/src/moments.cpp +++ b/modules/ocl/src/moments.cpp @@ -266,7 +266,7 @@ namespace cv int src_step = (int)(src.step/src.elemSize()); int dstm_step = (int)(dst_m.step/dst_m.elemSize()); - vector > args,args_sum; + vector > args; args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data )); args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows )); args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols )); @@ -384,4 +384,4 @@ namespace cv return mom; } } -} \ No newline at end of file +} From 79eb3c5cde774cc0caab98401ebc44278efd378f Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Wed, 9 Apr 2014 23:04:29 +0300 Subject: [PATCH 10/12] remove unused variable in OCL_PERF_TEST_P() --- modules/ocl/perf/perf_imgproc.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ocl/perf/perf_imgproc.cpp b/modules/ocl/perf/perf_imgproc.cpp index 05b948649c..6d859a94c0 100644 --- a/modules/ocl/perf/perf_imgproc.cpp +++ b/modules/ocl/perf/perf_imgproc.cpp @@ -630,7 +630,6 @@ typedef TestBaseWithParam CLAHEFixture; OCL_PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TEST_SIZES) { const Size srcSize = GetParam(); - const string impl = getSelectedImpl(); Mat src(srcSize, CV_8UC1), dst; const double clipLimit = 40.0; From 29d1bce85fd6e927b21a494c96d45c786bb78177 Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Wed, 9 Apr 2014 23:06:06 +0300 Subject: [PATCH 11/12] remove unused variable in TEST_P() --- modules/core/test/test_arithm.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/core/test/test_arithm.cpp b/modules/core/test/test_arithm.cpp index 8fec388df8..a240941847 100644 --- a/modules/core/test/test_arithm.cpp +++ b/modules/core/test/test_arithm.cpp @@ -1363,7 +1363,6 @@ TEST_P(ElemWiseTest, accuracy) op->op(src, dst, mask); double maxErr = op->getMaxErr(depth); - vector pos; ASSERT_PRED_FORMAT2(cvtest::MatComparator(maxErr, op->context), dst0, dst) << "\nsrc[0] ~ " << cvtest::MatInfo(!src.empty() ? src[0] : Mat()) << "\ntestCase #" << testIdx << "\n"; } } From eb89f5207cb42a7e1bfc4378fa96e7e49b58476d Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Wed, 9 Apr 2014 23:07:48 +0300 Subject: [PATCH 12/12] remove unused variables in CV_KDTreeTest_CPP::findNeighbors() --- modules/features2d/test/test_nearestneighbors.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/features2d/test/test_nearestneighbors.cpp b/modules/features2d/test/test_nearestneighbors.cpp index 45131eff2e..8d1ecfd79a 100644 --- a/modules/features2d/test/test_nearestneighbors.cpp +++ b/modules/features2d/test/test_nearestneighbors.cpp @@ -214,8 +214,6 @@ int CV_KDTreeTest_CPP::findNeighbors( Mat& points, Mat& neighbors ) const int emax = 20; Mat neighbors2( neighbors.size(), CV_32SC1 ); int j; - vector min(points.cols, static_cast(minValue)); - vector max(points.cols, static_cast(maxValue)); for( int pi = 0; pi < points.rows; pi++ ) { // 1st way