Skip to content

Instantly share code, notes, and snippets.

@codebudo
Created July 30, 2019 04:54
Show Gist options
  • Save codebudo/d55f1d61f5d299e71f8f96145907805d to your computer and use it in GitHub Desktop.
Save codebudo/d55f1d61f5d299e71f8f96145907805d to your computer and use it in GitHub Desktop.
OpenCV example resizing an image with CUDA GPU acceleration
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include "opencv2/cudaimgproc.hpp"
using namespace cv;
int main(int argc, char** argv ) {
if ( argc != 2 ) {
printf("usage: resizegpu <Image_Path>\n");
return -1;
}
Mat inImage;
Mat outImage;
inImage = imread( argv[1], 1 );
if ( !inImage.data ) {
printf("No image data \n");
return -1;
}
cuda::GpuMat gpuInImage;
cuda::GpuMat gpuOutImage;
for(int i=0; i < 100; i++){
//resize
gpuInImage.upload(inImage);
cuda::resize(gpuInImage, gpuOutImage, Size(4096, 4096));
gpuOutImage.download(outImage);
imwrite("output_gpu.jpg", outImage);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment