Updated test_video_pos.cpp
authorAlexander Reshetnikov <no@email>
Wed, 28 Mar 2012 11:33:36 +0000 (11:33 +0000)
committerAlexander Reshetnikov <no@email>
Wed, 28 Mar 2012 11:33:36 +0000 (11:33 +0000)
modules/highgui/test/test_video_pos.cpp

index bf6de1f..d787758 100755 (executable)
@@ -66,7 +66,7 @@ void CV_PositioningTest::CreateTestVideo(const string& format, int codec, int fr
  for (int i = 0; i < framecount; ++i)\r
  {\r
    cv::Mat mat(480, 640, CV_8UC1);\r
-   size_t n = 32, tmp = i;\r
+   size_t n = 8, tmp = i;\r
 \r
    vector<char> tmp_code; tmp_code.clear();\r
 \r
@@ -113,10 +113,12 @@ void CV_PositioningTest::run(int)
     size_t n_format = sizeof(format)/sizeof(format[0]),\r
            n_codec = sizeof(codec)/sizeof(codec[0]);\r
 \r
+    int n_frames = 256;\r
+\r
     for (size_t i = 0; i < n_format; ++i)\r
     for (size_t j = 0; j < n_codec; ++j)\r
     {\r
-      CreateTestVideo(format[i], CV_FOURCC(codec[j][0], codec[j][1], codec[j][2], codec[j][3]), 125);\r
+      CreateTestVideo(format[i], CV_FOURCC(codec[j][0], codec[j][1], codec[j][2], codec[j][3]), n_frames);\r
 \r
       stringstream s; s << CV_FOURCC(codec[j][0], codec[j][1], codec[j][2], codec[j][3]); //codec_bmp_tags[j].tag;\r
 \r
@@ -128,9 +130,9 @@ void CV_PositioningTest::run(int)
 \r
       if (!cap.isOpened())\r
       {\r
-        ts->printf(ts->LOG, "\nFile: %s\n", file_path.c_str());\r
+        ts->printf(ts->LOG, "\n\nFile: %s\n", file_path.c_str());\r
         ts->printf(ts->LOG, "\nVideo codec: %s\n", string(&codec[j][0], 4).c_str());\r
-        ts->printf(ts->LOG, "\nError: cannot read video file.\n");\r
+        ts->printf(ts->LOG, "\nError: cannot read video file.");\r
         ts->set_failed_test_info(ts->FAIL_INVALID_TEST_DATA);\r
         error = true;\r
       }\r
@@ -139,11 +141,11 @@ void CV_PositioningTest::run(int)
 \r
       int N = cap.get(CV_CAP_PROP_FRAME_COUNT);\r
 \r
-      if (N != 125)\r
+      if (N != n_frames)\r
       {\r
         if (!error)\r
         {\r
-            ts->printf(ts->LOG, "\nFile: %s\n", file_path.c_str());\r
+            ts->printf(ts->LOG, "\n\nFile: %s\n", file_path.c_str());\r
             ts->printf(ts->LOG, "\nVideo codec: %s\n", string(&codec[j][0], 4).c_str());\r
             error = true;\r
         }\r
@@ -170,17 +172,17 @@ void CV_PositioningTest::run(int)
         {\r
             if (!error)\r
             {\r
-                ts->printf(ts->LOG, "\nFile: %s\n", file_path.c_str());\r
+                ts->printf(ts->LOG, "\n\nFile: %s\n", file_path.c_str());\r
                 ts->printf(ts->LOG, "\nVideo codec: %s\n", string(&codec[j][0], 4).c_str());\r
                 error = true;\r
             }\r
             ts->printf(ts->LOG, "\nError: cannot read a frame in position %d.\n", idx[k]);\r
-            ts->set_failed_test_info(ts->FAIL_EXCEPTION);\r
+            ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);\r
         }\r
 \r
         const double thresh = 100;\r
 \r
-        const size_t n = 32, w = img.rows/n;\r
+        const size_t n = 8, w = img.rows/n;\r
 \r
         int index = 0, deg = n-1;\r
 \r
@@ -199,20 +201,22 @@ void CV_PositioningTest::run(int)
         {\r
             if (!error)\r
             {\r
-                ts->printf(ts->LOG, "\nFile: %s\n", file_path.c_str());\r
+                ts->printf(ts->LOG, "\n\nFile: %s\n", file_path.c_str());\r
                 ts->printf(ts->LOG, "\nVideo codec: %s\n\n", string(&codec[j][0], 4).c_str());\r
                 error = true;\r
             }\r
-            ts->printf(ts->LOG, "Required position: %d   Returned position: %d FAILED\n", idx[k], index);\r
+            ts->printf(ts->LOG, "Required position: %d   Returned position: %d\n", idx[k], index);\r
             ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);\r
             failed++;\r
         }\r
       }\r
 \r
-      if (!error) ts->printf(ts->LOG, "\nFile: %s\n", file_path.c_str());\r
+      if (!error) { ts->printf(ts->LOG, "\n\nFile: %s\n", file_path.c_str());\r
+                    ts->printf(ts->LOG, "\nVideo codec: %s\n", string(&codec[j][0], 4).c_str()); }\r
 \r
-      ts->printf(ts->LOG, "\nSuccessfull iterations: %d(%d%%)   Failed iterations: %d(%d%%)\n", N-failed, (N-failed)*100/N, failed, failed*100/N);\r
-      ts->printf(ts->LOG, "\n----------\n");\r
+      const string status = failed ? "FAILED" : "OK";\r
+      ts->printf(ts->LOG, "\nSuccessfull iterations: %d(%d%%)   Failed iterations: %d(%d%%)   %s\n", N-failed, (N-failed)*100/N, failed, failed*100/N, status.c_str());\r
+      if( i < n_format-1 || j < n_codec-1 ) ts->printf(ts->LOG, "\n----------");\r
     }\r
 \r
 #endif\r