[SOLVED] Pycuda and OpenCV

I turned the np functions to gpu functions that works with pycuda.

My last problem is the binarize problem. I have to change the opencv functions cpu to the gpu.

But python opencv functions work for only cpu. So this is a real problem. I have a 500 line code and this is my last problem on this code, lol. What do you should for me?

Here is the code:

frame = np.copy(frame)## ayni degiskene ayni dosyayi farkli formatta okutturdum
    hls = cv2.cvtColor(frame, cv2.COLOR_RGB2HLS).astype(np.float) ##HLS renk formatina cevirdik ve kanallari ayistirdim.
    l_channel = hls[:,:,1]
    s_channel = hls[:,:,2]
    sobelx = cv2.Sobel(l_channel, cv2.CV_64F, 1, 0) ##Gorselin L kanalindaki kisminin turevini x olarak aldim.
    abs_sobelx = np.absolute(sobelx) ##Satirlari dikey olarak hesaplayacagiz bu yuzden yatay olarak almasini engellemek icin turevin sonucunu mutlak deger aldik.
    scaled_sobel = np.uint8(255*abs_sobelx/np.max(abs_sobelx))
    ##Egimini hesapladim.
    sxbinary = np.zeros_like(scaled_sobel)
    sxbinary[(scaled_sobel >= sx_thresh[0]) & (scaled_sobel <= sx_thresh[1])] = 1
    ##Goruntunun doygunluk durumunu ogrenmek icin  kanallari ayristirarak Threshold uyguladim.
    s_binary = np.zeros_like(s_channel)
    s_binary[(s_channel >= s_thresh[0]) & (s_channel <= s_thresh[1])] = 1

    ##Isik durumunu ogrenmek icin bi ustteki islemi uyguladim
    l_binary = np.zeros_like(l_channel)
    l_binary[(l_channel >= l_thresh[0]) & (l_channel <= l_thresh[1])] = 1
    channels = 255*np.dstack(( l_binary, sxbinary, s_binary)).astype('uint8')        
    binary = np.zeros_like(sxbinary)
    binary[((l_binary == 1) & (s_binary == 1) | (sxbinary==1))] = 1
    binary = 255*np.dstack((binary,binary,binary)).astype('uint8')            
    return  binary,channels

The problem was caused by the functions. So I removed the functions and used normally. So it has been fixed

Hi! I’m working on a web application that performs computations on images using Django and Python Opencv. Now, I need to use GPU accelerated functions in processing my images and I’m kinda not sure on how to invoke them inside a kernel. Is there, by any chance and open source code to this project of yours? Any help would be appreciated! Thanks!