check penny color

cascade
Cole Deck 5 years ago
parent 3815a69ee6
commit 4fe1348fd2

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

@ -68,7 +68,7 @@ if type(args["number"]) == type(selected):
# load the image, convert it to grayscale, and blur it slightly # load the image, convert it to grayscale, and blur it slightly
image = cv2.imread(args["image"]) image = cv2.imread(args["image"])
#image = cv2.resize(image, (int(image.shape[1]*0.2), int(image.shape[0]*0.2)), interpolation = cv2.INTER_NEAREST) #image = cv2.resize(image, (int(image.shape[1]*1), int(image.shape[0]*1)))
image = cv2.resize(image, (1000, int(image.shape[0]/image.shape[1] * 1000)), interpolation = cv2.INTER_NEAREST) image = cv2.resize(image, (1000, int(image.shape[0]/image.shape[1] * 1000)), interpolation = cv2.INTER_NEAREST)
if args2.show: if args2.show:
@ -137,9 +137,13 @@ for c in cnts:
mask = np.zeros(gray.shape,np.uint8) mask = np.zeros(gray.shape,np.uint8)
cv2.drawContours(mask,[c],0,255,-1) cv2.drawContours(mask,[c],0,255,-1)
#pixelpoints = np.transpose(np.nonzero(mask)) #pixelpoints = np.transpose(np.nonzero(mask))
mean_val = cv2.mean(orig,mask = mask) hsv = cv2.cvtColor(orig, cv2.COLOR_BGR2HSV)
#print(str(mean_val)) mean_val = cv2.mean(hsv,mask = mask)
if pixelsPerMetric is None and circular is True and near(mean_val[0], 63, 30) is True and near(mean_val[1], 108, 30) is True and near(mean_val[2], 104, 30) is True: print(str(mean_val[0]))
#print(", " + str(mean_val[0]/mean_val[2]))
#print(", " + str(mean_val[2]/mean_val[1]))
if pixelsPerMetric is None and circular is True and near(mean_val[0], 16, 4.5):
# and near(mean_val[0], 63, 40) is True and near(mean_val[1], 108, 40) is True and near(mean_val[2], 104, 40) is True:
pixelsPerMetric = smaller(dA, dB) / args["width"] pixelsPerMetric = smaller(dA, dB) / args["width"]
@ -242,7 +246,7 @@ for c in cnts:
#print(str(convexness) + " % fill") #print(str(convexness) + " % fill")
#if not cv2.isContourConvex(approx): #if not cv2.isContourConvex(approx):
#if cv2.matchShapes(hull, c, 1, 0.0) > 1: #if cv2.matchShapes(hull, c, 1, 0.0) > 1:
if defects.size > 5 and (convexness < 0.9 and boxiness < 0.7): if defects.size > 5 and (convexness < 0.9 or boxiness < 0.75):
objtype = "Screw" objtype = "Screw"
iteml = larger(dimA, dimB) iteml = larger(dimA, dimB)
#print("Screw Length (RAW): " + str(iteml)) #print("Screw Length (RAW): " + str(iteml))

Loading…
Cancel
Save