Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
a41b0902
Commit
a41b0902
authored
Jan 31, 2012
by
Alexander Reshetnikov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prepared some videos for future tests. Added first version of common positioning video test.
parent
fef90e22
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
148 additions
and
5 deletions
+148
-5
cap_ffmpeg_impl.hpp
modules/highgui/src/cap_ffmpeg_impl.hpp
+4
-1
test_pos.cpp
modules/highgui/test/test_pos.cpp
+120
-0
test_video_io.cpp
modules/highgui/test/test_video_io.cpp
+24
-4
No files found.
modules/highgui/src/cap_ffmpeg_impl.hpp
View file @
a41b0902
...
@@ -507,6 +507,9 @@ bool CvCapture_FFMPEG::reopen()
...
@@ -507,6 +507,9 @@ bool CvCapture_FFMPEG::reopen()
#ifndef AVSEEK_FLAG_FRAME
#ifndef AVSEEK_FLAG_FRAME
#define AVSEEK_FLAG_FRAME 0
#define AVSEEK_FLAG_FRAME 0
#endif
#endif
ifndef
AVSEEK_FLAG_ANY
#define AVSEEK_FLAG_ANY 1
#endif
bool
CvCapture_FFMPEG
::
open
(
const
char
*
_filename
)
bool
CvCapture_FFMPEG
::
open
(
const
char
*
_filename
)
{
{
...
@@ -832,7 +835,7 @@ bool CvCapture_FFMPEG::setProperty( int property_id, double value )
...
@@ -832,7 +835,7 @@ bool CvCapture_FFMPEG::setProperty( int property_id, double value )
}
}
else
else
{
{
int
flags
=
AVSEEK_FLAG_
FRAME
;
int
flags
=
AVSEEK_FLAG_
ANY
;
if
(
timestamp
<
ic
->
streams
[
video_stream
]
->
cur_dts
)
if
(
timestamp
<
ic
->
streams
[
video_stream
]
->
cur_dts
)
flags
|=
AVSEEK_FLAG_BACKWARD
;
flags
|=
AVSEEK_FLAG_BACKWARD
;
int
ret
=
av_seek_frame
(
ic
,
video_stream
,
timestamp
,
flags
);
int
ret
=
av_seek_frame
(
ic
,
video_stream
,
timestamp
,
flags
);
...
...
modules/highgui/test/test_pos.cpp
0 → 100644
View file @
a41b0902
#include "test_precomp.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdio.h>
/* #include <cv.h>
#include <cxcore.h>
#include <iostream>
#include <sstream>
#include <string> */
using
namespace
cv
;
using
namespace
std
;
//ticket #1497
#define HIGHGUI_POSITIONING_ERROR_OPEN 0
#define MESSAGE_ERROR_CONTENT "Cannot read source video file."
class
CV_VideoPositioningTest
:
public
cvtest
::
BaseTest
{
public
:
void
run
(
int
);
};
void
CV_VideoPositioningTest
::
run
(
int
)
{
const
string
&
src_dir
=
ts
->
get_data_path
();
std
::
cout
<<
src_dir
.
c_str
()
<<
endl
;
string
file_path
=
"/home/reshetnikov/SVN_Projects/OpenCV/opencv_extra/testdata/perf/video/sample_sorenson.mov"
;
std
::
cout
<<
file_path
.
c_str
()
<<
endl
;
cv
::
VideoCapture
cap
(
file_path
);
// CvCapture* cap = cvCreateFileCapture(file_path.c_str());
if
(
!
cap
.
isOpened
())
{
printf
(
"Error!"
);
return
;
}
std
::
cout
<<
"Frame pos: "
<<
cap
.
get
(
CV_CAP_PROP_POS_FRAMES
)
<<
std
::
endl
;
// IplImage* frame = cvQueryFrame(cap);
Mat
frame
;
cap
>>
frame
;
/* if (!frame)
{
return;
} */
std
::
cout
<<
"Frames number: "
<<
cap
.
get
(
CV_CAP_PROP_FRAME_COUNT
)
<<
std
::
endl
;
int
step
=
20
;
int
frameCount
=
1
;
while
(
frameCount
<
100
)
{
std
::
cout
<<
"Frame count: "
<<
frameCount
<<
"
\t
Actual frame pos: "
<<
cap
.
get
(
CV_CAP_PROP_POS_FRAMES
)
<<
std
::
endl
;
// Save the frame
std
::
stringstream
ss
;
ss
<<
frameCount
;
std
::
string
filename
=
ss
.
str
()
+
".png"
;
imwrite
(
file_path
,
frame
,
vector
<
int
>
(
1
));
// Advance by step frames
frameCount
+=
step
;
std
::
cout
<<
"cvSetCaptureProperty result: "
<<
cap
.
set
(
CV_CAP_PROP_POS_FRAMES
,
frameCount
)
<<
std
::
endl
;;
// frame = cvQueryFrame(cap);
}
// cvReleaseCapture(&cap);
cap
.
release
();
}
/*
47 NOTES
48
49 Output:
50 Frame pos: 0
51 Frame count: 1 Actual frame pos: -1.84467e+017
52 cvSetCaptureProperty result: 1
53 Frame count: 21 Actual frame pos: -1.84467e+017
54 cvSetCaptureProperty result: 1
55 Frame count: 41 Actual frame pos: -1.84467e+017
56 cvSetCaptureProperty result: 1
57 Frame count: 61 Actual frame pos: -1.84467e+017
58 cvSetCaptureProperty result: 1
59 Frame count: 81 Actual frame pos: -1.84467e+017
60 cvSetCaptureProperty result: 1
61
62 Expected:
63 Frame pos: 0
64 Frame count: 1 Actual frame pos: 1
65 cvSetCaptureProperty result: 1
66 Frame count: 21 Actual frame pos: 21
67 cvSetCaptureProperty result: 1
68 Frame count: 41 Actual frame pos: 41
69 cvSetCaptureProperty result: 1
70 Frame count: 61 Actual frame pos: 61
71 cvSetCaptureProperty result: 1
72 Frame count: 81 Actual frame pos: 81
73 cvSetCaptureProperty result: 1
74
75 In addition, the frame retrieved from cvQueryFrame was not the correct frame
76 */
TEST
(
HighguiPositioning
,
regression
)
{
CV_VideoPositioningTest
test
;
test
.
safe_run
();
}
modules/highgui/test/test_video_io.cpp
View file @
a41b0902
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
#include "test_precomp.hpp"
#include "test_precomp.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "stdio.h"
using
namespace
cv
;
using
namespace
cv
;
using
namespace
std
;
using
namespace
std
;
...
@@ -56,6 +57,12 @@ public:
...
@@ -56,6 +57,12 @@ public:
void
run
(
int
);
void
run
(
int
);
};
};
class
CV_PositioningTest
:
public
cvtest
::
BaseTest
{
public
:
void
run
(
int
);
};
double
PSNR
(
const
Mat
&
m1
,
const
Mat
&
m2
)
double
PSNR
(
const
Mat
&
m1
,
const
Mat
&
m2
)
{
{
Mat
tmp
;
Mat
tmp
;
...
@@ -232,6 +239,11 @@ void CV_HighGuiTest::VideoTest(const string& dir, int fourcc)
...
@@ -232,6 +239,11 @@ void CV_HighGuiTest::VideoTest(const string& dir, int fourcc)
ts
->
printf
(
ts
->
LOG
,
"end test function : ImagesVideo
\n
"
);
ts
->
printf
(
ts
->
LOG
,
"end test function : ImagesVideo
\n
"
);
}
}
void
CV_PositioningTest
::
run
(
int
)
{
}
void
CV_HighGuiTest
::
run
(
int
/*start_from */
)
void
CV_HighGuiTest
::
run
(
int
/*start_from */
)
{
{
...
@@ -240,13 +252,21 @@ void CV_HighGuiTest::run( int /*start_from */)
...
@@ -240,13 +252,21 @@ void CV_HighGuiTest::run( int /*start_from */)
#if defined WIN32 || (defined __linux__ && !defined ANDROID)
#if defined WIN32 || (defined __linux__ && !defined ANDROID)
#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
VideoTest
(
ts
->
get_data_path
(),
CV_FOURCC_DEFAULT
);
const
char
codecs
[][
4
]
=
{
{
'I'
,
'Y'
,
'U'
,
'V'
},
{
'X'
,
'V'
,
'I'
,
'D'
},
{
'M'
,
'P'
,
'G'
,
'2'
},
{
'M'
,
'J'
,
'P'
,
'G'
}
};
printf
(
"%s"
,
ts
->
get_data_path
().
c_str
());
VideoTest
(
ts
->
get_data_path
(),
CV_FOURCC
(
'X'
,
'V'
,
'I'
,
'D'
));
int
count
=
sizeof
(
codecs
)
/
(
4
*
sizeof
(
char
));
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
VideoTest
(
ts
->
get_data_path
(),
CV_FOURCC
(
codecs
[
i
][
0
],
codecs
[
i
][
1
],
codecs
[
i
][
2
],
codecs
[
i
][
3
]));
}
VideoTest
(
ts
->
get_data_path
(),
CV_FOURCC
(
'M'
,
'P'
,
'G'
,
'2'
));
VideoTest
(
ts
->
get_data_path
(),
CV_FOURCC
(
'M'
,
'J'
,
'P'
,
'G'
));
#endif
#endif
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment