def sub_BG(subject, noSubject): #load the color, depth, and IR img w/ subject c,d,i = test.load(subject) #load the color, depth, and IR img w/o subject cN,dN,iN = test.load(noSubject) #convert depth and IR to uint8 (openCV's preferred format) d = test.to_uint8(d) dN = test.to_uint8(dN) i = test.to_uint8(i) iN = test.to_uint8(iN) #subtract background from subject in depth image noBG_depth = cv2.subtract(d, dN) #perform a threshold operation to add contrast to subject in depth image ret, noBG_depth = cv2.threshold(noBG_depth, 1, 255, cv2.THRESH_BINARY) #subtract background from subject in IR image noBG_IR = cv2.subtract(i, iN) #subtract background from subject in color image noBG_color = cv2.subtract(c, cN) #perform a threshold operation to add contrast to subject in IR image #ret, noBG_IR = cv2.threshold(noBG_IR, 1, 255, cv2.THRESH_BINARY) return (noBG_color, noBG_depth, noBG_IR)
#!/usr/bin/env python import test import sys if __name__ == '__main__': if len(sys.argv) == 2: test.load(sys.argv[1]) else: print 'Usage: load.py <filename>'
#!/usr/bin/env python import sys import time # import test utilities and configuration import test if __name__ == '__main__': # load test program onto arduino test.load('serial_test.hex') # open serial port ser = test.ser_open(1) output = [ 0 ] while True: for i in range(256): output[0] = i print "Sending byte %d"%i ser.write(str(bytearray(output))) inc = ser.read() if len(inc) != 1: print "Receive byte timed out" test.fail() else: print "Got byte %d"%ord(inc[0]) if ord(inc[0]) != output[0]: print "Got a byte I wasn't expecting" test.fail()
import test print test # TODO this should work even if we don't keep a reference to l; # it doesn't currently always work, but it sometimes works, so it's hard # to mark this case as "expected: fail". # Instead just weaken the test, and add this TODO to add the harder test back # later. l = [] test.store(l) print test.load() class C(object): def __init__(self): self.x = self.y = self.z = self.w = self.k = self.a = self.b = self.c = 1 for i in xrange(100000): C() print "This will break" print test.load()
#!/usr/bin/env python import sys import time # import test utilities and configuration import test if __name__ == '__main__': # load test program onto arduino test.load('serial_test.hex') # open serial port ser = test.ser_open(1) output = [ 0 ] for i in range(256): output[0] = i print "Sending byte %d"%i ser.write(str(bytearray(output))) inc = ser.read() if len(inc) != 1: print "Receive byte timed out" test.fail() else: print "Got byte %d"%ord(inc[0]) if ord(inc[0]) != output[0]: print "Got a byte I wasn't expecting" test.fail()
#!/usr/bin/env python import serial import test if __name__ == '__main__': test.load('locking.hex') ser = test.ser_open() lower = 0 upper = 0 while True: input = ser.read(26) if input == "`zyxwvutsrqponmlkjihgfedcb": lower += 1 elif input == "@ABCDEFGHIJKLMNOPQRSTUVWXY": upper += 1 else: print "\nInput mismatch %s"%input lower = 0 upper = 0 print "\rUpper %d, Lower %d"%(upper, lower),
active = True print("\nWelcome to your inventory program, Sydney!") # Main program loop while active: prompt = input(f"\nWhat would you like to do first?" "\nView inventory 'view'" "\nAdd new items 'add'" "\nUpdate counts 'update'" "\nDelete an item 'delete'" "\nSave 'save'" "\n>> ") scentsyItems = load() # View the current inventory if prompt == 'view': # Category # Item: Count # Loop through main dictionary for category, item in scentsyItems.items(): print(f"\nCategory: {category.title()}") for key, value in item.items(): print(f"\tScent: {key.title()} | Amount: {value}") # Add to the current inventory elif prompt == 'add': # Gather what category
#!/usr/bin/env python import serial import test if __name__ == '__main__': test.load('locking.hex') ser = test.ser_open() lower = 0 upper = 0 while True: input = ser.read(26) if input == "`zyxwvutsrqponmlkjihgfedcb": lower += 1 elif input == "@ABCDEFGHIJKLMNOPQRSTUVWXY": upper += 1 else: print "\nInput mismatch %s" % input lower = 0 upper = 0 print "\rUpper %d, Lower %d" % (upper, lower),
#!/usr/bin/env python import serial import test if __name__ == '__main__': test.load('burst_tx.hex') ser = test.ser_open(1) print "Waiting for input" rx_size = 10 rx_old_size = 0 rx_old_size_cnt = 0 while rx_old_size_cnt < 5: input = ser.read(rx_size) rx_size = len(input) print "Got burst of size %d" % rx_size tx = [rx_size & 0xff, (rx_size >> 8) & 0xff] ser.write(str(bytearray(tx))) print "Sent response of %d" % rx_size if rx_size == rx_old_size: rx_old_size_cnt += 1 else: rx_old_size = 0 rx_old_size = rx_size rx_size += 10
import cv2 from keras.models import load_model import numpy as np from test import load from args import get_train_args, get_setup_args args_ = get_train_args() # parameters for loading data and images detection_model_path = 'haarcascade_files/haarcascade_frontalface_default.xml' emotion_model_path = 'model/ResNet18_best.h5' # hyper-parameters for bounding boxes shape # loading models face_detection = cv2.CascadeClassifier(detection_model_path) emotion_classifier = load(emotion_model_path, args_) EMOTIONS = [ "angry", "disgust", "scared", "happy", "sad", "surprised", "neutral" ] cv2.namedWindow('your_face') camera = cv2.VideoCapture(0) while True: frame = camera.read()[1] #reading the frame frame = imutils.resize(frame, width=300) gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) faces = face_detection.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30),
#!/usr/bin/env python import serial import test if __name__ == "__main__": test.load("burst_tx.hex") ser = test.ser_open(1) print "Waiting for input" rx_size = 10 rx_old_size = 0 rx_old_size_cnt = 0 while rx_old_size_cnt < 5: input = ser.read(rx_size) rx_size = len(input) print "Got burst of size %d" % rx_size tx = [rx_size & 0xFF, (rx_size >> 8) & 0xFF] ser.write(str(bytearray(tx))) print "Sent response of %d" % rx_size if rx_size == rx_old_size: rx_old_size_cnt += 1 else: rx_old_size = 0 rx_old_size = rx_size rx_size += 10