Commit 77529b1f authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

fixed bugs in CartToPolarToCart test

parent 061b49e0
...@@ -382,7 +382,7 @@ void mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, const in ...@@ -382,7 +382,7 @@ void mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, const in
v[k] = &src[k]; v[k] = &src[k];
for( k = 0; k < n; k++ ) for( k = 0; k < n; k++ )
v[m + k] = &dst[k]; v[m + k] = &dst[k];
NAryMatIterator it(v, planes); NAryMatIterator it(v, planes, m + n);
for( int i = 0; i < it.nplanes; i++, ++it ) for( int i = 0; i < it.nplanes; i++, ++it )
mixChannels( &it.planes[0], m, &it.planes[m], n, fromTo, npairs ); mixChannels( &it.planes[0], m, &it.planes[m], n, fromTo, npairs );
......
...@@ -445,7 +445,7 @@ void cartToPolar( const Mat& X, const Mat& Y, Mat& Mag, Mat& Angle, bool angleIn ...@@ -445,7 +445,7 @@ void cartToPolar( const Mat& X, const Mat& Y, Mat& Mag, Mat& Angle, bool angleIn
NAryMatIterator it(arrays, planes); NAryMatIterator it(arrays, planes);
for( int i = 0; i < it.nplanes; i++, ++it ) for( int i = 0; i < it.nplanes; i++, ++it )
cartToPolar( it.planes[0], it.planes[1], it.planes[2], it.planes[2], angleInDegrees ); cartToPolar( it.planes[0], it.planes[1], it.planes[2], it.planes[3], angleInDegrees );
return; return;
} }
...@@ -604,7 +604,7 @@ void polarToCart( const Mat& Mag, const Mat& Angle, Mat& X, Mat& Y, bool angleIn ...@@ -604,7 +604,7 @@ void polarToCart( const Mat& Mag, const Mat& Angle, Mat& X, Mat& Y, bool angleIn
NAryMatIterator it(arrays, planes); NAryMatIterator it(arrays, planes);
for( int i = 0; i < it.nplanes; i++, ++it ) for( int i = 0; i < it.nplanes; i++, ++it )
polarToCart( it.planes[0], it.planes[1], it.planes[2], it.planes[2], angleInDegrees ); polarToCart( it.planes[0], it.planes[1], it.planes[2], it.planes[3], angleInDegrees );
return; return;
} }
......
...@@ -39,7 +39,7 @@ struct BaseElemWiseOp ...@@ -39,7 +39,7 @@ struct BaseElemWiseOp
ninputs > 1 ? ARITHM_MAX_CHANNELS : 4); ninputs > 1 ? ARITHM_MAX_CHANNELS : 4);
} }
virtual int getMaxErr(int depth) { return depth < CV_32F ? 1 : 256; } virtual double getMaxErr(int depth) { return depth < CV_32F ? 1 : depth == CV_32F ? 1e-5 : 1e-12; }
virtual void generateScalars(int depth, RNG& rng) virtual void generateScalars(int depth, RNG& rng)
{ {
const double m = 3.; const double m = 3.;
...@@ -182,9 +182,9 @@ struct AddWeightedOp : public BaseAddOp ...@@ -182,9 +182,9 @@ struct AddWeightedOp : public BaseAddOp
{ {
addWeighted(src[0], alpha, src[1], beta, gamma[0], dst); addWeighted(src[0], alpha, src[1], beta, gamma[0], dst);
} }
int getMaxErr(int depth) double getMaxErr(int depth)
{ {
return depth <= CV_32S ? 2 : depth < CV_64F ? (1 << 10) : (1 << 22); return depth <= CV_32S ? 2 : depth < CV_64F ? 1e-5 : 1e-10;
} }
}; };
...@@ -199,9 +199,9 @@ struct MulOp : public BaseElemWiseOp ...@@ -199,9 +199,9 @@ struct MulOp : public BaseElemWiseOp
{ {
cvtest::multiply(src[0], src[1], dst, alpha); cvtest::multiply(src[0], src[1], dst, alpha);
} }
int getMaxErr(int depth) double getMaxErr(int depth)
{ {
return depth < CV_32S ? 2 : depth < CV_32F ? 4 : 16; return depth <= CV_32S ? 2 : depth < CV_64F ? 1e-5 : 1e-12;
} }
}; };
...@@ -216,9 +216,9 @@ struct DivOp : public BaseElemWiseOp ...@@ -216,9 +216,9 @@ struct DivOp : public BaseElemWiseOp
{ {
cvtest::divide(src[0], src[1], dst, alpha); cvtest::divide(src[0], src[1], dst, alpha);
} }
int getMaxErr(int depth) double getMaxErr(int depth)
{ {
return depth < CV_32S ? 2 : depth < CV_32F ? 4 : 16; return depth <= CV_32S ? 2 : depth < CV_64F ? 1e-5 : 1e-12;
} }
}; };
...@@ -233,9 +233,9 @@ struct RecipOp : public BaseElemWiseOp ...@@ -233,9 +233,9 @@ struct RecipOp : public BaseElemWiseOp
{ {
cvtest::divide(Mat(), src[0], dst, alpha); cvtest::divide(Mat(), src[0], dst, alpha);
} }
int getMaxErr(int depth) double getMaxErr(int depth)
{ {
return depth < CV_32S ? 2 : depth < CV_32F ? 4 : 16; return depth <= CV_32S ? 2 : depth < CV_64F ? 1e-5 : 1e-12;
} }
}; };
...@@ -288,7 +288,7 @@ struct LogicOp : public BaseElemWiseOp ...@@ -288,7 +288,7 @@ struct LogicOp : public BaseElemWiseOp
else else
cvtest::logicOp(src[0], src[1], dst, opcode); cvtest::logicOp(src[0], src[1], dst, opcode);
} }
int getMaxErr(int depth) double getMaxErr(int depth)
{ {
return 0; return 0;
} }
...@@ -321,7 +321,7 @@ struct LogicSOp : public BaseElemWiseOp ...@@ -321,7 +321,7 @@ struct LogicSOp : public BaseElemWiseOp
else else
cvtest::logicOp(src[0], gamma, dst, opcode); cvtest::logicOp(src[0], gamma, dst, opcode);
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -339,7 +339,7 @@ struct MinOp : public BaseElemWiseOp ...@@ -339,7 +339,7 @@ struct MinOp : public BaseElemWiseOp
{ {
cvtest::min(src[0], src[1], dst); cvtest::min(src[0], src[1], dst);
} }
int getMaxErr(int depth) double getMaxErr(int depth)
{ {
return 0; return 0;
} }
...@@ -356,7 +356,7 @@ struct MaxOp : public BaseElemWiseOp ...@@ -356,7 +356,7 @@ struct MaxOp : public BaseElemWiseOp
{ {
cvtest::max(src[0], src[1], dst); cvtest::max(src[0], src[1], dst);
} }
int getMaxErr(int depth) double getMaxErr(int depth)
{ {
return 0; return 0;
} }
...@@ -373,7 +373,7 @@ struct MinSOp : public BaseElemWiseOp ...@@ -373,7 +373,7 @@ struct MinSOp : public BaseElemWiseOp
{ {
cvtest::min(src[0], gamma[0], dst); cvtest::min(src[0], gamma[0], dst);
} }
int getMaxErr(int depth) double getMaxErr(int depth)
{ {
return 0; return 0;
} }
...@@ -390,7 +390,7 @@ struct MaxSOp : public BaseElemWiseOp ...@@ -390,7 +390,7 @@ struct MaxSOp : public BaseElemWiseOp
{ {
cvtest::max(src[0], gamma[0], dst); cvtest::max(src[0], gamma[0], dst);
} }
int getMaxErr(int depth) double getMaxErr(int depth)
{ {
return 0; return 0;
} }
...@@ -417,7 +417,7 @@ struct CmpOp : public BaseElemWiseOp ...@@ -417,7 +417,7 @@ struct CmpOp : public BaseElemWiseOp
return cvtest::randomType(rng, cvtest::TYPE_MASK_ALL_BUT_8S, 1, 1); return cvtest::randomType(rng, cvtest::TYPE_MASK_ALL_BUT_8S, 1, 1);
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -444,7 +444,7 @@ struct CmpSOp : public BaseElemWiseOp ...@@ -444,7 +444,7 @@ struct CmpSOp : public BaseElemWiseOp
{ {
return cvtest::randomType(rng, cvtest::TYPE_MASK_ALL_BUT_8S, 1, 1); return cvtest::randomType(rng, cvtest::TYPE_MASK_ALL_BUT_8S, 1, 1);
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -467,7 +467,7 @@ struct CopyOp : public BaseElemWiseOp ...@@ -467,7 +467,7 @@ struct CopyOp : public BaseElemWiseOp
{ {
return cvtest::randomType(rng, cvtest::TYPE_MASK_ALL, 1, ARITHM_MAX_CHANNELS); return cvtest::randomType(rng, cvtest::TYPE_MASK_ALL, 1, ARITHM_MAX_CHANNELS);
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -490,7 +490,7 @@ struct SetOp : public BaseElemWiseOp ...@@ -490,7 +490,7 @@ struct SetOp : public BaseElemWiseOp
{ {
return cvtest::randomType(rng, cvtest::TYPE_MASK_ALL, 1, ARITHM_MAX_CHANNELS); return cvtest::randomType(rng, cvtest::TYPE_MASK_ALL, 1, ARITHM_MAX_CHANNELS);
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -645,7 +645,7 @@ struct InRangeSOp : public BaseElemWiseOp ...@@ -645,7 +645,7 @@ struct InRangeSOp : public BaseElemWiseOp
{ {
cvtest::inRangeS(src[0], gamma, gamma1, dst); cvtest::inRangeS(src[0], gamma, gamma1, dst);
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -683,7 +683,7 @@ struct InRangeOp : public BaseElemWiseOp ...@@ -683,7 +683,7 @@ struct InRangeOp : public BaseElemWiseOp
cvtest::inRange(src[0], lb, rb, dst); cvtest::inRange(src[0], lb, rb, dst);
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -707,9 +707,9 @@ struct ConvertScaleOp : public BaseElemWiseOp ...@@ -707,9 +707,9 @@ struct ConvertScaleOp : public BaseElemWiseOp
ddepth = cvtest::randomType(rng, cvtest::TYPE_MASK_ALL, 1, 1); ddepth = cvtest::randomType(rng, cvtest::TYPE_MASK_ALL, 1, 1);
return srctype; return srctype;
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return ddepth <= CV_32S ? 2 : ddepth < CV_64F ? (1 << 14) : (1 << 18); return ddepth <= CV_32S ? 2 : ddepth < CV_64F ? 1e-4 : 1e-12;
} }
void generateScalars(int depth, RNG& rng) void generateScalars(int depth, RNG& rng)
{ {
...@@ -736,6 +736,10 @@ struct ConvertScaleAbsOp : public BaseElemWiseOp ...@@ -736,6 +736,10 @@ struct ConvertScaleAbsOp : public BaseElemWiseOp
{ {
cvtest::add(src[0], alpha, Mat(), 0, Scalar::all(gamma[0]), dst, CV_8UC(src[0].channels()), true); cvtest::add(src[0], alpha, Mat(), 0, Scalar::all(gamma[0]), dst, CV_8UC(src[0].channels()), true);
} }
double getMaxErr(int)
{
return 1;
}
void generateScalars(int depth, RNG& rng) void generateScalars(int depth, RNG& rng)
{ {
if( rng.uniform(0, 2) ) if( rng.uniform(0, 2) )
...@@ -808,7 +812,7 @@ struct FlipOp : public BaseElemWiseOp ...@@ -808,7 +812,7 @@ struct FlipOp : public BaseElemWiseOp
{ {
flipcode = rng.uniform(0, 3) - 1; flipcode = rng.uniform(0, 3) - 1;
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -830,7 +834,7 @@ struct TransposeOp : public BaseElemWiseOp ...@@ -830,7 +834,7 @@ struct TransposeOp : public BaseElemWiseOp
{ {
cvtest::transpose(src[0], dst); cvtest::transpose(src[0], dst);
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -851,7 +855,7 @@ struct SetIdentityOp : public BaseElemWiseOp ...@@ -851,7 +855,7 @@ struct SetIdentityOp : public BaseElemWiseOp
{ {
cvtest::setIdentity(dst, gamma); cvtest::setIdentity(dst, gamma);
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -868,7 +872,7 @@ struct SetZeroOp : public BaseElemWiseOp ...@@ -868,7 +872,7 @@ struct SetZeroOp : public BaseElemWiseOp
{ {
cvtest::set(dst, Scalar::all(0)); cvtest::set(dst, Scalar::all(0));
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -951,9 +955,9 @@ struct ExpOp : public BaseElemWiseOp ...@@ -951,9 +955,9 @@ struct ExpOp : public BaseElemWiseOp
{ {
cvtest::exp(src[0], dst); cvtest::exp(src[0], dst);
} }
int getMaxErr(int) double getMaxErr(int depth)
{ {
return (1<<10); return depth == CV_32F ? 1e-5 : 1e-12;
} }
}; };
...@@ -982,9 +986,9 @@ struct LogOp : public BaseElemWiseOp ...@@ -982,9 +986,9 @@ struct LogOp : public BaseElemWiseOp
cvtest::exp(src[0], temp); cvtest::exp(src[0], temp);
cvtest::log(temp, dst); cvtest::log(temp, dst);
} }
int getMaxErr(int) double getMaxErr(int depth)
{ {
return (1<<10); return depth == CV_32F ? 1e-5 : 1e-12;
} }
}; };
...@@ -1075,9 +1079,9 @@ struct CartToPolarToCartOp : public BaseElemWiseOp ...@@ -1075,9 +1079,9 @@ struct CartToPolarToCartOp : public BaseElemWiseOp
{ {
angleInDegrees = rng.uniform(0, 2) != 0; angleInDegrees = rng.uniform(0, 2) != 0;
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return (1<<10); return 1e-3;
} }
bool angleInDegrees; bool angleInDegrees;
}; };
...@@ -1099,9 +1103,9 @@ struct MeanOp : public BaseElemWiseOp ...@@ -1099,9 +1103,9 @@ struct MeanOp : public BaseElemWiseOp
dst.create(1, 1, CV_64FC4); dst.create(1, 1, CV_64FC4);
dst.at<Scalar>(0,0) = cvtest::mean(src[0], mask); dst.at<Scalar>(0,0) = cvtest::mean(src[0], mask);
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return (1<<13); return 1e-6;
} }
}; };
...@@ -1122,9 +1126,9 @@ struct SumOp : public BaseElemWiseOp ...@@ -1122,9 +1126,9 @@ struct SumOp : public BaseElemWiseOp
dst.create(1, 1, CV_64FC4); dst.create(1, 1, CV_64FC4);
dst.at<Scalar>(0,0) = cvtest::mean(src[0])*(double)src[0].total(); dst.at<Scalar>(0,0) = cvtest::mean(src[0])*(double)src[0].total();
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return (1<<13); return 1e-6;
} }
}; };
...@@ -1155,7 +1159,7 @@ struct CountNonZeroOp : public BaseElemWiseOp ...@@ -1155,7 +1159,7 @@ struct CountNonZeroOp : public BaseElemWiseOp
dst.create(1, 1, CV_32S); dst.create(1, 1, CV_32S);
dst.at<int>(0,0) = saturate_cast<int>(cvtest::mean(temp)[0]/255*temp.total()); dst.at<int>(0,0) = saturate_cast<int>(cvtest::mean(temp)[0]/255*temp.total());
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -1188,9 +1192,9 @@ struct MeanStdDevOp : public BaseElemWiseOp ...@@ -1188,9 +1192,9 @@ struct MeanStdDevOp : public BaseElemWiseOp
dst.at<Scalar>(0,0) = mean; dst.at<Scalar>(0,0) = mean;
dst.at<Scalar>(0,1) = sqmean; dst.at<Scalar>(0,1) = sqmean;
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return (1<<13); return 1e-6;
} }
}; };
...@@ -1222,9 +1226,9 @@ struct NormOp : public BaseElemWiseOp ...@@ -1222,9 +1226,9 @@ struct NormOp : public BaseElemWiseOp
{ {
normType = 1 << rng.uniform(0, 3); normType = 1 << rng.uniform(0, 3);
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return (1<<13); return 1e-6;
} }
int normType; int normType;
}; };
...@@ -1270,7 +1274,7 @@ struct MinMaxLocOp : public BaseElemWiseOp ...@@ -1270,7 +1274,7 @@ struct MinMaxLocOp : public BaseElemWiseOp
cvtest::minMaxLoc(src[0], &minval, &maxval, &minidx, &maxidx, mask); cvtest::minMaxLoc(src[0], &minval, &maxval, &minidx, &maxidx, mask);
saveOutput(minidx, maxidx, minval, maxval, dst); saveOutput(minidx, maxidx, minval, maxval, dst);
} }
int getMaxErr(int) double getMaxErr(int)
{ {
return 0; return 0;
} }
...@@ -1375,5 +1379,4 @@ INSTANTIATE_TEST_CASE_P(Core_MeanStdDev, ElemWiseTest, ::testing::Values(ElemWis ...@@ -1375,5 +1379,4 @@ INSTANTIATE_TEST_CASE_P(Core_MeanStdDev, ElemWiseTest, ::testing::Values(ElemWis
INSTANTIATE_TEST_CASE_P(Core_Sum, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new cvtest::SumOp))); INSTANTIATE_TEST_CASE_P(Core_Sum, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new cvtest::SumOp)));
INSTANTIATE_TEST_CASE_P(Core_Norm, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new cvtest::NormOp))); INSTANTIATE_TEST_CASE_P(Core_Norm, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new cvtest::NormOp)));
INSTANTIATE_TEST_CASE_P(Core_MinMaxLoc, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new cvtest::MinMaxLocOp))); INSTANTIATE_TEST_CASE_P(Core_MinMaxLoc, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new cvtest::MinMaxLocOp)));
INSTANTIATE_TEST_CASE_P(Core_CartToPolarToCart, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new cvtest::CartToPolarToCartOp))); INSTANTIATE_TEST_CASE_P(Core_CartToPolarToCart, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new cvtest::CartToPolarToCartOp)));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment