Skip to content

Instantly share code, notes, and snippets.

View nhomble's full-sized avatar
🐕

Nicolas nhomble

🐕
View GitHub Profile
@nhomble
nhomble / songGuesser
Last active August 29, 2015 14:01
bored at the airport... when my brother is around we play this game
#!/usr/bin/env bash
SOURCE=$1
if [ -z "$SOURCE" ]; then
echo "I need the source directory"
exit
fi
if [ ! -d "$SOURCE" ]; then
echo "You did not give me a directory"
@nhomble
nhomble / mm
Last active August 29, 2015 14:04
message me.. never be late again!
#!/usr/bin/env bash
usage(){
cat << EOF
usage: $0 options
message me, send text message to a phone
PLEASE have an ssh key, cause otherwise this makes
no sense!
@nhomble
nhomble / mtp-box
Last active August 29, 2015 14:04
at long last, a dumb utility to move files from my computer to my Galaxy S3
#!/usr/bin/env bash
DIR_NAME="/home/nicolas/phone-sync/"
IFS=$'\n'
function main() {
DIR_KEY=$(mtp-folders | grep "sync" | sed 's/\([0-9]\+\)\s.*/\1/g')
loadLocalFiles
loadPhoneFiles
@nhomble
nhomble / scraper.py
Created September 25, 2015 23:52
playing with web scraper (Beautiful Soup) to expose BodyBuilding.com's exercise database (to later be turned into a restful service maybe)
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import pycurl
from io import BytesIO
import re
import sys
END = "abcdefghijklmnopqrstuvwxyz0123456789"
BB_URL = "http://www.bodybuilding.com/exercises/list/index/selected/"
class FibCoder:
'''
https://en.wikipedia.org/wiki/Fibonacci_coding
'''
def __init__(self, seed: int = 2):
self._fib = []
self._fibonacci(seed)
def _next_fib(self, n: int):
@nhomble
nhomble / opencv_denoise_tutorial.py
Last active September 5, 2017 05:33
computational photography discussion 2---wrap two opencv tutorials to grab an image from the webcam and denoise it
import cv2
from matplotlib import pyplot as plt
def before_after(bef, af):
"""
refactor out the matplot lib thing
"""
plt.subplot(121), plt.imshow(bef, 'gray')
plt.subplot(122), plt.imshow(af, 'gray')
@nhomble
nhomble / opencv_denoise_rt_tutorial.py
Last active September 7, 2017 06:16
denoise in real time
import cv2
import numpy as np
def get_img(cap):
ret, frame = cap.read()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
return frame
@nhomble
nhomble / gauss_smooth.py
Created October 1, 2017 23:05
Try gaussian smoothing across different scenarios
import cv2
import matplotlib.pyplot as plt
kernel = (7, 7)
imgs = {
"salt_n_pepper": cv2.imread("Noise_salt_and_pepper.png"), # thank you wikipedia
"wrinkles": cv2.imread("old_man.jpeg"), # images.pexels.com
"tripod": cv2.imread("tripod.png") # classic b/w man looking at camera on tripod
}
@nhomble
nhomble / diff_of_gauss.py
Created October 9, 2017 04:12
interactively do quick edge detection via difference of gaussian
import cv2
def dog(img, k2=(7, 7), k1=(3, 3), denoise=False, denoise_k=3):
blur1 = cv2.GaussianBlur(img, k1, 1)
blur2 = cv2.GaussianBlur(img, k2, 1)
diff = blur1 - blur2
if denoise:
diff = cv2.medianBlur(diff, denoise_k)
return diff
@nhomble
nhomble / color_experiment.py
Last active October 22, 2017 22:42
demonstrate easy color extraction with HSV rather than RGB
import cv2
import numpy as np
import matplotlib.pyplot as plt
"""
Starting motivation [https://docs.opencv.org/3.2.0/df/d9d/tutorial_py_colorspaces.html]
RGB has no concept of hue unlike HS* (in this case we will do HSV). While we can extract it, it's not as straightforward
as with HSV. In our image, let's say we want to find the green parts. In HSV, we can do a pretty good job by just with
just an arc in the hue and then a fixed saturation range and value. Green can only exist in ~[90,150] degrees. Given