Working Gesture Recognition
This commit is contained in:
@@ -13,13 +13,20 @@ img = cv2.imread('H:\car\GestureRecognition\IMG_0818.png', 1)
|
||||
# Downscale the image
|
||||
img = cv2.resize(img, None, fx=0.1, fy=0.1, interpolation = cv2.INTER_AREA)
|
||||
|
||||
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||
min_seg_threshold = 1.2
|
||||
max_seg_threshold = 1.8
|
||||
|
||||
img_gray[img_gray[:,:] > 90] = 255
|
||||
img_gray[img_gray[:,:] < 90] = 0
|
||||
# Need to make this get correct skin tones.
|
||||
# img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||
# img_gray[img_gray[:,:] > 90] = 255
|
||||
# img_gray[img_gray[:,:] < 90] = 0
|
||||
|
||||
img_bin = np.zeros(shape=(img.shape[0], img.shape[1]), dtype=int)
|
||||
img = np.where(img[:,:,1] == 0, 0, img[:,:,1])
|
||||
img[(img[:,:,2]/img[:,:,1] > min_seg_threshold) & (img[:,:,2]/img[:,:,1] < max_seg_threshold)] = [255,255,255]
|
||||
|
||||
# Threshold to binary.
|
||||
ret,img_thresh = cv2.threshold(img_gray, 127, 255, cv2.THRESH_BINARY)
|
||||
ret,img_thresh = cv2.threshold(img_bin, 127, 255, cv2.THRESH_BINARY)
|
||||
|
||||
# Following method is much faster -> 0.00143s
|
||||
# Still want to speed up further by lowering reliance on memory, which is quite heavy..
|
||||
@@ -34,7 +41,7 @@ coords_y = np.zeros((img_thresh.shape[0], img_thresh.shape[1]))
|
||||
coords_x[:,:] = x_ind
|
||||
|
||||
|
||||
# Even this is extremely quick as it goes through rows in the numpy array.
|
||||
# Even this is extremely quick as it goes through rows in the numpy array, which in python is much faster than columns
|
||||
for element in y_ind:
|
||||
coords_y[element,:] = element
|
||||
|
||||
|
||||
Reference in New Issue
Block a user