Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
#include <string> | ||
#include <opencv2/opencv.hpp> | ||
#include <opencv2/dnn_superres.hpp> | ||
|
||
img=cv::imread("image.png") | ||
DnnSuperResImpl sr; | ||
string model_path = "ESPCN_x4.pb"; | ||
sr.readModel(model_path); | ||
sr.setModel("espcn", 4); // set the model by passing the value and the upsampling ratio | ||
Mat result; // creating blank mat for result | ||
sr.upsample(img, result); // upscale the input image | ||
cv::imwrite("output.png",result) | ||
int main(){ | ||
|
||
// Read image | ||
cv::Mat img = cv::imread("image.png"); | ||
|
||
// Make DNN Super resolution instance | ||
cv::dnn_superres::DnnSuperResImpl sr; | ||
|
||
// Read the model | ||
std::string model_path = "ESPCN_x4.pb"; | ||
sr.readModel(model_path); | ||
|
||
// Set the model by passing the value and the upsampling ratio | ||
sr.setModel("espcn", 4); | ||
|
||
// Creating a blank Mat for result | ||
cv::Mat result; | ||
|
||
// Upscale the input image | ||
sr.upsample(img, result); | ||
|
||
// Write the final image | ||
cv::imwrite("output.png",result); | ||
|
||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters