Edge detection – OpenCV 3.4 with python 3 Tutorial 18
Beginners Opencv, Tutorials
0
Image edge detection:
import cv2 import numpy as np img = cv2.imread("white_panda.jpg", cv2.IMREAD_GRAYSCALE) img = cv2.GaussianBlur(img, (11, 11), 0) sobelx = cv2.Sobel(img, cv2.CV_64F, 1, 0) sobely = cv2.Sobel(img, cv2.CV_64F, 0, 1) laplacian = cv2.Laplacian(img, cv2.CV_64F, ksize=5) canny = cv2.Canny(img, 100, 150) cv2.imshow("Image", img) cv2.imshow("Sobelx", sobelx) cv2.imshow("Sobely", sobely) cv2.imshow("Laplacian", laplacian) cv2.imshow("Canny", canny) cv2.waitKey(0) cv2.destroyAllWindows()
Real time video edge detection:
import cv2 import numpy as np cap = cv2.VideoCapture(0) while True: _, frame = cap.read() frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) blurred_frame = cv2.GaussianBlur(frame, (5, 5), 0) laplacian = cv2.Laplacian(blurred_frame, cv2.CV_64F) canny = cv2.Canny(blurred_frame, 100, 150) cv2.imshow("Frame", frame) cv2.imshow("Laplacian", laplacian) cv2.imshow("Canny", canny) key = cv2.waitKey(1) if key == 27: break cap.release() cv2.destroyAllWindows()
Files:
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Opencv Beginner Tutorial
- 1) Loading images
- 2) Loading Video and Webcam
- 3) Drawing and writing on images
- 4) Basic operations on images
- 5) Add images and Threshold
- 6) Blending images
- 7) Bitwise Operators
- 8) Trackbars
- 9) Object detection using HSV Color space
- 10) Basic Thresholding
- 11) Histograms
- 12) Basic geometric transformations
- 13) Perspective transformation
- 14) Affine transformation
- 15) Adaptive thresholding5
- 16) Smoothing images
- 17) Morphological transformation
- 18) Edge detection
- 19) Find and Draw Contours
- 20) Template matching
- 21) Lines detection with Hough Transform
- 22) Corners detection
- 23) Image Pyramids
- 24) Image Pyramids (Blending and reconstruction)
- 25) Feature detection (SIFT, SURF, ORB)
- 26) Feature Matching (Brute-Force)
- 27) Mouse Events
- 28) Histogram and Back Projection
- 29) Object tracking with Mean-shift
- 30) Object tracking with Camshift
- 31) Optical Flow with Lucas-Kanade method
- 32) Background Subtraction
- 33) k-Nearest Neighbour classification
- 34) Object tracking using Homography
- 35) Fourier Transform
- 36) Knn handwritten digits recognition
- 37) Face detection using Haar Cascades