Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions contour.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# Import the modules
import cv2
# from sklearn.externals import joblib
# from skimage.feature import hog
import numpy as np
from keras.models import load_model
# import modelTrain` as mTT
# import h5py
# from modelTrain import test_images, test_labels
impo test_images, test_labels


# Load the classifier
Expand All @@ -24,16 +17,7 @@
im_gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
# im_gray = cv2.GaussianBlur(im_gray, (5, 5), 0)

# Threshold the image
ret, im_th = cv2.threshold(im_gray, 90, 255, cv2.THRESH_BINARY_INV)
edged = cv2.Canny(im_th, 28, 200)
contours, hierarchy = cv2.findContours(edged.copy(),
cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
cv2.imshow('Canny Edges After Contouring', edged)
cv2.waitKey(0)
print("Number of Contours found = " + str(len(contours)))
# Draw all contours
# -1 signifies drawing all contours

cv2.drawContours(im_th, contours, -1, (0, 255, 0), 3)
cv2.imshow('canvas', im_th)
cv2.waitKey()
Expand Down