From e6876fecd34fc3c8d06f86115b536d7a34ec5b48 Mon Sep 17 00:00:00 2001 From: Nisarg Thakkar Date: Tue, 17 Feb 2015 22:14:57 +0530 Subject: [PATCH 1/4] Fixed doc error in optical flow --- .../py_video/py_lucas_kanade/py_lucas_kanade.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/py_tutorials/py_video/py_lucas_kanade/py_lucas_kanade.markdown b/doc/py_tutorials/py_video/py_lucas_kanade/py_lucas_kanade.markdown index 1ea6cd69dc..48c8761c76 100644 --- a/doc/py_tutorials/py_video/py_lucas_kanade/py_lucas_kanade.markdown +++ b/doc/py_tutorials/py_video/py_lucas_kanade/py_lucas_kanade.markdown @@ -46,7 +46,7 @@ get the following equation: where: -\f[f_x = \frac{\partial f}{\partial x} \; ; \; f_y = \frac{\partial f}{\partial x}\f]\f[u = \frac{dx}{dt} \; ; \; v = \frac{dy}{dt}\f] +\f[f_x = \frac{\partial f}{\partial x} \; ; \; f_y = \frac{\partial f}{\partial y}\f]\f[u = \frac{dx}{dt} \; ; \; v = \frac{dy}{dt}\f] Above equation is called Optical Flow equation. In it, we can find \f$f_x\f$ and \f$f_y\f$, they are image gradients. Similarly \f$f_t\f$ is the gradient along time. But \f$(u,v)\f$ is unknown. We cannot solve this From 98a8045aaf07393c3b3fc0b58a3f33511b42f220 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Mon, 16 Feb 2015 15:39:52 +0300 Subject: [PATCH 2/4] Reduce variable scope --- modules/core/src/conjugate_gradient.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/core/src/conjugate_gradient.cpp b/modules/core/src/conjugate_gradient.cpp index caf41fc954..90353cc7fd 100644 --- a/modules/core/src/conjugate_gradient.cpp +++ b/modules/core/src/conjugate_gradient.cpp @@ -136,7 +136,6 @@ namespace cv dprintf(("d first time\n"));print_matrix(d); dprintf(("r\n"));print_matrix(r); - double beta=0; for(int count=0;count<_termcrit.maxCount;count++){ minimizeOnTheLine(_Function,proxy_x,d,minimizeOnTheLine_buf1,minimizeOnTheLine_buf2); r.copyTo(r_old); @@ -147,7 +146,7 @@ namespace cv break; } r_norm_sq=r_norm_sq*r_norm_sq; - beta=MAX(0.0,(r_norm_sq-r.dot(r_old))/r_norm_sq); + double beta=MAX(0.0,(r_norm_sq-r.dot(r_old))/r_norm_sq); d=r+beta*d; } From 453f384bd7d72506377ca60d41a738b71d71d229 Mon Sep 17 00:00:00 2001 From: theodore Date: Thu, 19 Feb 2015 17:38:44 +0100 Subject: [PATCH 3/4] adding documentation for the findnonzero() function --- modules/core/include/opencv2/core.hpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 76fb3fd520..cd9cb47206 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -545,8 +545,29 @@ The function returns the number of non-zero elements in src : */ CV_EXPORTS_W int countNonZero( InputArray src ); -/** @brief returns the list of locations of non-zero pixels -@todo document +/** @brief Returns the list of locations of non-zero pixels + +The function returns the coordinates of the location of non-zero pixels in src. +The result array can be both type of Mat or vector. For example: +@code{.cpp} + cv::Mat binaryImage; // input, binary image + cv::Mat locations; // output, locations of non-zero pixels + cv::findNonZero(binaryImage, locations); + + // access pixel coordinates + Point pnt = locations.at(i); +@endcode +or +@code{.cpp} + cv::Mat binaryImage; // input, binary image + vector locations; // output, locations of non-zero pixels + cv::findNonZero(binaryImage, locations); + + // access pixel coordinates + Point pnt = locations[i]; +@endcode +@param src single-channel array +@param idx output array with the non-zero pixel points */ CV_EXPORTS_W void findNonZero( InputArray src, OutputArray idx ); From cfccdc9b0cdfc3e856a2b81fa51d90cd05949439 Mon Sep 17 00:00:00 2001 From: theodore Date: Thu, 19 Feb 2015 17:57:52 +0100 Subject: [PATCH 4/4] documenting findnonzero() function --- modules/core/include/opencv2/core.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index cd9cb47206..69baa4d1ab 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -547,8 +547,10 @@ CV_EXPORTS_W int countNonZero( InputArray src ); /** @brief Returns the list of locations of non-zero pixels -The function returns the coordinates of the location of non-zero pixels in src. -The result array can be both type of Mat or vector. For example: +Given a binary matrix (likely returned from an operation such +as threshold(), compare(), >, ==, etc, return all of +the non-zero indices as a cv::Mat or std::vector (x,y) +For example: @code{.cpp} cv::Mat binaryImage; // input, binary image cv::Mat locations; // output, locations of non-zero pixels @@ -566,8 +568,8 @@ or // access pixel coordinates Point pnt = locations[i]; @endcode -@param src single-channel array -@param idx output array with the non-zero pixel points +@param src single-channel array (type CV_8UC1) +@param idx the output array, type of cv::Mat or std::vector, corresponding to non-zero indices in the input */ CV_EXPORTS_W void findNonZero( InputArray src, OutputArray idx );