def run_samples(n): net = net6_c.NetSix_C() path = '/media/1tb/Izzy/nets/net6_05-11-2016_12h09m12s.ckpt' sess = net.load(path) bc = BinaryCamera('./meta.txt') bc.open() for i in range(4): bc.read_frame() num_samples = n samples = [] images = [] for i in range(num_samples): print i try: while True: frame = bc.read_frame() frame = inputdata.im2tensor(frame, channels=3) cv2.imshow('preview', frame) cv2.waitKey(30) except: pass frame = bc.read_frame() frame = similarity.color(frame) images.append(frame) print "Saved sample" np.save('samples_images.npy', images)
""" from gripper.TurnTableControl import * from gripper.PyControl import * from gripper.xboxController import * from pipeline.bincam import BinaryCamera from options import Options from lfd import LFD import argparse ap = argparse.ArgumentParser() ap.add_argument('-s', '--show', required=False, action='store_true') args = vars(ap.parse_args()) bincam = BinaryCamera('./meta.txt') bincam.open() options = Options() options.show = args['show'] options.record = False t = TurnTableControl( ) # the com number may need to be changed. Default of com7 is used izzy = PyControl(115200, .04, [0, 0, 0, 0, 0], [0, 0, 0]) # same with this c = XboxController([ options.scales[0], 155, options.scales[1], 155, options.scales[2], options.scales[3] ])
from pipeline.bincam import BinaryCamera import cv2 import time import numpy as np from Net.tensor import inputdata from edgeRICam import getTemplates, processFrame, findInitialMatch, traceObj, updateMatch bc = BinaryCamera("./meta.txt") bc.open() frame = bc.read_frame() #store processed templates; list of lists with various rotations of each template filtTemplates = getTemplates() sampleTemps = filtTemplates[0] filtFrame = processFrame(frame) pos, foundTemp = findInitialMatch(filtFrame, sampleTemps) out = traceObj(frame, pos, foundTemp) cv2.imshow("camera", out) print("initial match found- press any key to begin") cv2.waitKey(5000) try: while True: frame = bc.read_frame() filtFrame = processFrame(frame) pos, foundTemp = updateMatch(pos, frame, sampleTemps) out = traceObj(frame, pos, foundTemp) cv2.imshow("camera",out) cv2.waitKey(250) except KeyboardInterrupt: pass
Comment or uncomment "options.record = True" """ from gripper.TurnTableControl import * from gripper.PyControl import * from gripper.xboxController import * from pipeline.bincam import BinaryCamera from options import Options from lfd import LFD import argparse ap = argparse.ArgumentParser() ap.add_argument('-s', '--show', required=False, action='store_true') args = vars(ap.parse_args()) bincam = BinaryCamera('./meta.txt') bincam.open() options = Options() options.show = args['show'] options.record = False t = TurnTableControl() # the com number may need to be changed. Default of com7 is used izzy = PyControl(115200, .04, [0,0,0,0,0],[0,0,0]); # same with this c = XboxController([options.scales[0],155,options.scales[1],155,options.scales[2],options.scales[3]]) izzy.stop() #izzy.gotoState(None, .1, None, None, None, None])
from Net.tensor import tensornet, net2 from pipeline.bincam import BinaryCamera from options import Options import cv2 import numpy as np bc = BinaryCamera('./meta.txt') bc.open() options = Options() options.show = True options.record = False tfnet = net2.NetTwo() sess = tfnet.load(var_path=options.tf_dir + 'net2/net2_01-21-2016_02h14m08s.ckpt') im = bc.read_binary_frame(show=options.show, record=False) im = np.reshape(im, (125, 125, 1)) print(tfnet.output(sess, im)) sess.close() sess = tfnet.load(var_path=options.tf_dir + 'net2/net2_01-21-2016_02h14m08s.ckpt') print(tfnet.output(sess, im)) sess.close()
from pipeline.bincam import BinaryCamera import cv2 import numpy as np from Net.tensor import inputdata, net4 bc = BinaryCamera('./meta.txt') bc.open() frame = bc.read_frame() net_path = '/media/1tb/Izzy/nets/net4_02-17-2016_19h07m23s.ckpt' #vc = cv2.VideoCapture(0) #rval, frame = vc.read() tf_net = net4.NetFour() tf_net_path = net_path sess = tf_net.load(var_path=tf_net_path) while True: frame = bc.read_frame() img = cv2.resize(frame.copy(), (250, 250)) img = np.reshape(img, (250, 250, 3)) cv2.imwrite("test.jpg", img.copy()) img_jpg = cv2.imread("test.jpg", 1) not_saved = tf_net.output(sess, img, channels=3) saved = tf_net.output(sess, img, channels=3) print "NOT SAVED ", not_saved print "SAVED ", saved
from pipeline.bincam import BinaryCamera import cv2 import time from options import Options from Net.tensor import inputdata bc = BinaryCamera("./meta.txt") bc.open() frame = bc.read_frame() frames = [] fourcc = cv2.cv.CV_FOURCC(*'mp4v') writer = cv2.VideoWriter("hardware_reset.mov", fourcc, 10.0, (420,420)) try: while True: frame = bc.read_frame() frame = inputdata.im2tensor(frame, channels=3) cv2.imshow("camera",frame) cv2.waitKey(30) frames.append(frame) #time.sleep(0.08) except KeyboardInterrupt: pass #for frame in frames: # writer.write(frame) #writer.release()
i += 1 print "saved to: ", rollout_path if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("-e", "--experiment", type=str, help="run experiment, will prompt for name") args = parser.parse_args() if args.experiment: person = args.experiment else: person = None options = AMTOptions() bc = BinaryCamera('./meta.txt') bc.open() izzy = DexRobotZeke() izzy._zeke.steady(False) # t = DexRobotTurntable() t = None template_file = open(options.templates_dir + '/saved_template_paths.txt', 'r') c = XboxController([options.scales[0],155,options.scales[1],155,options.scales[2],options.scales[3]]) return_to_start(izzy) while True: print "Waiting for keypress ('q' -> quit, 'r' -> rollout, 'u' -> update weights, 't' -> test, 'd' -> demonstrate, 'c' -> compile train/test sets, 'p' -> run on previous template, 'l' -> run templates saved in 'last_templates'): " char = getch() if char == 'q':