Object tracking using Homography – OpenCV 3.4 with python 3 Tutorial 34
We’re going to learn in this tutorial how to track an object using the Feature matching method, and then finding the Homography. This detection method works only to track two identical objects, so for example if we want to find the cover of a book…
k-Nearest Neighbour classification – OpenCV 3.4 with python 3 Tutorial 33
Source code: [python] import cv2 import numpy as np def mouse_pos(event, x, y, flags, params): global squares, color, new_element if event == cv2.EVENT_LBUTTONDOWN: if color == "b": blue_squares.append([x, y]) elif color == "r": red_squares.append([x, y]) else: new_element = [x, y] # Create Window and Set…
Background Subtraction – OpenCV 3.4 with python 3 Tutorial 32
We’re going to learn in this tutorial how to subtract the background on a video. The concept of background subtraction is really simple. On the video we take the first frame, and we find the absolute difference with another frame. Let’s see an example where…
Optical Flow with Lucas-Kanade method – OpenCV 3.4 with python 3 Tutorial 31
Source code: [python] import cv2 import numpy as np cap = cv2.VideoCapture(0) # Create old frame _, frame = cap.read() old_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # Lucas kanade params lk_params = dict(winSize = (15, 15), maxLevel = 4, criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 0.03)) #…
Object tracking with Camshift – OpenCV 3.4 with python 3 Tutorial 30
Source code: [python] import cv2 import numpy as np img = cv2.imread("gray_cover.jpg") roi = img[252: 395, 354: 455] x = 354 y = 252 width = 455 – x height = 395 – y hsv_roi = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV) roi_hist = cv2.calcHist([hsv_roi], [0], None, [180],…
Object tracking with Mean-shift – OpenCV 3.4 with python 3 Tutorial 29
Source code: [python] import cv2 import numpy as np video = cv2.VideoCapture("mouthwash.avi") _, first_frame = video.read() x = 300 y = 305 width = 100 height = 115 roi = first_frame[y: y + height, x: x + width] hsv_roi = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV) roi_hist =…
Histogram and Back Projection – OpenCV 3.4 with python 3 Tutorial 28
[python] import cv2 import numpy as np from matplotlib import pyplot as plt original_image = cv2.imread("goalkeeper.jpg") hsv_original = cv2.cvtColor(original_image, cv2.COLOR_BGR2HSV) roi = cv2.imread("pitch_ground.jpg") hsv_roi = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV) hue, saturation, value = cv2.split(hsv_roi) # Histogram ROI roi_hist = cv2.calcHist([hsv_roi], [0, 1], None, [180, 256], [0, 180,…
Mouse Events – OpenCV 3.4 with python 3 Tutorial 27
Draw circles: [python] import cv2 import numpy as np def mouse_drawing(event, x, y, flags, params): if event == cv2.EVENT_LBUTTONDOWN: print("Left click") circles.append((x, y)) cap = cv2.VideoCapture(0) cv2.namedWindow("Frame") cv2.setMouseCallback("Frame", mouse_drawing) circles = [] while True: _, frame = cap.read() for center_position in circles: cv2.circle(frame, center_position,…
Feature Matching (Brute-Force) – OpenCV 3.4 with python 3 Tutorial 26
Source code: [python] import cv2 import numpy as np img1 = cv2.imread("the_book_thief.jpg", cv2.IMREAD_GRAYSCALE) img2 = cv2.imread("me_holding_book.jpg", cv2.IMREAD_GRAYSCALE) # ORB Detector orb = cv2.ORB_create() kp1, des1 = orb.detectAndCompute(img1, None) kp2, des2 = orb.detectAndCompute(img2, None) # Brute Force Matching bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True) matches = bf.match(des1, des2)…
Feature detection (SIFT, SURF, ORB) – OpenCV 3.4 with python 3 Tutorial 25
We’re going to learn in this tutorial how to find features on an image.We have thre different algorythms that we can use: SIFT SURF ORB Each one of them as pros and cons, it depends on the type of images some algorithm will detect more…
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
Most Read:
-
Train YOLO to detect a custom object (online with free GPU)
-
YOLO object detection using Opencv with Python
-
Detecting colors (Hsv Color Space) – Opencv with Python
-
How to install Python 3 and Opencv 4 on Windows
-
Check if two images are equal with Opencv and Python
-
How to install Dlib for Python 3 on Windows
-
Feature detection (SIFT, SURF, ORB) – OpenCV 3.4 with python 3 Tutorial 25
-
Simple shape detection – Opencv with Python 3