SpeedProg
2019-08-23 ff863fe7f8540a10e699e445317d6b2399c51440
opencv_dnn.py
@@ -68,8 +68,22 @@
            if card_img is None:
                print('WARNING: card %s is not found!' % img_name)
                continue
            set_img = card_img[575:638, 567:700]
            """
            img_cc = cv2.cvtColor(card_img, cv2.COLOR_BGR2GRAY)
            img_thresh = cv2.adaptiveThreshold(img_cc, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, 11, 5)
            # Dilute the image, then erode them to remove minor noises
            kernel = np.ones((3, 3), np.uint8)
            img_dilate = cv2.dilate(img_thresh, kernel, iterations=1)
            img_erode = cv2.erode(img_dilate, kernel, iterations=1)
            cnts, hier = cv2.findContours(img_erode, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
            cnts2 = sorted(cnts, key=cv2.contourArea, reverse=True)
            cnts2 = cnts2[:10]
            if True:
                cv2.drawContours(img_cc, cnts2, -1, (0, 255, 0), 3)
                #cv2.imshow('Contours', card_img)
                #cv2.waitKey(10000)
            """
            set_img = card_img[595:635, 600:690]
            #cv2.imshow(card_info['name'], set_img)
            # Compute value of the card's perceptual hash, then store it to the database
            #img_art = Image.fromarray(card_img[121:580, 63:685])  # For 745*1040 size card image