Skip to content

Instantly share code, notes, and snippets.

import cv2
import numpy as np
import poly_point_isect as bot
img = cv2.imread('parking.png')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
kernel_size = 5
blur_gray = cv2.GaussianBlur(gray,(kernel_size, kernel_size),0)
# https://www.geeksforgeeks.org/arithmetic-operations-on-images-using-opencv-set-2-bitwise-operations-on-binary-images/
# Python program to illustrate
# arithmetic operation of
# bitwise AND of two images
# organizing imports
import cv2
import numpy as np
import cv2
def track_object(thresh_image):
# findcontours
cnts = cv2.findContours(thresh_image, cv2.RETR_LIST,
cv2.CHAIN_APPROX_SIMPLE)[0]
# filter by area
xcnts = []
import cv2
from scipy.spatial import distance as dist
scale = 0.23
def midpoint(ptA, ptB):
return (int((ptA[0] + ptB[0]) * 0.5), int((ptA[1] + ptB[1]) * 0.5))
def track_object(thresh_image):
import cv2
img = cv2.imread('images/input1.png', cv2.IMREAD_UNCHANGED)
print('Original Dimensions : ', img.shape)
scale_percent = 60 # percent of original size
width = int(img.shape[1] * scale_percent / 100)
height = int(img.shape[0] * scale_percent / 100)
dim = (width, height)
import cv2
# capture frames from a camera with device index=0
cap = cv2.VideoCapture(0)
print(cap.isOpened())
if not cap.isOpened():
print("Can`t open the video file!\n")
exit()
import cv2
path = "images/multiple-blob.png"
img = cv2.imread(path, cv2.IMREAD_COLOR)
# convert the image to grayscale
gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# convert the grayscale image to binary image
ret, thresh = cv2.threshold(gray_image, 127, 255, 0)
import cv2
# Load an color image in grayscale
# img = cv2.imread('images/multiple-blob.png', 0)
# Load an color image in color
img = cv2.imread('images/multiple-blob.png', cv2.IMREAD_COLOR)
# img = cv2.imread('images/plate.jpg', cv2.IMREAD_COLOR)
# Convert to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
import cv2
# Load an color image in grayscale
# img = cv2.imread('images/multiple-blob.png', 0)
# Load an color image in color
img = cv2.imread('images/multiple-blob.png', cv2.IMREAD_COLOR)
# Convert to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)