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], [0, 180]) cap = cv2.VideoCapture(0) term_criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, […]

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, 0, 256]) mask = cv2.calcBackProject([hsv_original], [0, 1], roi_hist, [0, 180, […]