diff --git a/__pycache__/detect.cpython-38.pyc b/__pycache__/detect.cpython-38.pyc index 5e1785c..8c6053a 100644 Binary files a/__pycache__/detect.cpython-38.pyc and b/__pycache__/detect.cpython-38.pyc differ diff --git a/detect.py b/detect.py index 6bd1ab0..6169dbb 100644 --- a/detect.py +++ b/detect.py @@ -319,6 +319,7 @@ def detect(calibration_width, img_file, show, quick): # cv2.putText(orig, "{:.5f}in".format(itemhr), # (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX, # 0.65, (255, 255, 255), 2) + #objtype = magicSort(c) if objtype == "Unknown": objtype = magicSort(c) 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): moments = cv2.moments(contour) humoments = cv2.HuMoments(moments) - humoments[6] = abs(humoments[6]) #it's possible for the last number to change sign if item is mirrored - magicNumber = 0 + #humoments[6] = abs(humoments[6]) #it's possible for the last number to change sign if item is mirrored + #magicNumber1 = 0 + #magicNumber2 = 0 + name = "Unknown" for i in range(0,7): humoments[i] = -1 * math.copysign(1.0, humoments[i]) * math.log10(abs(humoments[i])) - for i in range(0,7): - magicNumber += humoments[i] - print(str(humoments[i])) + if i > 1: + 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) - name = "Unknown: " - name += str(int(round(magicNumber[0] / 2) * 2)) + #name = "Unknown: " + str(int(magicNumber1)) + ", " + str(int(magicNumber2)) print(name) return name \ No newline at end of file