Skip to content

Instantly share code, notes, and snippets.

Avatar

Łukasz Piłatowski VanDavv

View GitHub Profile
View webrtc_server
import json
from aiohttp import web
from aiortc import RTCPeerConnection, RTCSessionDescription
import traceback
import numpy as np
from aiortc import VideoStreamTrack
import cv2
from av import VideoFrame
import depthai as dai
import blobconverter
@VanDavv
VanDavv / config.txt
Created Sep 6, 2021
DepthAI CM4 `/boot/config.txt`
View config.txt
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1
@VanDavv
VanDavv / Dockerfile
Created Jan 18, 2021
Ubuntu18.04 installation of depthai-gui
View Dockerfile
FROM ubuntu:18.04
RUN apt update && apt install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt update
RUN apt install -y python3.8 curl python3-distutils python3-apt libgl1-mesa-glx libpulse-dev libxcb-xinerama0 libfontconfig libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxcb-xfixes0 libxcb-xkb1 libxkbcommon-x11-0
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
RUN python3.8 get-pip.py
RUN python3.8 -m pip install --extra-index-url https://artifacts.luxonis.com/artifactory/luxonis-python-snapshot-local/ depthai-gui
CMD depthai-gui
View install_depthai_sys_no_sudo.sh
#!/bin/bash
set -e
apt-get update
apt-get install -y python3 python3-pip udev
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666"' | tee /etc/udev/rules.d/80-movidius.rules
udevadm control --reload-rules && sudo udevadm trigger
# https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
# https://stackoverflow.com/questions/55313610/importerror-libgl-so-1-cannot-open-shared-object-file-no-such-file-or-directo
@VanDavv
VanDavv / videowriter.py
Last active Aug 19, 2020
Helper class for recording frames into video file
View videowriter.py
import cv2
VIDEO_WRITER_FOURCC = "H264"
class Writer:
"""
Usage:
writer = Writer("myvideofile.mp4")
for frame in <source>:
@VanDavv
VanDavv / debug_info.sh
Last active Oct 3, 2020
Debug script for DepthAI
View debug_info.sh
#!/bin/bash
if [[ $(pwd) != *"depthai" ]]; then
echo "You need to run this script from the cloned depthai repository (you can clone it from here - https://github.com/luxonis/depthai)"
exit 1
fi
echo "Installing required tools for the debug script..."
sudo apt-get install util-linux usbutils lshw coreutils
@VanDavv
VanDavv / flask_counter.py
Last active Jun 9, 2020
simple flask api for counting people
View flask_counter.py
#!/usr/bin/env python3
from flask import Flask, jsonify, request
app = Flask(__name__)
people_count = 0
@app.route("/increase/", methods=['POST'])
def run():
View multiprocessing-pipes.py
from multiprocessing import Pipe, Process
def _thread_fun(pipe: Pipe):
while True:
print('WAITING')
val = pipe.recv()
if val == 'FINISH':
print('FINISHING')
break
pipe.send(val * 10)
@VanDavv
VanDavv / depthai-generator.py
Created Jun 2, 2020
DepthAI integration encapsulated in generator class
View depthai-generator.py
from pathlib import Path
import consts.resource_paths
import cv2
import depthai
class DepthAI:
def __init__(self):
if not depthai.init_device(consts.resource_paths.device_cmd_fpath):
@VanDavv
VanDavv / depthai-class.py
Last active Jun 2, 2020
DepthAI integration encapsulated inside a class
View depthai-class.py
from pathlib import Path
import consts.resource_paths
import cv2
import depthai
class DepthAI:
def __init__(self):
if not depthai.init_device(consts.resource_paths.device_cmd_fpath):