Merge pull request #19580 from SergeyKrivohatskiy:patch-1
authorSergey Krivohatskiy <cthutq66a@yandex.ru>
Sun, 21 Feb 2021 15:57:18 +0000 (18:57 +0300)
committerGitHub <noreply@github.com>
Sun, 21 Feb 2021 15:57:18 +0000 (15:57 +0000)
* Fixed OCL implementation of pyrlk

If prevPts size is (N, 1) (which is a default layout for converting `vector<Point2f>` to `UMat`) the `prevPts.cols == 1` and optical flow will be calculated for the first point only.
Getting `prevPts.total()` as in line 1048 is the correct way to get points count.

* fixed compilation warning (size_t to int)

Signed-off-by: Sergey Krivohatskiy <s.krivohatskiy@gmail.com>
modules/video/src/lkpyramid.cpp

index 8df531448a6cee984b4dc2fe636d61c5b2332841..657b3ced4b9295da9d129d53a6eb85e064adc82e 100644 (file)
@@ -938,7 +938,8 @@ namespace
             {
                 if (!lkSparse_run(prevPyr[level], nextPyr[level], prevPts,
                                   nextPts, status, err,
-                                  prevPts.cols, level))
+                                  static_cast<int>(prevPts.total()),
+                                  level))
                     return false;
             }
             return true;