fixed build errors on Linux + fixed Farneback optical flow sample
This commit is contained in:
parent
b38a11e837
commit
4b7aaf2e48
@ -1631,7 +1631,7 @@ void compare(const Mat& src, double value, Mat& dst, int cmpop)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename _Tp> static double
|
template<typename _Tp> double
|
||||||
cmpUlpsInt_(const _Tp* src1, const _Tp* src2, size_t total, int imaxdiff,
|
cmpUlpsInt_(const _Tp* src1, const _Tp* src2, size_t total, int imaxdiff,
|
||||||
size_t startidx, size_t& idx)
|
size_t startidx, size_t& idx)
|
||||||
{
|
{
|
||||||
@ -1651,7 +1651,7 @@ cmpUlpsInt_(const _Tp* src1, const _Tp* src2, size_t total, int imaxdiff,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<> static double cmpUlpsInt_<int>(const int* src1, const int* src2,
|
template<> double cmpUlpsInt_<int>(const int* src1, const int* src2,
|
||||||
size_t total, int imaxdiff,
|
size_t total, int imaxdiff,
|
||||||
size_t startidx, size_t& idx)
|
size_t startidx, size_t& idx)
|
||||||
{
|
{
|
||||||
@ -1671,17 +1671,17 @@ template<> static double cmpUlpsInt_<int>(const int* src1, const int* src2,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename _Tp> static double
|
static double
|
||||||
cmpUlpsFlt_(const _Tp* src1, const _Tp* src2, size_t total, int imaxdiff, size_t startidx, size_t& idx)
|
cmpUlpsFlt_(const int* src1, const int* src2, size_t total, int imaxdiff, size_t startidx, size_t& idx)
|
||||||
{
|
{
|
||||||
const _Tp C = ((_Tp)1 << (sizeof(_Tp)*8-1)) - 1;
|
const int C = 0x7fffffff;
|
||||||
_Tp realmaxdiff = 0;
|
int realmaxdiff = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
for( i = 0; i < total; i++ )
|
for( i = 0; i < total; i++ )
|
||||||
{
|
{
|
||||||
_Tp a = src1[i], b = src2[i];
|
int a = src1[i], b = src2[i];
|
||||||
if( a < 0 ) a ^= C; if( b < 0 ) b ^= C;
|
if( a < 0 ) a ^= C; if( b < 0 ) b ^= C;
|
||||||
_Tp diff = std::abs(a - b);
|
int diff = std::abs(a - b);
|
||||||
if( realmaxdiff < diff )
|
if( realmaxdiff < diff )
|
||||||
{
|
{
|
||||||
realmaxdiff = diff;
|
realmaxdiff = diff;
|
||||||
@ -1693,6 +1693,27 @@ cmpUlpsFlt_(const _Tp* src1, const _Tp* src2, size_t total, int imaxdiff, size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static double
|
||||||
|
cmpUlpsFlt_(const int64* src1, const int64* src2, size_t total, int imaxdiff, size_t startidx, size_t& idx)
|
||||||
|
{
|
||||||
|
const int64 C = CV_BIG_INT(0x7fffffffffffffff);
|
||||||
|
double realmaxdiff = 0;
|
||||||
|
size_t i;
|
||||||
|
for( i = 0; i < total; i++ )
|
||||||
|
{
|
||||||
|
int64 a = src1[i], b = src2[i];
|
||||||
|
if( a < 0 ) a ^= C; if( b < 0 ) b ^= C;
|
||||||
|
double diff = fabs((double)a - (double)b);
|
||||||
|
if( realmaxdiff < diff )
|
||||||
|
{
|
||||||
|
realmaxdiff = diff;
|
||||||
|
if( diff > imaxdiff && idx == 0 )
|
||||||
|
idx = i + startidx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return realmaxdiff;
|
||||||
|
}
|
||||||
|
|
||||||
bool cmpUlps(const Mat& src1, const Mat& src2, int imaxDiff, double* _realmaxdiff, vector<int>* loc)
|
bool cmpUlps(const Mat& src1, const Mat& src2, int imaxDiff, double* _realmaxdiff, vector<int>* loc)
|
||||||
{
|
{
|
||||||
CV_Assert( src1.type() == src2.type() && src1.size == src2.size );
|
CV_Assert( src1.type() == src2.type() && src1.size == src2.size );
|
||||||
|
@ -46,7 +46,7 @@ int main(int, char**)
|
|||||||
|
|
||||||
if( prevgray.data )
|
if( prevgray.data )
|
||||||
{
|
{
|
||||||
(prevgray, gray, flow, 0.5, 3, 15, 3, 5, 1.2, 0);
|
calcOpticalFlowFarneback(prevgray, gray, flow, 0.5, 3, 15, 3, 5, 1.2, 0);
|
||||||
cvtColor(prevgray, cflow, CV_GRAY2BGR);
|
cvtColor(prevgray, cflow, CV_GRAY2BGR);
|
||||||
drawOptFlowMap(flow, cflow, 16, 1.5, CV_RGB(0, 255, 0));
|
drawOptFlowMap(flow, cflow, 16, 1.5, CV_RGB(0, 255, 0));
|
||||||
imshow("flow", cflow);
|
imshow("flow", cflow);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user