From 4f391d6efbfa569b0e2227e00c11fd514ec7a8e7 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Sun, 22 Apr 2012 23:03:54 +0900 Subject: [PATCH] fix calculation of velocity matrix size in rb_optical_flow_bm see http://code.opencv.org/issues/1362 --- ext/opencv/cvmat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/opencv/cvmat.cpp b/ext/opencv/cvmat.cpp index d8770ca..0baa0d9 100644 --- a/ext/opencv/cvmat.cpp +++ b/ext/opencv/cvmat.cpp @@ -5404,8 +5404,8 @@ rb_optical_flow_bm(int argc, VALUE *argv, VALUE self) int use_previous = 0; try { CvSize image_size = cvGetSize(self_ptr); - CvSize velocity_size = cvSize((image_size.width - block_size.width) / shift_size.width, - (image_size.height - block_size.height) / shift_size.height); + CvSize velocity_size = cvSize((image_size.width - block_size.width + shift_size.width) / shift_size.width, + (image_size.height - block_size.height + shift_size.height) / shift_size.height); CvMat *velx_ptr, *vely_ptr; if (NIL_P(velx) && NIL_P(vely)) { int type = CV_MAKETYPE(CV_32F, 1);