Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hu_moments_list = list()
- for cnt in cont:
- matrix_list_cnt = list() # []
- cv2.drawContours(warp, cnt, -1, (150, 150, 200), 4)
- if len(sqrContainsNum(cnt, retNumbers(contours))) != 0:
- cv2.drawContours(warp, sqrContainsNum(cnt, retNumbers(contours)), -1, (150, 150, 200), 4)
- # print(sqrContainsNum(cnt, retNumbers(contours)))
- for cnt in sqrContainsNum(cnt, retNumbers(contours)):
- M = cv2.HuMoments(cv2.moments(cnt))
- matrix_list_cnt.append(M)
- # print(M)
- # for moment in M:
- # matrix[cnt][moment] = M[moment]
- #
- # print(matrix)
- else:
- matrix_list_cnt.append(None)
- hu_moments_list.append(matrix_list_cnt)
- cv2.imshow('kk', warp)
- from pprint import pprint
- pprint(hu_moments_list)
- import pickle
- with open("numero1.file", "wb") as file: # file = open("numero1.file", "wb")
- pickle.dump(hu_moments_list, file) # hu_moments_list -> momentos del 1
- # file.close()
- with open("numero1.file", "rb") as file: # file = open("numero1.file", "rb")
- number1_moments = pickle.load(file)
- print(number1_moments)
- # file.close()
- hu_moments_1 = [momentos_obtenidos]
- len(numbers[1]) == 1
- len(numbers[4]) == 2
- len(numbers[4][0]) == 7
- len(numbers[4][1]) == 7
- numbers = {1: hu_moments_1, # hu_moments_1 = list()
- 2: hu_moments_2,
- 3: hu_moments_3,
- ...,
- 9: hu_moments_9}
- with open("numbers", "wb") as moments_file:
- pickle.dump(numbers, moments_file)
- with open("numbers", "rb") as moments_file:
- moments_dict = pickle.load(moments_file)
- ##############################################################################################################
- numbers = {}
- for i in range(1, 10):
- with open("ejemplo" + i + ".jpg", "rb") as file:
- nmoments = get_number_moments(file)
- numbers[i] = nmoments
- with open("numbers", "wb") as moments_file:
- pickle.dump(numbers, moments_file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement