@@ -1316,7 +1316,8 @@ bool DISOpticalFlowImpl::ocl_calc(InputArray I0, InputArray I1, InputOutputArray
1316
1316
else
1317
1317
flow.create (I1Mat.size (), CV_32FC2);
1318
1318
UMat &u_flowMat = flow.getUMatRef ();
1319
- coarsest_scale = (int )(log ((2 * I0Mat.cols ) / (4.0 * patch_size)) / log (2.0 ) + 0.5 ) - 1 ;
1319
+ coarsest_scale = min ((int )(log (max (I0Mat.cols , I0Mat.rows ) / (4.0 * patch_size)) / log (2.0 ) + 0.5 ), /* Original code serach for maximal movement of width/4 */
1320
+ (int )(log (min (I0Mat.cols , I0Mat.rows ) / patch_size) / log (2.0 ))); /* Deepest pyramid level greater or equal than patch*/
1320
1321
1321
1322
ocl_prepareBuffers (I0Mat, I1Mat, u_flowMat, use_input_flow);
1322
1323
u_Ux[coarsest_scale].setTo (0 .0f );
@@ -1382,7 +1383,8 @@ void DISOpticalFlowImpl::calc(InputArray I0, InputArray I1, InputOutputArray flo
1382
1383
else
1383
1384
flow.create (I1Mat.size (), CV_32FC2);
1384
1385
Mat flowMat = flow.getMat ();
1385
- coarsest_scale = (int )(log ((2 * I0Mat.cols ) / (4.0 * patch_size)) / log (2.0 ) + 0.5 ) - 1 ;
1386
+ coarsest_scale = min ((int )(log (max (I0Mat.cols , I0Mat.rows ) / (4.0 * patch_size)) / log (2.0 ) + 0.5 ), /* Original code serach for maximal movement of width/4 */
1387
+ (int )(log (min (I0Mat.cols , I0Mat.rows ) / patch_size) / log (2.0 ))); /* Deepest pyramid level greater or equal than patch*/
1386
1388
int num_stripes = getNumThreads ();
1387
1389
1388
1390
prepareBuffers (I0Mat, I1Mat, flowMat, use_input_flow);
0 commit comments