Skip to content

Instantly share code, notes, and snippets.

Aravind Pai aravindpai

Block or report user

Report or block aravindpai

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 11_12.py
frames = os.listdir('frames/')
frames.sort(key=lambda f: int(re.sub('\D', '', f)))
frame_array=[]
for i in range(len(frames)):
#reading each files
img = cv2.imread('frames/'+frames[i])
height, width, layers = img.shape
size = (width,height)
View 11_9.py
files = ball_df['frame'].values
num=10
for idx in range(len(files)):
#draw contours
img = cv2.imread('frames/'+files[idx])
x=ball_df.loc[idx,'x']
y=ball_df.loc[idx,'y']
View 11_8.py
!rm -r ball/*
ball_df = pd.DataFrame(columns=['frame','x','y','w','h'])
for idx in range(len(frames)):
img= cv2.imread('frames/' + frames[idx])
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray,(25, 25),0)
_ , mask = cv2.threshold(gray, 200, 255, cv2.THRESH_BINARY)
image, contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
View 11_7.py
import os
import cv2
import numpy as np
import pandas as pd
folders=os.listdir('data/')
images=[]
labels= []
for folder in folders:
files=os.listdir('data/'+folder)
View 11_6.py
!rm -r patch/*
num=20
cnt=0
for i in range(len(contours)):
x,y,w,h = cv2.boundingRect(contours[i])
numer=min([w,h])
denom=max([w,h])
ratio=numer/denom
View 11_5.py
_ , mask = cv2.threshold(gray, 200, 255, cv2.THRESH_BINARY)
plt.figure(figsize=(5,5))
plt.imshow(mask,cmap='gray')
View 11_4.py
img= cv2.imread('frames/' + frames[10])
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray,(25,25),0)
plt.figure(figsize=(5,10))
plt.imshow(gray,cmap='gray')
View 11_3.py
threshold = 15 * 10e3
for i in range(len(images)-1):
if(nonzero[i]>threshold):
scene_change_idx = i
break
frames = frames[:(scene_change_idx+1)]
View 11_2.py
nonzero=[]
for i in range((len(images)-1)):
mask = cv2.absdiff(images[i],images[i+1])
_ , mask = cv2.threshold(mask, 50, 255, cv2.THRESH_BINARY)
num = np.count_nonzero((mask.ravel()))
nonzero.append(num)
x = np.arange(0,len(images)-1)
View 11_1.py
import matplotlib.pyplot as plt
import cv2
import numpy as np
import os
import re
#listing down all the file names
frames = os.listdir('frames/')
frames.sort(key=lambda f: int(re.sub('\D', '', f)))
You can’t perform that action at this time.