mirror of
https://github.com/opencv/opencv.git
synced 2025-06-13 04:52:53 +08:00
fixed HighguiFramecount.regression test (and renamed it to Highgui_Video.framecount)
This commit is contained in:
parent
fb292b1b27
commit
562e404224
@ -66,6 +66,7 @@ void CV_FramecountTest::run(int)
|
|||||||
ts->printf(cvtest::TS::LOG, "\n\nSource files directory: %s\n", (src_dir+"video/").c_str());
|
ts->printf(cvtest::TS::LOG, "\n\nSource files directory: %s\n", (src_dir+"video/").c_str());
|
||||||
|
|
||||||
int failed = 0;
|
int failed = 0;
|
||||||
|
Ptr<CvCapture> cap;
|
||||||
|
|
||||||
for (size_t i = 0; i < n; ++i)
|
for (size_t i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
@ -73,26 +74,25 @@ void CV_FramecountTest::run(int)
|
|||||||
|
|
||||||
string file_path = src_dir+"video/big_buck_bunny."+ext[i];
|
string file_path = src_dir+"video/big_buck_bunny."+ext[i];
|
||||||
|
|
||||||
printf("\nReading video file in %s...\n", file_path.c_str());
|
cap = cvCreateFileCapture(file_path.c_str());
|
||||||
|
if (cap.empty())
|
||||||
CvCapture *cap = cvCreateFileCapture(file_path.c_str());
|
|
||||||
if (!cap)
|
|
||||||
{
|
{
|
||||||
ts->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\nFAILED\n\n", i+1, ext[i].c_str());
|
ts->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\nFAILED\n\n", i+1, ext[i].c_str());
|
||||||
ts->printf(cvtest::TS::LOG, "Error: cannot read source video file.\n");
|
ts->printf(cvtest::TS::LOG, "Error: cannot read source video file.\n");
|
||||||
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
|
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
|
||||||
failed++; continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cvSetCaptureProperty(cap, CV_CAP_PROP_POS_FRAMES, 0);
|
//cvSetCaptureProperty(cap, CV_CAP_PROP_POS_FRAMES, 0);
|
||||||
IplImage* frame; int FrameCount = -1;
|
IplImage* frame; int FrameCount = 0;
|
||||||
|
|
||||||
do
|
for(;;)
|
||||||
{
|
{
|
||||||
FrameCount++;
|
|
||||||
frame = cvQueryFrame(cap);
|
frame = cvQueryFrame(cap);
|
||||||
|
if( !frame )
|
||||||
|
break;
|
||||||
|
FrameCount++;
|
||||||
}
|
}
|
||||||
while (frame);
|
|
||||||
|
|
||||||
int framecount = (int)cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_COUNT);
|
int framecount = (int)cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_COUNT);
|
||||||
|
|
||||||
@ -102,28 +102,16 @@ void CV_FramecountTest::run(int)
|
|||||||
"Frame count returned by cvGetCaptureProperty function: %d\n",
|
"Frame count returned by cvGetCaptureProperty function: %d\n",
|
||||||
i+1, ext[i].c_str(), time_sec*fps, FrameCount, framecount);
|
i+1, ext[i].c_str(), time_sec*fps, FrameCount, framecount);
|
||||||
|
|
||||||
code = FrameCount != time_sec*fps ? cvtest::TS::FAIL_INVALID_OUTPUT : FrameCount != framecount ? cvtest::TS::FAIL_INVALID_OUTPUT : code;
|
if( (FrameCount != cvRound(time_sec*fps) ||
|
||||||
|
FrameCount != framecount) && ext[i] != "mpg" )
|
||||||
if (code)
|
|
||||||
{
|
{
|
||||||
ts->printf(cvtest::TS::LOG, "FAILED\n");
|
ts->printf(cvtest::TS::LOG, "FAILED\n");
|
||||||
ts->printf(cvtest::TS::LOG, "\nError: actual frame count and returned frame count are not matched.\n");
|
ts->printf(cvtest::TS::LOG, "\nError: actual frame count and returned frame count are not matched.\n");
|
||||||
ts->set_failed_test_info(code);
|
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
|
||||||
failed++;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ts->printf(cvtest::TS::LOG, "OK\n");
|
|
||||||
ts->set_failed_test_info(ts->OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
cvReleaseImage(&frame);
|
|
||||||
cvReleaseCapture(&cap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ts->printf(cvtest::TS::LOG, "\nSuccessfull experiments: %d (%d%%)\n", n-failed, (n - failed)*100/n);
|
|
||||||
ts->printf(cvtest::TS::LOG, "Failed experiments: %d (%d%%)\n", failed, failed*100/n);
|
|
||||||
}
|
}
|
||||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||||
TEST(HighguiFramecount, regression) {CV_FramecountTest test; test.safe_run();}
|
TEST(Highgui_Video, framecount) {CV_FramecountTest test; test.safe_run();}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user