Is it possible to write PyOpenCV code using GPUs? I want to know if I can write the following on Python:
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
using namespace cv;
int main() {
Mat src = imread("car1080.jpg", 0);
if (!src.data) exit(1);
gpu::GpuMat d_src(src);
gpu::GpuMat d_dst;
gpu::bilateralFilter(d_src, d_dst, -1, 50, 7);
gpu::Canny(d_dst, d_dst, 35, 200, 3);
Mat dst(d_dst);
imwrite("out.png", dst);
return 0;
}
talonmies
72.8k35 gold badges204 silver badges297 bronze badges
asked Nov 25, 2013 at 1:25
FacundoGFlores
8,13812 gold badges68 silver badges97 bronze badges
2 Answers 2
PyOpenCV stopped being updated after OpenCV 2.1.0, and it doesn't support OpenCV's GPU module.
Nowadays OpenCV offers it's own API for Python programmers, but unfortunately it also doesn't support the GPU module yet.
answered Nov 25, 2013 at 3:07
karlphillip
93.7k38 gold badges254 silver badges449 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
FacundoGFlores
So I think the only way to get "image processing productivity" is to get the raw data as "numpy" array and to process it using my own "CUDA or OpenCL" kernels right? Or... does exist any other alternative for OpenCV to work with DIPs on GPUs?
karlphillip
Actually, it's easier to just write Python wrappers yourself for the C++ GPU module. With this approach you don't have to code the algorithms yourself. ;)
unfortunately, you can't.
none of the gpu/cuda/ocl bindings are exposed to the scripting layer (so, same prob in java)
answered Nov 25, 2013 at 8:34
berak
39.9k9 gold badges96 silver badges92 bronze badges
Comments
lang-py