In this tutorial, we will introduce how to detect edge using python opencv.
1. Install opencv
pip install opencv-python
2. Import library
import cv2
3. Create a VideoCapture object
vcapture= cv2.VideoCapture(0)
We will process each frame of this video
4. Get all frame of video
while True: ret, frame = vcapture.read()
5. Convert colorful frame to grayscale
if ret == True: grayscale = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
6. Implement edge detection
edge = cv2.Canny(grayscale, 75, 125) cv2.imshow('Edge frame', edge) if cv2.waitKey(20) == ord('q'): break
7. Release resources
vcapture.release() cv2.destroyAllWindows()