This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |