|
|
|
@ -15,7 +15,6 @@ |
|
|
|
|
#endif // HAVE_OPENCV_VIDEO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace opencv_test |
|
|
|
|
{ |
|
|
|
|
namespace |
|
|
|
@ -128,6 +127,54 @@ struct OptFlowLKTestParams |
|
|
|
|
int flags = 0; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
inline void compareOutputPyramids(const BuildOpticalFlowPyramidTestOutput& outGAPI, |
|
|
|
|
const BuildOpticalFlowPyramidTestOutput& outOCV) |
|
|
|
|
{ |
|
|
|
|
GAPI_Assert(outGAPI.maxLevel == outOCV.maxLevel); |
|
|
|
|
GAPI_Assert(outOCV.maxLevel >= 0); |
|
|
|
|
const size_t maxLevel = static_cast<size_t>(outOCV.maxLevel); |
|
|
|
|
for (size_t i = 0; i <= maxLevel; i++) |
|
|
|
|
{ |
|
|
|
|
EXPECT_TRUE(AbsExact().to_compare_f()(outGAPI.pyramid[i], outOCV.pyramid[i])); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <typename Elem> |
|
|
|
|
inline bool compareVectorsAbsExactForOptFlow(const std::vector<Elem>& outGAPI, |
|
|
|
|
const std::vector<Elem>& outOCV) |
|
|
|
|
{ |
|
|
|
|
return AbsExactVector<Elem>().to_compare_f()(outGAPI, outOCV); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline void compareOutputsOptFlow(const OptFlowLKTestOutput& outGAPI, |
|
|
|
|
const OptFlowLKTestOutput& outOCV) |
|
|
|
|
{ |
|
|
|
|
EXPECT_TRUE(compareVectorsAbsExactForOptFlow(outGAPI.nextPoints, outOCV.nextPoints)); |
|
|
|
|
EXPECT_TRUE(compareVectorsAbsExactForOptFlow(outGAPI.statuses, outOCV.statuses)); |
|
|
|
|
EXPECT_TRUE(compareVectorsAbsExactForOptFlow(outGAPI.errors, outOCV.errors)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, const cv::TermCriteria& criteria) |
|
|
|
|
{ |
|
|
|
|
os << "{"; |
|
|
|
|
switch (criteria.type) { |
|
|
|
|
case cv::TermCriteria::COUNT: |
|
|
|
|
os << "COUNT; "; |
|
|
|
|
break; |
|
|
|
|
case cv::TermCriteria::EPS: |
|
|
|
|
os << "EPS; "; |
|
|
|
|
break; |
|
|
|
|
case cv::TermCriteria::COUNT | cv::TermCriteria::EPS: |
|
|
|
|
os << "COUNT | EPS; "; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
os << "TypeUndefined; "; |
|
|
|
|
break; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return os << criteria.maxCount << "; " << criteria.epsilon <<"}"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENCV_VIDEO |
|
|
|
|
|
|
|
|
|
inline GComputation runOCVnGAPIBuildOptFlowPyramid(TestFunctional& testInst, |
|
|
|
@ -390,54 +437,24 @@ inline GComputation runOCVnGAPIOptFlowPipeline(TestFunctional&, |
|
|
|
|
|
|
|
|
|
#endif // HAVE_OPENCV_VIDEO
|
|
|
|
|
|
|
|
|
|
inline void compareOutputPyramids(const BuildOpticalFlowPyramidTestOutput& outGAPI, |
|
|
|
|
const BuildOpticalFlowPyramidTestOutput& outOCV) |
|
|
|
|
{ |
|
|
|
|
GAPI_Assert(outGAPI.maxLevel == outOCV.maxLevel); |
|
|
|
|
GAPI_Assert(outOCV.maxLevel >= 0); |
|
|
|
|
size_t maxLevel = static_cast<size_t>(outOCV.maxLevel); |
|
|
|
|
for (size_t i = 0; i <= maxLevel; i++) |
|
|
|
|
{ |
|
|
|
|
EXPECT_TRUE(AbsExact().to_compare_f()(outGAPI.pyramid[i], outOCV.pyramid[i])); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <typename Elem> |
|
|
|
|
inline bool compareVectorsAbsExactForOptFlow(std::vector<Elem> outGAPI, std::vector<Elem> outOCV) |
|
|
|
|
{ |
|
|
|
|
return AbsExactVector<Elem>().to_compare_f()(outGAPI, outOCV); |
|
|
|
|
} |
|
|
|
|
} // namespace
|
|
|
|
|
} // namespace opencv_test
|
|
|
|
|
|
|
|
|
|
inline void compareOutputsOptFlow(const OptFlowLKTestOutput& outGAPI, |
|
|
|
|
const OptFlowLKTestOutput& outOCV) |
|
|
|
|
// Note: namespace must match the namespace of the type of the printed object
|
|
|
|
|
namespace cv { namespace gapi { namespace video |
|
|
|
|
{ |
|
|
|
|
EXPECT_TRUE(compareVectorsAbsExactForOptFlow(outGAPI.nextPoints, outOCV.nextPoints)); |
|
|
|
|
EXPECT_TRUE(compareVectorsAbsExactForOptFlow(outGAPI.statuses, outOCV.statuses)); |
|
|
|
|
EXPECT_TRUE(compareVectorsAbsExactForOptFlow(outGAPI.errors, outOCV.errors)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, const cv::TermCriteria& criteria) |
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, const BackgroundSubtractorType op) |
|
|
|
|
{ |
|
|
|
|
os << "{"; |
|
|
|
|
switch (criteria.type) { |
|
|
|
|
case cv::TermCriteria::COUNT: |
|
|
|
|
os << "COUNT; "; |
|
|
|
|
break; |
|
|
|
|
case cv::TermCriteria::EPS: |
|
|
|
|
os << "EPS; "; |
|
|
|
|
break; |
|
|
|
|
case cv::TermCriteria::COUNT | cv::TermCriteria::EPS: |
|
|
|
|
os << "COUNT | EPS; "; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
os << "TypeUndefined; "; |
|
|
|
|
break; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return os << criteria.maxCount << "; " << criteria.epsilon <<"}"; |
|
|
|
|
#define CASE(v) case BackgroundSubtractorType::v: os << #v; break |
|
|
|
|
switch (op) |
|
|
|
|
{ |
|
|
|
|
CASE(TYPE_BS_MOG2); |
|
|
|
|
CASE(TYPE_BS_KNN); |
|
|
|
|
default: GAPI_Assert(false && "unknown BackgroundSubtractor type"); |
|
|
|
|
} |
|
|
|
|
#undef CASE |
|
|
|
|
return os; |
|
|
|
|
} |
|
|
|
|
} // namespace
|
|
|
|
|
} // namespace opencv_test
|
|
|
|
|
|
|
|
|
|
}}} // namespace cv::gapi::video
|
|
|
|
|
|
|
|
|
|
#endif // OPENCV_GAPI_VIDEO_TESTS_COMMON_HPP
|
|
|
|
|