Skip to content

Instantly share code, notes, and snippets.

View VanDavv's full-sized avatar

Łukasz Piłatowski VanDavv

View GitHub Profile
@VanDavv
VanDavv / main.py
Created February 26, 2024 08:04
Convert RGB stream to grayscale using DepthAI ImageManip node
import cv2
import depthai as dai
pipeline = dai.Pipeline()
cam = pipeline.create(dai.node.ColorCamera)
cam.setCamera("color")
cam.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
manip = pipeline.create(dai.node.ImageManip)
@VanDavv
VanDavv / workflow.yml
Created February 21, 2023 11:19
GitHub Actions Workflow to publish to PyPI
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
on: push
jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.10
@VanDavv
VanDavv / download.sh
Created June 16, 2017 06:33
Script to download latest chrome driver
#!/bin/bash
PLATFORM=linux64 # Change this line if You're using other platform
VERSION=$(curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
curl http://chromedriver.storage.googleapis.com/$VERSION/chromedriver_$PLATFORM.zip -LOk
unzip chromedriver_*
rm chromedriver_*
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 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
@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 / main.py
Created August 25, 2019 10:49
Micro:bit catch or loose game
from microbit import display, Image, button_a, button_b, pin0, running_time
import random
class Utils:
@staticmethod
def deepcopy(arr):
return [row[:] for row in arr]
@staticmethod
#!/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 / 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>: