Update magic numbers to be more consistent
This commit is contained in:
parent
0cfa5cb1a8
commit
68c1f4dc1a
Binary file not shown.
24
detect.py
24
detect.py
@ -319,6 +319,7 @@ 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 == "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)
|
||||||
@ -364,16 +365,25 @@ def detect(calibration_width, img_file, show, quick):
|
|||||||
def magicSort(contour):
|
def magicSort(contour):
|
||||||
moments = cv2.moments(contour)
|
moments = cv2.moments(contour)
|
||||||
humoments = cv2.HuMoments(moments)
|
humoments = cv2.HuMoments(moments)
|
||||||
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
|
||||||
magicNumber = 0
|
#magicNumber1 = 0
|
||||||
|
#magicNumber2 = 0
|
||||||
|
name = "Unknown"
|
||||||
for i in range(0,7):
|
for i in range(0,7):
|
||||||
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]))
|
||||||
|
|
||||||
for i in range(0,7):
|
for i in range(0,7):
|
||||||
magicNumber += humoments[i]
|
if i > 1:
|
||||||
print(str(humoments[i]))
|
humoments[i] = int(round(humoments[i][0] / 8) * 8)
|
||||||
|
if i != 4 and i != 6:
|
||||||
|
name += ", " + str(abs(int(humoments[i][0])))
|
||||||
|
#magicNumber1 += abs(humoments[i][0])
|
||||||
|
else:
|
||||||
|
humoments[i] = int(round(humoments[i][0] * 4) * 16)
|
||||||
|
name += ", " + str(abs(int(humoments[i][0])))
|
||||||
|
#magicNumber2 += abs(humoments[i][0])
|
||||||
|
#magicNumber += humoments[i][0]
|
||||||
|
print(str(humoments))
|
||||||
#print(magicNumber)
|
#print(magicNumber)
|
||||||
name = "Unknown: "
|
#name = "Unknown: " + str(int(magicNumber1)) + ", " + str(int(magicNumber2))
|
||||||
name += str(int(round(magicNumber[0] / 2) * 2))
|
|
||||||
print(name)
|
print(name)
|
||||||
return name
|
return name
|
Loading…
x
Reference in New Issue
Block a user