This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pigpio | |
import RPi.GPIO as GPIO | |
class PWM: | |
def __init__(self): | |
self.pi = pigpio.pi() | |
self.freq = 100 | |
self.steering = 0 | |
self.acceleration = 0 | |
self.gpioPinAcceleration = 18 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sendToGoogleDrive(fileName,filePath,pathToClientSecrets="/PATH/TO/credentials.json"): | |
gauth = GoogleAuth() | |
gauth.LoadClientConfigFile(pathToClientSecrets) # <----- | |
drive = GoogleDrive(gauth) | |
folder_id = 'XXXX' // example .../folders/XXXX or ..../folders/13vovGVWKWz1KvFmBFwjxIMCT5dE-WFSx | |
file1 = drive.CreateFile({ | |
'title': 'data.csv', | |
"mimeType": "text/csv", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http.server | |
import socketserver | |
class Handler(http.server.BaseHTTPRequestHandler): | |
def do_GET(self): | |
if self.path == '/data': # handle any GET requests to /data | |
pass | |
elif self.path == '/annotation':# handle any GET requests to /annotation | |
pass | |
def do_POST(self): # handle general post event |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
def calculate_hull(img,sensitivity=0.25): | |
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) | |
gray = np.float32(gray) | |
corners = cv2.goodFeaturesToTrack(gray, 100, sensitivity, 10) | |
corners = np.int0(corners) | |
hull = cv2.convexHull(corners) | |
return hull |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create3DFaces(sideHull,frontHull): | |
sideHull = normalize(sideHull) | |
frontHull = normalize(frontHull) | |
sideHull = addZAxis(sideHull) | |
frontHull = addZAxis(frontHull) | |
frontHull = rotate_by_90(frontHull) | |
frontHull,sideHull,hull_back = match_front_face(frontHull,sideHull) | |
faces = construct_faces(frontHull,hull_back) | |
faces = scale_down_faces(faces) | |
return faces |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_mesh(self): | |
if processor.ready_to_send(): | |
faces = processor.get_faces() | |
"""Respond to a GET request.""" | |
self.send_response(200) | |
self.send_header("Content-type", "text") | |
self.end_headers() | |
for i in range(len(faces)): | |
self.wfile.write("N".encode()) | |
self.wfile.write(str(len(faces[i])).encode()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def deal_post_data(self): | |
ctype, pdict = cgi.parse_header(self.headers['Content-Type']) | |
pdict['boundary'] = bytes(pdict['boundary'], "utf-8") | |
pdict['CONTENT-LENGTH'] = int(self.headers['Content-Length']) | |
if ctype == 'multipart/form-data': | |
form = cgi.FieldStorage( fp=self.rfile, headers=self.headers, environ={'REQUEST_METHOD':'POST', 'CONTENT_TYPE':self.headers['Content-Type'], }) | |
# typeOfImage = form["Type"].value + '.png' | |
bbox = { | |
'x':int(form["x"].value), | |
'y':int(form["y"].value), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IEnumerator TakePhoto(string type) // Start this Coroutine on some button click | |
{ | |
// NOTE - you almost certainly have to do this here: | |
yield return new WaitForEndOfFrame(); | |
Texture2D tex = new Texture2D(Screen.width, Screen.height,TextureFormat.RGB24, false); | |
tex.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); | |
tex.Apply(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UnityWebRequest www = UnityWebRequest.Get("http://SERVERIP:PORT/data"); | |
yield return www.SendWebRequest(); | |
Debug.Log(www.responseCode); | |
if(www.isNetworkError || www.isHttpError || www.responseCode == 500) { | |
GameObject myObject = GameObject.Find("ARCamera"); | |
myObject.GetComponent<Buttons>().showError("Need to Capture Front and Side!"); | |
yield return new WaitForSeconds(3); | |
myObject.GetComponent<Buttons>().clearError(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void OnTrackableStateChanged( | |
TrackableBehaviour.Status previousStatus, | |
TrackableBehaviour.Status newStatus) | |
{ | |
if (newStatus == TrackableBehaviour.Status.DETECTED || | |
newStatus == TrackableBehaviour.Status.TRACKED || | |
newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) | |
{ | |
Debug.Log("Detected"); |
OlderNewer