Created
July 30, 2019 04:54
-
-
Save codebudo/d55f1d61f5d299e71f8f96145907805d to your computer and use it in GitHub Desktop.
OpenCV example resizing an image with CUDA GPU acceleration
This file contains hidden or 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
#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