1

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
  • 70,661
  • 34
  • 192
  • 269
FacundoGFlores
  • 7,858
  • 12
  • 64
  • 94

2 Answers2

3

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.

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • 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? – FacundoGFlores Nov 25 '13 at 10:58
  • 1
    Actually, it's easier to just [write Python wrappers](http://stackoverflow.com/questions/145270/calling-c-c-from-python) yourself for the C++ GPU module. With this approach you don't have to code the algorithms yourself. ;) – karlphillip Nov 25 '13 at 12:05
0

unfortunately, you can't.

none of the gpu/cuda/ocl bindings are exposed to the scripting layer (so, same prob in java)

berak
  • 39,159
  • 9
  • 91
  • 89