@@ -1307,6 +1307,14 @@ TEST(AffineFrameTransformerTest, RotateFullFrame) {
13071307}
13081308
13091309
1310+ bool isSameImage (const cv::Mat &im1, const cv::Mat &im2) {
1311+ if (im1.size () != im2.size ()) {
1312+ return false ;
1313+ }
1314+ return std::equal (im1.begin <Pixel>(), im1.end <Pixel>(), im2.begin <Pixel>());
1315+ }
1316+
1317+
13101318TEST (AffineFrameTransformerTest, TestRotationThreshold) {
13111319 const auto *test_img_path = " test/test_imgs/rotation/hello-world.png" ;
13121320 auto original_img = cv::imread (test_img_path);
@@ -1315,14 +1323,14 @@ TEST(AffineFrameTransformerTest, TestRotationThreshold) {
13151323 { {" ROTATION" , " 10" }, {" ROTATION_THRESHOLD" , " 10.001" } }, {});
13161324
13171325 auto img = MPFImageReader (job).GetImage ();
1318- ASSERT_EQ ( 0 , cv::countNonZero ( img != original_img ));
1326+ ASSERT_TRUE ( isSameImage (original_img, img));
13191327 }
13201328 {
13211329 MPFImageJob job (" test" , test_img_path,
13221330 { {" ROTATION" , " 10" }, {" ROTATION_THRESHOLD" , " 9.99" } }, {});
13231331
13241332 auto img = MPFImageReader (job).GetImage ();
1325- ASSERT_NE (original_img. size () , img. size ( ));
1333+ ASSERT_FALSE ( isSameImage (original_img , img));
13261334 }
13271335}
13281336
@@ -1337,13 +1345,13 @@ TEST(AffineFrameTransformerTest, TestRotationThresholdWithFeedForward) {
13371345 MPFImageJob job (" test" , test_img_path, ff_img_loc,
13381346 { {" ROTATION_THRESHOLD" , " 5.12" }, {" FEED_FORWARD_TYPE" , " REGION" } }, {});
13391347 auto img = MPFImageReader (job).GetImage ();
1340- ASSERT_EQ ( 0 , cv::countNonZero ( img != original_img ));
1348+ ASSERT_TRUE ( isSameImage (original_img, img));
13411349 }
13421350 {
13431351 MPFImageJob job (" test" , test_img_path, ff_img_loc,
13441352 { {" ROTATION_THRESHOLD" , " 5.00" }, {" FEED_FORWARD_TYPE" , " REGION" } }, {});
13451353 auto img = MPFImageReader (job).GetImage ();
1346- ASSERT_NE ( 0 , cv::countNonZero ( img != original_img ));
1354+ ASSERT_FALSE ( isSameImage (original_img, img));
13471355 }
13481356}
13491357
0 commit comments