ECC patch by the author (G. Evangelidis); fixed some OCL Farneback optical flow test failures on Mac

pull/3066/head
Vadim Pisarevsky 11 years ago
parent 99eed2d885
commit 0224a20ff6
  1. 7
      modules/video/src/ecc.cpp
  2. 16
      modules/video/src/optflowgf.cpp

@ -297,7 +297,12 @@ static void update_warping_matrix_ECC (Mat& map_matrix, const Mat& update, const
mapPtr[5] += updatePtr[7];
}
if (motionType == MOTION_EUCLIDEAN) {
double new_theta = acos(mapPtr[0]) + updatePtr[0];
double new_theta = updatePtr[0];
if (mapPtr[3]>0)
new_theta += acos(mapPtr[0]);
if (mapPtr[3]<0)
new_theta -= acos(mapPtr[0]);
mapPtr[2] += updatePtr[1];
mapPtr[5] += updatePtr[2];

@ -43,6 +43,10 @@
#include "precomp.hpp"
#include "opencl_kernels_video.hpp"
#if defined __APPLE__ || defined ANDROID
#define SMALL_LOCALSIZE
#endif
//
// 2D dense optical flow algorithm from the following paper:
// Gunnar Farneback. "Two-Frame Motion Estimation Based on Polynomial Expansion".
@ -836,7 +840,7 @@ private:
bool gaussianBlurOcl(const UMat &src, int ksizeHalf, UMat &dst)
{
#ifdef ANDROID
#ifdef SMALL_LOCALSIZE
size_t localsize[2] = { 128, 1};
#else
size_t localsize[2] = { 256, 1};
@ -863,7 +867,7 @@ private:
bool gaussianBlur5Ocl(const UMat &src, int ksizeHalf, UMat &dst)
{
int height = src.rows / 5;
#ifdef ANDROID
#ifdef SMALL_LOCALSIZE
size_t localsize[2] = { 128, 1};
#else
size_t localsize[2] = { 256, 1};
@ -888,7 +892,7 @@ private:
}
bool polynomialExpansionOcl(const UMat &src, UMat &dst)
{
#ifdef ANDROID
#ifdef SMALL_LOCALSIZE
size_t localsize[2] = { 128, 1};
#else
size_t localsize[2] = { 256, 1};
@ -925,7 +929,7 @@ private:
bool boxFilter5Ocl(const UMat &src, int ksizeHalf, UMat &dst)
{
int height = src.rows / 5;
#ifdef ANDROID
#ifdef SMALL_LOCALSIZE
size_t localsize[2] = { 128, 1};
#else
size_t localsize[2] = { 256, 1};
@ -952,7 +956,7 @@ private:
bool updateFlowOcl(const UMat &M, UMat &flowx, UMat &flowy)
{
#ifdef ANDROID
#ifdef SMALL_LOCALSIZE
size_t localsize[2] = { 32, 4};
#else
size_t localsize[2] = { 32, 8};
@ -976,7 +980,7 @@ private:
}
bool updateMatricesOcl(const UMat &flowx, const UMat &flowy, const UMat &R0, const UMat &R1, UMat &M)
{
#ifdef ANDROID
#ifdef SMALL_LOCALSIZE
size_t localsize[2] = { 32, 4};
#else
size_t localsize[2] = { 32, 8};

Loading…
Cancel
Save