Student: Xavier Weber
Mentors: Vladimir Tyan & Yida Wang
Student on the same project: Fanny Monori
Link to accomplished work:
- PR in the opencv_contrib repository: opencv_contrib/pull/2231
Student: Xavier Weber
Mentors: Vladimir Tyan & Yida Wang
Student on the same project: Fanny Monori
Link to accomplished work:
#include <opencv2/dnn_superres.hpp> | |
#include <opencv2/imgproc.hpp> | |
#include <opencv2/highgui.hpp> | |
using namespace std; | |
using namespace cv; | |
using namespace dnn; | |
using namespace dnn_superres; | |
int main(int argc, char *argv[]) |
% Code created by Xavier Weber | |
% ============= PART 1: READING AND PADDING THE IMAGE ===================== | |
function [count,im] = countBlobs(img) | |
%countBlobs Counts the number of blobs: connected regions of positive | |
% values - and labels them. | |
% returns: number of blobs | |
% Get dimensions |
% Code created by Xavier Weber | |
function outimg = padImage(I, pad) | |
%padImage Pads an image with black pixels (zero-values) | |
% Works with single or multi-channels | |
% Get input dimensions | |
img_size = size(I); | |
src_height = img_size(1); | |
src_width = img_size(2); |
% Code created by Xavier Weber | |
% Create an image -- like the one in the GIF. | |
im = zeros(5,5); | |
im(1:1,5:5) = 255; | |
im(2:2,2:2) = 255; | |
im(3:3,1:1) = 255; |
import cv2 | |
from cv2 import dnn_superres | |
# Create an SR object | |
sr = dnn_superres.DnnSuperResImpl_create() | |
# Read image | |
image = cv2.imread('./input.png') | |
# Read the desired model |
cmake \ | |
-D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D INSTALL_PYTHON_EXAMPLES=ON \ | |
-D INSTALL_C_EXAMPLES=OFF \ | |
-D OPENCV_ENABLE_NONFREE=ON \ | |
-D WITH_CUDA=ON \ | |
-D WITH_CUDNN=ON \ | |
-D OPENCV_DNN_CUDA=ON \ | |
-D ENABLE_FAST_MATH=1 \ |
# Read the desired model | |
path = "EDSR_x3.pb" | |
sr.readModel(path) | |
# Set CUDA backend and target to enable GPU inference | |
sr.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA) | |
sr.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA) | |
#etcetera.. |
//Read the desired model | |
string path = "FSRCNN_x2.pb"; | |
sr.readModel(path); | |
//Set CUDA backend and target to enable GPU inference | |
sr.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA) | |
sr.setPreferableTarget(cv::dnn::DNN_BACKEND_CUDA) | |
//etcetera.. |
NUMBER_TO_SUBTRACT=217 | |
for file in `ls -1v out*`; do | |
echo $file | |
NUMBER=${file:3:-4} | |
NEW_NUMBER=$[NUMBER-NUMBER_TO_SUBTRACT] | |
NEW_FILE_NAME="out${NEW_NUMBER}.png" | |
echo $NEW_FILE_NAME |