|
|
@ -180,6 +180,7 @@ def detect(calibration_width, img_file, show, quick):
|
|
|
|
#orig = image.copy()
|
|
|
|
#orig = image.copy()
|
|
|
|
num += 1
|
|
|
|
num += 1
|
|
|
|
# if the contour is not sufficiently large, ignore it
|
|
|
|
# if the contour is not sufficiently large, ignore it
|
|
|
|
|
|
|
|
#pixelsPerMetric = 75
|
|
|
|
if cv2.contourArea(c) < 100 or pixelsPerMetric is None:
|
|
|
|
if cv2.contourArea(c) < 100 or pixelsPerMetric is None:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
# compute the rotated bounding box of the contour
|
|
|
|
# compute the rotated bounding box of the contour
|
|
|
@ -319,7 +320,8 @@ def detect(calibration_width, img_file, show, quick):
|
|
|
|
# cv2.putText(orig, "{:.5f}in".format(itemhr),
|
|
|
|
# cv2.putText(orig, "{:.5f}in".format(itemhr),
|
|
|
|
# (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX,
|
|
|
|
# (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX,
|
|
|
|
# 0.65, (255, 255, 255), 2)
|
|
|
|
# 0.65, (255, 255, 255), 2)
|
|
|
|
#objtype = magicSort(c)
|
|
|
|
if objtype != "Penny":
|
|
|
|
|
|
|
|
objtype = magicSort(c)
|
|
|
|
if objtype == "Unknown":
|
|
|
|
if objtype == "Unknown":
|
|
|
|
objtype = magicSort(c)
|
|
|
|
objtype = magicSort(c)
|
|
|
|
output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh)
|
|
|
|
output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh)
|
|
|
@ -370,6 +372,8 @@ def magicSort(contour):
|
|
|
|
#magicNumber2 = 0
|
|
|
|
#magicNumber2 = 0
|
|
|
|
name = "Unknown"
|
|
|
|
name = "Unknown"
|
|
|
|
for i in range(0,7):
|
|
|
|
for i in range(0,7):
|
|
|
|
|
|
|
|
if humoments[i] == 0:
|
|
|
|
|
|
|
|
humoments[i] = 0.1;
|
|
|
|
humoments[i] = -1 * math.copysign(1.0, humoments[i]) * math.log10(abs(humoments[i]))
|
|
|
|
humoments[i] = -1 * math.copysign(1.0, humoments[i]) * math.log10(abs(humoments[i]))
|
|
|
|
if i > 1:
|
|
|
|
if i > 1:
|
|
|
|
humoments[i] = int(round(humoments[i][0] / 8) * 8)
|
|
|
|
humoments[i] = int(round(humoments[i][0] / 8) * 8)
|
|
|
|