cat /etc/os-release
NAME="Ubuntu" VERSION="20.04.3 LTS (Focal Fossa)" ...
FROM python:3.7-slim | |
RUN apt update | |
RUN apt install sudo | |
RUN sudo apt install ffmpeg libsm6 libxext6 -y | |
RUN pip install opencv-contrib-python==4.5.5.64 | |
# RUN pip install easyocr==1.4.2 |
! pip install kafka-python | |
import cv2 | |
from kafka import KafkaConsumer | |
import numpy as np | |
import time | |
def benchmark(fn): | |
def _timing(*a, **kw): | |
st = time.perf_counter() |
# Cut video (two time values; first one is starting, second one is length) | |
ffmpeg -ss 00:01:23 -t 00:03:10 -i input.mp4 -vcodec copy -acodec copy cropped.mp4 | |
# Merge all videos in directory | |
ffmpeg -f concat -safe 0 -i <(for f in ./*.mp4; do echo "file '$PWD/$f'"; done) -c copy merged.mp4 | |
# Copy video without audio | |
ffmpeg -i vid_with_audio.mp4 -c copy -an vid_without_audio.mp4 | |
# Reverse video |
import argparse | |
import cv2 | |
import os | |
def get_frame(src): | |
# Create a VideoCapture object and read from input file | |
# If the input is the camera, pass 0 instead of the video file path | |
cap = cv2.VideoCapture(src) | |
# Check if camera opened successfully |
# Regex for Turkish License Plate | |
# http://tr.wikipedia.org/wiki/Türkiye_il_plaka_kodları | |
import re | |
# Upper limits of numerical characters customizable. (eg. 81XX...) | |
def is_plate_valid(plate): | |
exps = [ | |
r"\b[0-9]{1}[0-9]{1}[a-zA-Z]{1}[0-9]{4,5}\b", # 99 X 9999, 99 X 99999 | |
r"\b[0-9]{1}[0-9]{1}[a-zA-Z]{2}[0-9]{3,4}\b", # 99 XX 999, 99 XX 9999 |