39 #include <visp3/core/vpConfig.h>
41 #if defined(VISP_HAVE_CATCH2)
43 #include <catch_amalgamated.hpp>
45 #include <visp3/core/vpIoTools.h>
46 #include <visp3/io/vpVideoReader.h>
47 #include <visp3/io/vpVideoWriter.h>
49 #ifdef ENABLE_VISP_NAMESPACE
53 static long first_frame = 100;
54 static int frame_step = 2;
55 static unsigned int nframes = 3;
56 static long last_frame = first_frame +
static_cast<long>(frame_step) * (nframes - 1);
57 static std::string tmp;
58 static std::string videoname_grey;
59 static std::string videoname_color;
62 bool test_createSequence(
vpImage<Type> &I,
const std::string &videoname,
unsigned int first_frame,
int frame_step,
72 for (
unsigned int i = 0; i < nframes; i++) {
74 std::cout <<
"Frame saved in: " << writer.
getFrameName() << std::endl;
84 bool test_readSequence(
vpImage<Type> &I,
const std::string &videoname,
long first_frame,
int frame_step,
int step,
93 std::cout <<
"First frame: " << frame << std::endl;
94 if (frame != first_frame) {
95 std::cout <<
"Wrong first frame" << std::endl;
99 std::cout <<
"Last frame: " << frame << std::endl;
100 if (frame != last_frame) {
101 std::cout <<
"Wrong last frame" << std::endl;
106 while (!reader.
end()) {
109 std::cout <<
"Read frame with index " << index <<
" from: " << reader.
getFrameName() << std::endl;
110 if (index != first_frame + cpt * frame_step) {
111 std::cout <<
"Read wrong frame index" << std::endl;
119 TEST_CASE(
"Test saving sequence of uchar images with step 2",
"[grey]")
121 std::cout <<
"** Create sequence of uchar images with step " << frame_step << std::endl;
123 CHECK(test_createSequence(I, videoname_grey, first_frame, frame_step, nframes));
126 TEST_CASE(
"Test reading a sequence of grey images",
"[grey]")
128 SECTION(
"Read sequence of uchar images with step 1")
132 CHECK(test_readSequence(I, videoname_grey, first_frame, frame_step, step, last_frame));
135 SECTION(
"Read sequence of uchar images with step 2")
137 int step = frame_step;
139 CHECK(test_readSequence(I, videoname_grey, first_frame, frame_step, step, last_frame));
143 TEST_CASE(
"Test saving sequence of color images with step 2",
"[color]")
145 std::cout <<
"** Create sequence of color images with step " << frame_step << std::endl;
147 CHECK(test_createSequence(I, videoname_color, first_frame, frame_step, nframes));
150 TEST_CASE(
"Test reading a sequence of color images",
"[color]")
152 SECTION(
"Read sequence of color images with step 1")
156 CHECK(test_readSequence(I, videoname_color, first_frame, frame_step, step, last_frame));
159 SECTION(
"Read sequence of color images with step 2")
161 int step = frame_step;
163 CHECK(test_readSequence(I, videoname_color, first_frame, frame_step, step, last_frame));
167 int main(
int argc,
char *argv[])
169 Catch::Session session;
172 session.applyCommandLine(argc, argv);
185 std::cerr << std::endl <<
"ERROR:" << std::endl;
186 std::cerr <<
" Cannot create " << tmp << std::endl;
190 std::cout <<
"** Create temp directory: " << tmp << std::endl;
192 videoname_grey = tmp + std::string(
"/I%d.pgm");
193 videoname_color = tmp + std::string(
"/I%d.ppm");
195 int numFailed = session.run();
203 int main() {
return EXIT_SUCCESS; }
Definition of the vpImage class member functions.
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
void acquire(vpImage< vpRGBa > &I)
void open(vpImage< vpRGBa > &I)
void setFileName(const std::string &filename)
long getFirstFrameIndex()
void setFrameStep(const long frame_step)
std::string getFrameName() const
long getFrameIndex() const
Class that enables to write easily a video file or a sequence of images.
void saveFrame(vpImage< vpRGBa > &I)
void setFileName(const std::string &filename)
void setFrameStep(const int frame_step)
void open(vpImage< vpRGBa > &I)
void setFirstFrameIndex(int first_frame)
std::string getFrameName() const