Skip to content

Instantly share code, notes, and snippets.

@jwhendy
jwhendy / set_opencv_webcam.py
Last active September 8, 2023 09:52
An example of setting webcam settings via v4l2-ctl in a python script. Some of the CAP_* settings in opencv didn't seem to work.
import cv2
import subprocess
### for reference, the output of v4l2-ctl -d /dev/video1 -l (helpful for min/max/defaults)
# brightness (int) : min=0 max=255 step=1 default=128 value=128
# contrast (int) : min=0 max=255 step=1 default=128 value=128
# saturation (int) : min=0 max=255 step=1 default=128 value=128
# white_balance_temperature_auto (bool) : default=1 value=1
# gain (int) : min=0 max=255 step=1 default=0 value=0
# power_line_frequency (menu) : min=0 max=2 default=2 value=2
@jwhendy
jwhendy / dash-dynamic-fiddling.py
Last active March 5, 2018 11:58
A plotly dash app where I want to have a dynamic number of text boxes and access their values from a callback when a button is pushed.
import dash
from dash.dependencies import Input, Output, Event, State
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
app.config.supress_callback_exceptions = True
app.css.append_css({'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css'})
#!/usr/bin/env python
import datetime
import os
import math
import numpy as np
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
@jwhendy
jwhendy / matrix-teensy.ino
Last active September 26, 2017 18:11
Code used to run some fun animations/routines on a 16x16 WS2812 LED matrix
/*
* Based on SpectrumAnalyzerBasic by Paul Stoffregen included in the Teensy Audio Library
* Modified by Jason Coon for the SmartMatrix Library
* Requires Teensyduino 1.20 or higher and the Teensy Audio Library
* Also requires FastLED 3.1 or higher
* If you are having trouble compiling, see
* the troubleshooting instructions here:
* https://github.com/pixelmatix/SmartMatrix/#external-libraries
*
* actual code found:
#include "FastLED.h"
#define REDPIN 5
#define GREENPIN 6
#define BLUEPIN 3
// blend() below can take two CRGB or CHSV colors
// CRGB color1 = CRGB(255, 0, 0);
// CRGB color2 = CRGB(0, 0, 255);
#include "FastLED.h"
// must use fastLED 3.1: https://github.com/FastLED/FastLED/tree/FastLED3.1
// fast led constants and initialize
#define DATA_PIN 9
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 48
CRGB leds[NUM_LEDS];
@jwhendy
jwhendy / fill_gradient_demo.ino
Last active October 23, 2015 04:09
A quick demo of using fill_gradient per a request on the FastLED Google+ community.
#include "FastLED.h"
// fast led constants
#define DATA_PIN 3 // change to your data pin
#define COLOR_ORDER GRB // if colors are mismatched; change this
#define NUM_LEDS 28 // change to the number of LEDs in your strip
// change WS2812B to match your type of LED, if different
// list of supported types is here:
// https://github.com/FastLED/FastLED/wiki/Overview
@jwhendy
jwhendy / _.md
Created February 12, 2014 01:54
transpo explorer