Simon, 

It turns out that using OpenCV.jl with OpenCL support is actually 
remarkably easy thanks to the transparent T-API of OpenCV 3.0.  All that is 
needed is to use cv::UMat in place of cv::Mat (and an extra header file in 
OpenCV.jl).  

A comparison of a simple RGB to gray conversion with CPU vs. GPU Mat 
suggest at least 10x improvement (even with a mediocre GTX-Force 330M 
512MB, CC 1.2):

Declare the Mat and UMat (1000x1000 RGB) source and initialize target images
julia> srcMat = Mat(1000, 1000, CV_8UC3, cvScalar(0, 255, 0)); 
julia> srcUMat = UMat(1000, 1000, CV_8UC3, cvScalar(0, 255, 0));
julia> dstMat = Mat()
julia> dstUMat = UMat()

*CPU*
julia> @time(cvtColor(srcMat, dstMat, COLOR_BGR2GRAY)) 
elapsed time: 0.00164426 seconds (80 bytes allocated) 
elapsed time: 0.001682741 seconds (80 bytes allocated) 
elapsed time: 0.002086002 seconds (80 bytes allocated) 
elapsed time: 0.001711169 seconds (80 bytes allocated) 
elapsed time: 0.001686306 seconds (80 bytes allocated) 
elapsed time: 0.001655958 seconds (80 bytes allocated) 
elapsed time: 0.001707453 seconds (80 bytes allocated)

*GPU*
julia> @time(cvtColor(srcUMat, dstUMat, COLOR_BGR2GRAY)) 
elapsed time: 0.000149589 seconds (80 bytes allocated) 
elapsed time: 0.000149705 seconds (80 bytes allocated) 
elapsed time: 0.000149575 seconds (80 bytes allocated) 
elapsed time: 0.000151404 seconds (80 bytes allocated) 
elapsed time: 0.00017067 seconds (80 bytes allocated) 
elapsed time: 0.000181821 seconds (80 bytes allocated)






On Saturday, December 6, 2014 10:43:58 PM UTC+1, Max Suster wrote:
>
>  
>
>>
>> http://developer.amd.com/community/blog/2014/10/15/opencv-3-0-transparent-api-opencl-acceleration/
>
>
> The link above makes it sounds very promising that enabling OpenCL in 
> OpenCV.jl will be rather feasible (assuming no surprises along the way...).
> I was first looking frantically for the module ("ocl") in my OpenCV 3.0 
> folder because the (outdated) web API documentation 
> said that there should be such a folder.  However, this is not true - it 
> turns out that from v3.0, the “ocl” namespace and folder are gone, 
> and  so is the “oclMat.”  To transfer data one has to use UMat.  
>
> I will try to get this implemented soon.
>
> Max
>
>
>
>

Reply via email to