Home Raspberry pi Opencv being slow
Reply: 0

Raspberry pi Opencv being slow

Ali Bahmanyar
1#
Ali Bahmanyar Published in 2018-02-14 11:26:45Z

I'm using RPI for Color Hue Image Processing, For this purpose i have to convert the image format from BGR to HSV by:

hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

Normally this will take 8 ms on 704*704 resolution; to make it faster i divide the image to two segments and process each segment on a separate thread to speed up the BGR2HSV conversion:

num_processes = 2
c = 0
hsv = np.zeros((704,704,3))
frame = vs.read()

def bgrhsv(x):
    global c
    hsv[int(frame.shape[0]/num_processes*x):int(frame.shape[0]/num_processes*(x+1)), :] = cv2.cvtColor(frame[int(frame.shape[0]/num_processes*x):int(frame.shape[0]/num_processes*(x+1)), :], cv2.COLOR_BGR2HSV)
    c += 1

e1 = time.time()
Thread(target=bgrhsv, args=(0,)).start()
Thread(target=bgrhsv, args=(1,)).start()
while c < 2:
    pass
e2 = time.time()

But, this way the conversion process will take up to 20 ms!

How can i make the BGR2HSV conversion faster?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306182 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO