From ff863fe7f8540a10e699e445317d6b2399c51440 Mon Sep 17 00:00:00 2001
From: SpeedProg <speedprog@googlemail.com>
Date: Fri, 23 Aug 2019 17:12:36 +0000
Subject: [PATCH] added some code related to finding the set
---
opencv_dnn.py | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/opencv_dnn.py b/opencv_dnn.py
index 64a9067..37ecaae 100644
--- a/opencv_dnn.py
+++ b/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
--
Gitblit v1.10.0