How to i can count rectangle on python? Ex.rec1 rec2 rec3 ...
i need help for my project please if u know
i need help for my project please if u know
from pyimagesearch.shapedetector import ShapeDetector import argparse import imutils import cv2
image = cv2.imread("RecogPark90.png") resized = imutils.resize(image, width=300) ratio = image.shape[0] / float(resized.shape[0])
gray = cv2.cvtColor(resized, cv2.COLOR_BGR2GRAY) blurred = cv2.GaussianBlur(gray, (5, 5), 0) thresh = cv2.threshold(blurred, 60, 255, cv2.THRESH_BINARY)[1]
cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) cnts = cnts[0] if imutils.is_cv2() else cnts[1] sd = ShapeDetector()
for c in cnts: # compute the center of the contour, then detect the name of the # shape using only the contour M = cv2.moments(c) cX = int((M["m10"] / M["m00"]) * ratio) cY = int((M["m01"] / M["m00"]) * ratio) shape = sd.detect(c)
# multiply the contour (x, y)-coordinates by the resize ratio,
# then draw the contours and the name of the shape on the image
c = c.astype("float")
c *= ratio
c = c.astype("int")
cv2.drawContours(image, [c], -1, (0, 255, 0), 2)
cv2.putText(image, shape, (cX, cY), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (255, 255, 255), 2)
# show the output image
cv2.imshow("Image", image) cv2.waitKey(0)
Asked: 2018-06-05 07:42:39 -0600
Seen: 1,516 times
Last updated: Jun 05 '18
How to check and update the existing version of Open-CV on ubuntu 14.04 ?
Need Help! Python, Object Detection/Tracking [closed]
Lucas Kanade Optical Flow Implementation
What the hell is up with BackgroundSubtractorMOG, MOG2, KNN, etc.? [closed]
video is not opening in opencv 2.4.10 with python
OpenCV + Python | Multiple object tracking
LBPH OpenCV Raspberry Pi with Python
Track multiple simple objects and measure distance traveled by each in 4 second video
problem in displaying video stream window in face detection python
The imread of python opencv 3.1 can't work with chinese pathdir?
Please post your code as text and not as image