Skip to content

Instantly share code, notes, and snippets.

View TonsOfFun's full-sized avatar
🏠
Working from home

Justin Bowen TonsOfFun

🏠
Working from home
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@TonsOfFun
TonsOfFun / leaf_area_dependencies.py
Created May 22, 2018 02:18
Using this in a medium post
import numpy as np
import imutils
import cv2
import matplotlib.pyplot as plt
%matplotlib inline
# Defined bounds using https://github.com/jrosebr1/imutils/blob/master/bin/range-detector
leaf_lower = (29, 0, 0)
leaf_upper = (255, 255, 128)
def leaf_mask(bgr_image):
frame = imutils.resize(bgr_image, width=500)
blurred = cv2.GaussianBlur(frame, (11, 11), 0)
hsv = cv2.cvtColor(blurred, cv2.COLOR_BGR2HSV)
# construct a mask for the color "green", then perform
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@TonsOfFun
TonsOfFun / request_signing.rb
Created May 14, 2018 17:36
Crypto Smart Camera: Pre-signed POST to S3
module RequestSigning
extend ActiveSupport::Concern
included do
before_action :set_s3_direct_post, only: [:new]
end
def set_s3_direct_post
@s3_direct_post = AWS_S3_BUCKET.presigned_post(key: "uploads/#{SecureRandom.uuid}/${filename}", success_action_status: '201', acl: 'public-read')
end
@TonsOfFun
TonsOfFun / note.py
Created May 14, 2018 17:30
Crypto Smart Camera: Uploading motion captures
import json
import re
import requests
class Note(object):
def __init__(self,
host=None,
title='',
body='',
profile='',
@TonsOfFun
TonsOfFun / motion_capture.py
Last active May 14, 2018 17:23
Crypto Smart Camera: Motion Capture
import io
import random
import picamera
from PIL import Image
from
import json
import re
import requests
global previous_frame
@TonsOfFun
TonsOfFun / motion.py
Created May 14, 2018 17:04
Crypto Smart Camera: Basic Motion
import imutils
def motion(current_frame=None, previous_frame=None, avg=None, min_area=2000):
motion = False
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (21, 21), 0)
# if the average frame is None, initialize it
if avg is None: