Skip to content

Instantly share code, notes, and snippets.

@danielhfrank
danielhfrank / pydantic.py
Created December 1, 2020 00:15
Pydantic with Numpy
from typing import Generic, TypeVar
import numpy as np
from pydantic.fields import ModelField
JSON_ENCODERS = {
np.ndarray: lambda arr: arr.tolist()
}
DType = TypeVar('DType')
@velovix
velovix / sunhacks_2020_gstreamer_talk.md
Last active July 8, 2024 16:44
The text version of my GStreamer talk at sunhacks 2020

Introduction

Hi everyone! Today I'm going to be giving you a crash course in video processing using Python. Coming out of this talk, you'll be able to take video from pretty much any source, decode it, apply visual effects, and display it on-screen. To do this, we're going to be using a library named GStreamer, an incredibly powerful and versatile framework. This is the same tool that the pros use, but don't feel intimidated! GStreamer actually makes it very easy to do impressive things with video and you'll be well on your way to making something great in just the time it takes to watch this talk.

If you fall behind at any point during the live presentation, don't worry! I have a text version of this talk available with the same content and more. There should be a link in the description.

Installing Dependencies

Let's start by installing everything we'll need to start using GStreamer in Python. This is probably the hardest part, so if you managed to do it before this talk, it's all smooth sailing fro

@ChengLuFred
ChengLuFred / cheat sheet.md
Last active January 14, 2024 05:42
[Markdown Cheat Sheet] #Markdown
  1. Markdown markdown

  2. R markdown rmarkdown

@ndevenish
ndevenish / CMakeLists.txt
Last active March 4, 2024 22:47
Very simple "Getting started" boost-python CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
# Find python and Boost - both are required dependencies
find_package(PythonLibs 2.7 REQUIRED)
find_package(Boost COMPONENTS python REQUIRED)
# Without this, any build libraries automatically have names "lib{x}.so"
set(CMAKE_SHARED_MODULE_PREFIX "")
# Add a shared module - modules are intended to be imported at runtime.
@fernandoremor
fernandoremor / video.py
Created February 1, 2017 14:32 — forked from artizirk/01-video.py
python v4l2 webcam capture test
#!/usr/bin/env python3
from v4l2 import *
import fcntl
import mmap
import select
import time
vd = open('/dev/video0', 'rb+', buffering=0)
@BretFisher
BretFisher / docker-swarm-ports.md
Last active June 11, 2024 14:06
Docker Swarm Port Requirements, both Swarm Mode 1.12+ and Swarm Classic, plus AWS Security Group Style Tables

Docker Swarm Mode Ports

Starting with 1.12 in July 2016, Docker Swarm Mode is a built-in solution with built-in key/value store. Easier to get started, and fewer ports to configure.

Inbound Traffic for Swarm Management

  • TCP port 2377 for cluster management & raft sync communications
  • TCP and UDP port 7946 for "control plane" gossip discovery communication between all nodes
  • UDP port 4789 for "data plane" VXLAN overlay network traffic
  • IP Protocol 50 (ESP) if you plan on using overlay network with the encryption option

AWS Security Group Example

@NBonaparte
NBonaparte / gst-camera-record
Last active August 17, 2023 14:26
Python 3 program using Gstreamer 1.0 that shows video stream and allows for uninterrupted recording.
#!/usr/bin/python3
# This program is licensed under GPLv3.
from os import path
import gi
gi.require_version('Gst', '1.0')
gi.require_version('Gtk', '3.0')
gi.require_version('GdkX11', '3.0')
gi.require_version('GstVideo', '1.0')
from gi.repository import GObject, Gst, Gtk