|
|
@ -176,7 +176,7 @@ def detect(calibration_width, img_file, show, quick):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
pixelsPerMetric = 25
|
|
|
|
pixelsPerMetric = 25
|
|
|
|
orig = image.copy()
|
|
|
|
orig = image.copy()
|
|
|
|
objtype = "Unknown"
|
|
|
|
objtype = "Object"
|
|
|
|
objname = ""
|
|
|
|
objname = ""
|
|
|
|
# loop over the contours individually
|
|
|
|
# loop over the contours individually
|
|
|
|
for c in cnts:
|
|
|
|
for c in cnts:
|
|
|
@ -224,7 +224,7 @@ def detect(calibration_width, img_file, show, quick):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
circular = True
|
|
|
|
circular = True
|
|
|
|
cv2.circle(orig, (int(x), int(y)), int(radius), (255, 0, 0), 2)
|
|
|
|
cv2.circle(orig, (int(x), int(y)), int(radius), (255, 0, 0), 2)
|
|
|
|
objtype = "Unknown"
|
|
|
|
objtype = "Object"
|
|
|
|
itemw = larger(dimA, dimB)
|
|
|
|
itemw = larger(dimA, dimB)
|
|
|
|
itemwr = itemw
|
|
|
|
itemwr = itemw
|
|
|
|
itemwr *= 8
|
|
|
|
itemwr *= 8
|
|
|
@ -306,7 +306,7 @@ def detect(calibration_width, img_file, show, quick):
|
|
|
|
# 0.65, (255, 255, 255), 2)
|
|
|
|
# 0.65, (255, 255, 255), 2)
|
|
|
|
if objtype != "Penny":
|
|
|
|
if objtype != "Penny":
|
|
|
|
objtype = magicSort(c)
|
|
|
|
objtype = magicSort(c)
|
|
|
|
if objtype == "Unknown":
|
|
|
|
if objtype == "Object":
|
|
|
|
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)
|
|
|
|
if circular:
|
|
|
|
if circular:
|
|
|
@ -355,7 +355,7 @@ def magicSort(contour):
|
|
|
|
#humoments[6] = abs(humoments[6]) #it's possible for the last number to change sign if item is mirrored
|
|
|
|
#humoments[6] = abs(humoments[6]) #it's possible for the last number to change sign if item is mirrored
|
|
|
|
#magicNumber1 = 0
|
|
|
|
#magicNumber1 = 0
|
|
|
|
#magicNumber2 = 0
|
|
|
|
#magicNumber2 = 0
|
|
|
|
name = "Unknown"
|
|
|
|
name = "Object"
|
|
|
|
for i in range(0,7):
|
|
|
|
for i in range(0,7):
|
|
|
|
if humoments[i] == 0:
|
|
|
|
if humoments[i] == 0:
|
|
|
|
humoments[i] = 0.1;
|
|
|
|
humoments[i] = 0.1;
|
|
|
|