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 os | |
import datetime | |
from time import sleep | |
for file in os.listdir(os.getcwd()): | |
if file.endswith('.jpg'): | |
os.rename(file, "img_"+datetime.datetime.now().strftime("%Y%m%d-%H%M%S%f")+'.jpg') | |
sleep(0.05) |
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 os | |
for file in os.listdir(os.getcwd()): | |
if file.endswith('.txt'): | |
os.remove(file) |
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 | |
cap=cv2.VideoCapture("video.mp4") | |
fps = cap.get(cv2.CAP_PROP_FPS) | |
print(fps) |
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 = '/home/orkhan/Desktop/train/' | |
cap = cv2.VideoCapture('video.mp4') | |
i = 0 | |
counter = 0 | |
while cap.isOpened(): | |
ret, frame = cap.read() | |
if not ret: |
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 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 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 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 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 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 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 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 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 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 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 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]) |
OlderNewer