In this tutorial you will learn how to use the 'dnn_superres' interface to upscale video via pre-trained neural networks.
Or make sure you check the dnn_superres module in the GUI version of CMake: cmake-gui.
14 using namespace dnn_superres;
16 int main(
int argc,
char *argv[])
21 cout <<
"usage: Arg 1: input video path" << endl;
22 cout <<
"\t Arg 2: output video path" << endl;
23 cout <<
"\t Arg 3: algorithm | edsr, espcn, fsrcnn or lapsrn" << endl;
24 cout <<
"\t Arg 4: scale | 2, 3, 4 or 8 \n";
25 cout <<
"\t Arg 5: path to model file \n";
29 string input_path = string(argv[1]);
30 string output_path = string(argv[2]);
31 string algorithm = string(argv[3]);
32 int scale = atoi(argv[4]);
33 string path = string(argv[5]);
43 if (!input_video.isOpened())
45 std::cerr <<
"Could not open the video." << std::endl;
51 sr.setModel(algorithm, scale);
55 Mat frame, output_frame;
61 sr.upsample(frame, output_frame);
62 output_video << output_frame;
65 imshow(
"Upsampled video", output_frame);
68 imshow(
"Original video", frame);
75 input_video.release();
76 output_video.release();
Video writer class.
Definition: videoio.hpp:863
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
"black box" representation of the file storage associated with a file on disk.
Definition: affine.hpp:51
virtual bool open(const String &filename, int fourcc, double fps, Size frameSize, bool isColor=true)
Initializes or reinitializes video writer.
Class for video capturing from video files, image sequences or cameras.
Definition: videoio.hpp:627
Template class for specifying the size of an image or rectangle.
Definition: types.hpp:315
4-character code of codec. see VideoWriter::fourcc .
Definition: videoio.hpp:140
Width of the frames in the video stream.
Definition: videoio.hpp:137
Height of the frames in the video stream.
Definition: videoio.hpp:138
void scale(cv::Mat &mat, const cv::Mat &range, const T min, const T max)
Definition: quality_utils.hpp:90
void namedWindow(const String &winname, int flags=WINDOW_AUTOSIZE)
Creates a window.
Size2i Size
Definition: types.hpp:347
the user cannot resize the window, the size is constrainted by the image displayed.
Definition: highgui.hpp:188
Frame rate.
Definition: videoio.hpp:139
n-dimensional dense array class
Definition: mat.hpp:797
int waitKey(int delay=0)
Waits for a pressed key.