Skip to content

Instantly share code, notes, and snippets.

@bhive01
bhive01 / RGBpi.py
Last active January 23, 2017 23:46
#base packages
import os, sys
import errno
import datetime
import subprocess
from time import gmtime, strftime, sleep
#rPi packages
from picamera import PiCamera
import RPi.GPIO as GPIO
library(tidyverse)
df <- data.frame(Group = c(rep("A", 7), rep("B", 7), rep("C", 7)),
Time = c(rep(c(1:7), 3)),
Result = c(100, 96.9, 85.1, 62.0, 30.7, 15.2, 9.6,
10.2, 14.8, 32.26, 45.85, 56.25, 70.1, 100,
100, 55.61, 3.26, -4.77, -7.21, -3.2, -5.6))
df %>%
filter(Group != "B") %>% # filter out B because fails NLS fitting
# from https://stackoverflow.com/questions/32328179/opencv-3-0-python-lineiterator#
def createLineIterator(P1, P2, img):
"""
Produces and array that consists of the coordinates and intensities of each pixel in a line between two points
Parameters:
-P1: a numpy array that consists of the coordinate of the first point (x,y)
-P2: a numpy array that consists of the coordinate of the second point (x,y)
-img: the image being processed
import argparse
import sys
import os.path
import trans #pip install trans
import time
import cv2
import math
import skimage
import numpy as np
import sys
import os.path
import trans #pip install trans
import time
import datetime
import cv2
import math
import pandas as pd
import numpy as np
@bhive01
bhive01 / play3.py
Last active November 6, 2018 22:21
# Brandon Hurr
# Assumptions
# 1. Color card is Xrite Passport
# 2. Card is not mirrored
# 3. Only color calibration half of card is visible
# 4. When remove edges is selected at command line, the card is not at the edge of the image.
# 3. The scale factor is based upon median width of found objects (contours) that should be xrite squares, but could not be
# could be problematic with lots of squares objects in image other than color card
import argparse
import argparse
import trans #pip install trans
import time
import cv2
import math
import pandas as pd
import numpy as np
import zbar # sudo apt-get install libzbar-dev \ pip install zbar
from sklearn.neighbors import NearestNeighbors
from scipy.spatial.distance import squareform, pdist
library(tidyverse)
dt <- tibble(V1=c(1,2,4), V2=c("a","a","b"), V3=c(2,3,1))
swap_if<- function (condition, val1, val2, missing = NA)
{
if (!is.logical(condition)) {
stop("`condition` must be logical", call. = FALSE)
}
out1 <- val1[rep(NA_integer_, length(condition))]
---
output:
html_document:
mathjax: null
theme: null
highlight: null
pandoc_args: [
"+RTS", "-K64m",
"-RTS"
]
---
title: "testforcarson"
author: "Brandon Hurr"
date: "September 15, 2016"
output: html_document
---
```{r setup, eval = TRUE, echo = FALSE, warning = FALSE, message = FALSE, results='asis', out.width = 1000, out.height = 1000}
library(ggplot2)
library(dplyr)