Skip to content

Instantly share code, notes, and snippets.

View davidrs's full-sized avatar

David Rust-Smith davidrs

View GitHub Profile
@davidrs
davidrs / face_tracking_mask.py
Created October 30, 2020 17:25
Track your face and replace it with a mask image like a snapchat filter.
"""
Track your face and replace it with a mask image.
Based on very helpful, but somewhat buggy code in this tutorial:
https://analyticsindiamag.com/how-to-build-your-own-face-filter-with-opencv/
Setup:
0) pip install dlib and opencv
1) Download shape_predictor_68_face_landmarks.dat from https://github.com/AKSHAYUBHAT/TensorFace/raw/master/openface/models/dlib/shape_predictor_68_face_landmarks.dat
2) Make a mask.png image for your face.
@davidrs
davidrs / gist:6530c4b4b1753bfc934e0334119f67e6
Created October 10, 2017 21:42
Adding Conda to any Docker file
# I found some snippets around the web that didn't work, this is what did workf or me.
# This assumes a linux based Docker image, in my case an Ubunut one.
# I was trying to add conda to leyden5iwx/caffe-cpu-master
# Base Docker image
FROM tleyden5iwx/caffe-cpu-master
# misc apt-get installs....
# Install miniconda to /miniconda
@davidrs
davidrs / raspi-ble-notifications.py
Created September 25, 2017 00:31
Raspberry Pi code to use bluepy to start BLE notifications on a characteristic.
# This code is intended to run on a device with up to date Bluez.
# Works on Raspberry Pi or Mac.
# Currently configured to stream heart rate.
# https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.service.heart_rate.xml
# Bluepy Docs
# @see http://ianharvey.github.io/bluepy-doc/
# Notifciations doc:
# @see http://ianharvey.github.io/bluepy-doc/notifications.html
# Code assumes adapter is already enabled, and scan was already done.
/*
Patrick the drink pourer
This code is for an Arduino hooked up to a servo
that will sweep when it sees a sudden delta in its
photoresistor.
Photoresistor wires: A4, 10~
Resistor A4 to Grnd
Servo: 9~, 5V and Grnd
*/
<!--
1. Load legend json from the service
-->
<script>
var myService = 'http://fake.com/arcgis/rest/services/Timor/IlliteracyRate/MapServer';
$.ajax({
url: myService + '/legend',
data:{f: 'pjson'},
dataType: 'jsonp'
}).then(function(esriLegend){