How to speed up pixel scanning a numpy array

246 views Asked by At

I have made a distance detector using a webcam and laser to estimate the distance of the laser dot. My plan is to make a cheap 2d ldar system using the raspberry pi.

At first I did pixel scanning using nested python loops, this was way too slow with a scan taking around 2 minutes. Then i tried to speed up the scanning process using numpy arrays. This has brought the time down to 600 milliseconds. However this still is not fast enough. 10 ms would be a more suitable time frame, if i could get it lower than that it would be a bonus. Does anyone have any ideas on how to get a faster scan time?

I am setting a threshold with the numpy arrays , just looking for the reddest pixels using xy_vals = [img_array_rgb] > 236. this gives me an array of true elements where the red dot is. I then find the x,y coordinates of the true elements using nonzero().

0

There are 0 answers