Earlier this month, I spent a week building OpenCV 3.2.0, with the intention to reproduce the contour detection demo I witnessed at MoCoMakers meetup. I successfully made contour detection working on PiCamera through MJPEG streaming. P.S. Can you tell the Hack Arizona 2016 shirt?
def makeContour(image): gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) gray = cv2.GaussianBlur(gray, (3, 3), 0) edged = auto_canny(gray) def auto_canny(image, sigma=0.33): v = np.median(image) lower = int(max(0, (1.0 - sigma) * v)) upper = int(min(255, (1.0 + sigma) * v)) edged = cv2.Canny(image, lower, upper) return edged
Their code works with a MJPEG stream from an Android phone.
It extracts a JPEG frame from the video stream, processes the image through
makeContour function, and displays the result.
makeContour function converts the RGB image to grayscale, blurs the grayscale image, and runs the Canny Edge Detection algorithm.