This file contains 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 pymongo | |
def connect_server(): #connect mongo server | |
myclient = pymongo.MongoClient("mongodb://localhost:27017/") | |
return myclient | |
#######################DATABASE UTILS################################# | |
def create_db(): | |
mydb = myclient["mydatabase"] #create database |
This file contains 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 matplotlib.pyplot as plt | |
from glob import glob | |
import sys | |
import uuid | |
from tqdm import tqdm | |
import os | |
num_of_files = len([x for x in os.listdir(str(sys.argv[1])) if (x.endswith('.txt'))]) |
This file contains 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 sys | |
import uuid | |
from tqdm import tqdm | |
video_name = str(sys.argv[1]) | |
e_rate = int(sys.argv[2]) | |
cap = cv2.VideoCapture(video_name+'.mp4') | |
frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) | |
count=0 |
This file contains 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 glob | |
import sys | |
import os | |
lbls = [] | |
frames = [] | |
if_lbl_exists = False | |
for lbl in glob.glob(str(sys.argv[1])+'/*.txt'): | |
lbls.append(lbl.split('/')[1].split('.')[0]) |
This file contains 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 math | |
BATCH_SIZE=32 | |
TRAINING_SIZE = 40000 | |
# We take the ceiling because we do not drop the remainder of the batch | |
compute_steps_per_epoch = lambda x: int(math.ceil(1. * x / BATCH_SIZE)) | |
steps_per_epoch = compute_steps_per_epoch(TRAINING_SIZE) |
This file contains 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 os | |
import cv2 | |
src_path = os.path.abspath(os.path.join(os.getcwd(), "bolu_tunnel_nvr")) | |
print(src_path) | |
ch1_dst_path = os.path.abspath(os.path.join(os.getcwd(), "ch1")) | |
ch2_dst_path = os.path.abspath(os.path.join(os.getcwd(), "ch2")) | |
print(ch1_dst_path) |
This file contains 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 os | |
import cv2 | |
src_path = os.path.abspath(os.path.join(os.getcwd(), "bolu_tunnel_nvr")) | |
print(src_path) | |
ch1_dst_path = os.path.abspath(os.path.join(os.getcwd(), "ch1")) | |
ch2_dst_path = os.path.abspath(os.path.join(os.getcwd(), "ch2")) | |
print(ch1_dst_path) |
This file contains 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 os | |
from PIL import Image | |
def has_transparency(img): | |
if img.mode == "P": | |
transparent = img.info.get("transparency", -1) | |
for _, index in img.getcolors(): | |
if index == transparent: | |
return True | |
elif img.mode == "RGBA": |
This file contains 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 glob, errno | |
# Replace mydir with the directory you want | |
mydir = 'Train1/' | |
#check if directory exist, if not create it | |
try: | |
os.makedirs(mydir) | |
except OSError as e: |
This file contains 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 = '/home/orkhan/Desktop/train/' | |
cap = cv2.VideoCapture('video.mp4') | |
i = 0 | |
counter = 0 | |
while cap.isOpened(): | |
ret, frame = cap.read() | |
if not ret: |
NewerOlder