fix meanShift mismatch on none-double GPUs
This commit is contained in:
parent
6ebb0e2ad2
commit
f4ef0c1598
@ -12,11 +12,13 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
|
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
|
||||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||||
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||||
// Third party copyrights are property of their respective owners.
|
// Third party copyrights are property of their respective owners.
|
||||||
//
|
//
|
||||||
// @Authors
|
// @Authors
|
||||||
// Shengen Yan,yanshengen@gmail.com
|
// Shengen Yan,yanshengen@gmail.com
|
||||||
// Xu Pang, pangxu010@163.com
|
// Xu Pang, pangxu010@163.com
|
||||||
|
// Wenju He, wenju@multicorewareinc.com
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
// are permitted provided that the following conditions are met:
|
// are permitted provided that the following conditions are met:
|
||||||
@ -43,12 +45,6 @@
|
|||||||
// the use of this software, even if advised of the possibility of such damage.
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
//
|
//
|
||||||
//M*/
|
//M*/
|
||||||
#if defined (DOUBLE_SUPPORT)
|
|
||||||
#pragma OPENCL EXTENSION cl_khr_fp64:enable
|
|
||||||
typedef double F;
|
|
||||||
#else
|
|
||||||
typedef float F;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
short2 do_mean_shift(int x0, int y0, __global uchar4* out,int out_step,
|
short2 do_mean_shift(int x0, int y0, __global uchar4* out,int out_step,
|
||||||
__global uchar4* in, int in_step, int dst_off, int src_off,
|
__global uchar4* in, int in_step, int dst_off, int src_off,
|
||||||
@ -184,12 +180,11 @@ short2 do_mean_shift(int x0, int y0, __global uchar4* out,int out_step,
|
|||||||
if( count == 0 )
|
if( count == 0 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
F icount = 1.0/count;
|
int x1 = sx/count;
|
||||||
int x1 = convert_int_rtz(sx*icount);
|
int y1 = sy/count;
|
||||||
int y1 = convert_int_rtz(sy*icount);
|
s.x = s.x/count;
|
||||||
s.x = convert_int_rtz(s.x*icount);
|
s.y = s.y/count;
|
||||||
s.y = convert_int_rtz(s.y*icount);
|
s.z = s.z/count;
|
||||||
s.z = convert_int_rtz(s.z*icount);
|
|
||||||
|
|
||||||
int4 tmp = s - convert_int4(c);
|
int4 tmp = s - convert_int4(c);
|
||||||
int norm2 = tmp.x * tmp.x + tmp.y * tmp.y +
|
int norm2 = tmp.x * tmp.x + tmp.y * tmp.y +
|
||||||
|
@ -183,12 +183,11 @@ COOR do_meanShift(int x0, int y0, uchar *sptr, uchar *dptr, int sstep, cv::Size
|
|||||||
if( count == 0 )
|
if( count == 0 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
double icount = 1.0 / count;
|
int x1 = sx / count;
|
||||||
int x1 = cvFloor(sx * icount);
|
int y1 = sy / count;
|
||||||
int y1 = cvFloor(sy * icount);
|
s0 = s0 / count;
|
||||||
s0 = cvFloor(s0 * icount);
|
s1 = s1 / count;
|
||||||
s1 = cvFloor(s1 * icount);
|
s2 = s2 / count;
|
||||||
s2 = cvFloor(s2 * icount);
|
|
||||||
|
|
||||||
bool stopFlag = (x0 == x1 && y0 == y1) || (abs(x1 - x0) + abs(y1 - y0) +
|
bool stopFlag = (x0 == x1 && y0 == y1) || (abs(x1 - x0) + abs(y1 - y0) +
|
||||||
tab[s0 - c0 + 255] + tab[s1 - c1 + 255] + tab[s2 - c2 + 255] <= eps);
|
tab[s0 - c0 + 255] + tab[s1 - c1 + 255] + tab[s2 - c2 + 255] <= eps);
|
||||||
@ -1370,9 +1369,7 @@ TEST_P(meanShiftFiltering, Mat)
|
|||||||
gdst.download(cpu_gdst);
|
gdst.download(cpu_gdst);
|
||||||
|
|
||||||
char sss[1024];
|
char sss[1024];
|
||||||
char warning[300] = "Warning: If the selected device doesn't support double, a deviation will exist.\nIf the accuracy is acceptable, please ignore it.\n";
|
|
||||||
sprintf(sss, "roicols=%d,roirows=%d,srcx=%d,srcy=%d,dstx=%d,dsty=%d\n", roicols, roirows, srcx, srcy, dstx, dsty);
|
sprintf(sss, "roicols=%d,roirows=%d,srcx=%d,srcy=%d,dstx=%d,dsty=%d\n", roicols, roirows, srcx, srcy, dstx, dsty);
|
||||||
strcat(sss, warning);
|
|
||||||
EXPECT_MAT_NEAR(dst, cpu_gdst, 0.0, sss);
|
EXPECT_MAT_NEAR(dst, cpu_gdst, 0.0, sss);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1398,9 +1395,7 @@ TEST_P(meanShiftProc, Mat)
|
|||||||
gdstCoor.download(cpu_gdstCoor);
|
gdstCoor.download(cpu_gdstCoor);
|
||||||
|
|
||||||
char sss[1024];
|
char sss[1024];
|
||||||
char warning[300] = "Warning: If the selected device doesn't support double, a deviation will exist.\nIf the accuracy is acceptable, please ignore it.\n";
|
|
||||||
sprintf(sss, "roicols=%d,roirows=%d,srcx=%d,srcy=%d,dstx=%d,dsty=%d\n", roicols, roirows, srcx, srcy, dstx, dsty);
|
sprintf(sss, "roicols=%d,roirows=%d,srcx=%d,srcy=%d,dstx=%d,dsty=%d\n", roicols, roirows, srcx, srcy, dstx, dsty);
|
||||||
strcat(sss, warning);
|
|
||||||
EXPECT_MAT_NEAR(dst, cpu_gdst, 0.0, sss);
|
EXPECT_MAT_NEAR(dst, cpu_gdst, 0.0, sss);
|
||||||
EXPECT_MAT_NEAR(dstCoor, cpu_gdstCoor, 0.0, sss);
|
EXPECT_MAT_NEAR(dstCoor, cpu_gdstCoor, 0.0, sss);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user