Skip to content

Instantly share code, notes, and snippets.

View jackersson's full-sized avatar

Taras jackersson

View GitHub Profile
def is_circle(perimetr, area):
if perimetr == 0:
return False
circularity = 4*math.pi*(area/(perimetr**2))
if 0.7 < circularity < 1.2:
return True
return False
@jackersson
jackersson / setup.py
Created July 25, 2018 07:59
run_custom_script_with_pip_package
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
setup for AI Models package
"""
from setuptools import setup # , Command
from setuptools.command.install import install
with open('README.md') as readme_file:
required_libs = {
"gstreamer": "1.14.2".split("."),
"tensorflow": "1.10.0".split("."),
"opencv": "3.4.0".split(".")
}
def check_opencv():
major, minor, _ = 0, 0, 0
@jackersson
jackersson / tensorflow.sh
Last active February 6, 2019 10:51
tensorflow.sh
#!/bin/bash
#!/usr/bin/env bash
#
SCRIPT_DIR="$(cd "$(dirname "${0}")"; pwd)"
RED="\033[1;31m"
YELLOW="\033[1;33m"
GREEN="\033[0;32m"
NO_COLOR="\033[0m"
"""
python3 gst_video_split.py -f "/media/taras/Transcend/Dataai/OBI/test_with_overlay/00000004063000000.mp4" -o /media/taras/Transcend/Dataai/OBI/test_with_overlay/output -t 60
python3 gst_video_split.py -f "/media/taras/Transcend/Dataai/OBI/test/00000004063000000.mp4" -o /media/taras/Transcend/Dataai/OBI/test_with_overlay/output -t 60
"""
import os
import datetime
import traceback
# Converts video from MPEG to MP4 so it can be opened by VLC or other media player
# And concats if needed
# Run in folder with videos ./mpeg_2_mp4.sh
# chmod u+x ./mpeg_2_mp4.sh
ALL_VIDEOS_FILE="all.txt"
STATUS_FILE="status.txt"
# *************** Installation **********************
git clone https://github.com/intel/libva.git
./autogen.sh
make -j8
sudo make install
git clone https://github.com/intel/intel-vaapi-driver.git
Gst-Pipelines
1: filesrc location=video.mp4 ! qtdemux ! h264parse ! avdec_h264 ! videoconvert n-threads=0 ! video/x-raw,format=RGB,width=1920,height=1080 ! appsink emit-signals=True sync=false
2: appsrc caps=video/x-raw,format=RGB,width=1920,height=1080 emit-signals=True is-live=true ! videoconvert ! x264enc tune=zerolatency ! mp4mux ! filesink location=1.mp4 sync=false
Getting an error:
> gst_segment_to_running_time: assertion 'segment->format == format' failed
{
"frame_offset": 1,
"track_id": 1,
"group_id": 1,
"identity": {
"name": "First-Last Name",
"confidence": 0.9
},
class ColorPicker:
def __init__(self, channels: int = 4):
self._color_by_id = {}
self._channels = channels
def get(self, idx):
if idx not in self._color_by_id:
self._color_by_id[idx] = self._generate_color(channels=self._channels)