Skip to content

Instantly share code, notes, and snippets.

View VanDavv's full-sized avatar

Łukasz Piłatowski VanDavv

View GitHub Profile
@VanDavv
VanDavv / depthai-class.py
Last active June 2, 2020 19:55
DepthAI integration encapsulated inside a class
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-generator.py
Created June 2, 2020 19:57
DepthAI integration encapsulated in generator class
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):
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 / flask_counter.py
Last active June 9, 2020 19:04
simple flask api for counting people
#!/usr/bin/env python3
from flask import Flask, jsonify, request
app = Flask(__name__)
people_count = 0
@app.route("/increase/", methods=['POST'])
def run():
@VanDavv
VanDavv / debug_info.sh
Last active October 3, 2020 10:01
Debug script for DepthAI
#!/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 / videowriter.py
Last active August 19, 2020 20:00
Helper class for recording frames into video file
import cv2
VIDEO_WRITER_FOURCC = "H264"
class Writer:
"""
Usage:
writer = Writer("myvideofile.mp4")
for frame in <source>:
#!/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 / Dockerfile
Created January 18, 2021 13:51
Ubuntu18.04 installation of depthai-gui
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
@VanDavv
VanDavv / config.txt
Created September 6, 2021 13:00
DepthAI CM4 `/boot/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
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