41#include <visp3/core/vpConfig.h>
43#if defined(VISP_HAVE_CATCH2)
44#define CATCH_CONFIG_RUNNER
47#include <visp3/core/vpIoTools.h>
48#include <visp3/io/vpVideoReader.h>
49#include <visp3/io/vpVideoWriter.h>
51static long first_frame = 100;
52static int frame_step = 2;
53static unsigned int nframes = 3;
54static long last_frame = first_frame +
static_cast<long>(frame_step) * (nframes - 1);
55static std::string tmp;
56static std::string videoname_grey;
57static std::string videoname_color;
60bool test_createSequence(
vpImage<Type> &I,
const std::string &videoname,
unsigned int first_frame,
int frame_step,
70 for (
unsigned int i = 0; i < nframes; i++) {
72 std::cout <<
"Frame saved in: " << writer.
getFrameName() << std::endl;
81bool test_readSequence(
vpImage<Type> &I,
const std::string &videoname,
long first_frame,
int frame_step,
int step,
90 std::cout <<
"First frame: " << frame << std::endl;
91 if (frame != first_frame) {
92 std::cout <<
"Wrong first frame" << std::endl;
96 std::cout <<
"Last frame: " << frame << std::endl;
97 if (frame != last_frame) {
98 std::cout <<
"Wrong last frame" << std::endl;
103 while (!reader.
end()) {
106 std::cout <<
"Read frame with index " << index <<
" from: " << reader.
getFrameName() << std::endl;
107 if (index != first_frame + cpt * frame_step) {
108 std::cout <<
"Read wrong frame index" << std::endl;
116TEST_CASE(
"Test saving sequence of uchar images with step 2",
"[grey]")
118 std::cout <<
"** Create sequence of uchar images with step " << frame_step << std::endl;
120 CHECK(test_createSequence(I, videoname_grey, first_frame, frame_step, nframes));
123TEST_CASE(
"Test reading a sequence of grey images",
"[grey]")
125 SECTION(
"Read sequence of uchar images with step 1")
129 CHECK(test_readSequence(I, videoname_grey, first_frame, frame_step, step, last_frame));
132 SECTION(
"Read sequence of uchar images with step 2")
134 int step = frame_step;
136 CHECK(test_readSequence(I, videoname_grey, first_frame, frame_step, step, last_frame));
140TEST_CASE(
"Test saving sequence of color images with step 2",
"[color]")
142 std::cout <<
"** Create sequence of color images with step " << frame_step << std::endl;
144 CHECK(test_createSequence(I, videoname_color, first_frame, frame_step, nframes));
147TEST_CASE(
"Test reading a sequence of color images",
"[color]")
149 SECTION(
"Read sequence of color images with step 1")
153 CHECK(test_readSequence(I, videoname_color, first_frame, frame_step, step, last_frame));
156 SECTION(
"Read sequence of color images with step 2")
158 int step = frame_step;
160 CHECK(test_readSequence(I, videoname_color, first_frame, frame_step, step, last_frame));
164int main(
int argc,
char *argv[])
166 Catch::Session session;
169 session.applyCommandLine(argc, argv);
181 std::cerr << std::endl <<
"ERROR:" << std::endl;
182 std::cerr <<
" Cannot create " << tmp << std::endl;
186 std::cout <<
"** Create temp directory: " << tmp << std::endl;
188 videoname_grey = tmp + std::string(
"/I%d.pgm");
189 videoname_color = tmp + std::string(
"/I%d.ppm");
191 int numFailed = session.run();
199int 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