-
Notifications
You must be signed in to change notification settings - Fork 0
Stand Up & Wheel Count Size Location
We meet today original for a team coding scrimmage, in order to get a chunk of the coding work out of the way. However, due to time constraints everyone had with regards to other module work & assignments. In place of this, we had a quick Stand-Up meeting, whereby we discussed our current work thus far, as well as our plans for moving forward and any possible barriers stopping us completing these tasks.
Full minutes can be found here. (DIT Sign-in required)
# Original Code
circles = cv2.HoughCircles(img, #src Image
cv2.HOUGH_GRADIENT, # Hough Circling Method
1, # DP
30, # Minimum distance between centroids
param1=140, # Canny Edge Detection Thresholding
param2=40, # Accumulator threshold for the circle centers. Lower means more false positives
minRadius=0, # Minimum radius allowed for a detected Circle
maxRadius=50) # Maximum radius allowed for a detected CircleThe above code was used to test it's results at capturing all the wheels in the project vehicle images. I had various results, and had to tweak the HoughCircles parameters according to the best fit for each vehicle. So by accumulating the best cases for each vehicle, I came up with a compromising set of parameters used below.
cols = ['Wheel No.', 'X Coords', 'Y Coords','Wheel Diam']
circleLocations = []
# Working best if we take the greyscaled image as HoughCircles fxn preforms canny edge on the image anyway
img = cv2.medianBlur(greyscale_image,5)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
circles = cv2.HoughCircles( img,
cv2.HOUGH_GRADIENT,
1,
30,
param1=160,
param2=25,
minRadius=10,
maxRadius=50)
circles = np.uint16(np.around(circles))
for index,i in enumerate(circles[0,:]):
# draw the outer circle
cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)
# draw the center of the circle
cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)
# append to list that'll be added to the dataframe
circleLocations.append([index+1, i[0], i[1], i[2]])
wheelData = pd.DataFrame(circleLocations, columns=cols)
plt.imshow(cimg)
print(wheelData)
# TODO There could be a point that if the circle's y coord is along the same plane, so a buffer for +- 30 pixels,
# then only include those circles Wheel No. X Coords Y Coords Wheel Diam
0 1 488 108 44
1 2 524 78 28
2 3 558 108 29
3 4 600 188 30
4 5 634 90 49
5 6 72 90 37
6 7 668 186 30
7 8 424 48 48
8 9 226 196 13
9 10 598 118 29
10 11 362 68 29
11 12 246 78 21
12 13 528 186 29
13 14 572 64 30
14 15 300 82 28
15 16 170 196 12
16 17 62 130 17
17 18 66 196 11
18 19 90 144 22
19 20 438 76 17
The truck's wheel output is seen above. As you can see, there are way too many circles captured as false positives, but this will be dealt with later. What's more important, is that all the wheels are perfectly captured. This can be seen in various test outputs below.
As mentioned previously, we need to deal with all the false positives outliers. To do so, I simply just used a buffer of the lower third of the image. so from this, we can then only save the circle we're interested in (The actual wheels of the vehicles). There's also another check, the wheel size. For some images, the full size of the wheel isn't captured. So to deal with this, I just took the size of the largest wheel captured, and set that as the size of the vehicle's wheels. This is a crude wheel size assignment, but it provides the information we require, to a reasonable degree of accuracy.
actualWheels = []
biggerWheel = 0
# Using just the lower third of the image to find the wheels
lowerThirdBuffer = image.shape[0] * 0.66
for index,row in enumerate(wheelData.iterrows()):
# Let's find the largest wheel, and take that as the vehicle's wheel size
if(row[1][3] > biggerWheel):
biggerWheel = row[1][3]
# Appends the actual wheels to a new list
if(row[1][2] > lowerThirdBuffer):
row[1][3] = biggerWheel
actualWheels.append(list(row[1]))
actualWheels = pd.DataFrame(actualWheels,columns=cols)
print(actualWheels) Wheel No. X Coords Y Coords Wheel Diam
0 4 600 188 44
1 7 668 186 49
2 9 226 196 49
3 13 528 186 49
4 16 170 196 49
5 18 66 196 49
Again, the outputs here are from the truck. As you can see, all of the wheels in the original image are captured, along with the size set to the largest wheel size.


