|
|
@ -29,6 +29,14 @@ def go():
|
|
|
|
#selectedBin = sort.sort(itema)
|
|
|
|
#selectedBin = sort.sort(itema)
|
|
|
|
#control_motor.goToBin(selectedBin)
|
|
|
|
#control_motor.goToBin(selectedBin)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def sendString(string):
|
|
|
|
|
|
|
|
print("Found " + string)
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
conn.sendall(string.encode('utf-8'))
|
|
|
|
|
|
|
|
except socket.error:
|
|
|
|
|
|
|
|
print("Error Occured.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not video:
|
|
|
|
if not video:
|
|
|
|
elapsed_time = timeit.timeit(go, number=1)/1
|
|
|
|
elapsed_time = timeit.timeit(go, number=1)/1
|
|
|
|
print(elapsed_time)
|
|
|
|
print(elapsed_time)
|
|
|
@ -39,17 +47,21 @@ else :
|
|
|
|
host = '' # Symbolic name meaning all available interfaces
|
|
|
|
host = '' # Symbolic name meaning all available interfaces
|
|
|
|
port = 9001 # Arbitrary non-privileged port
|
|
|
|
port = 9001 # Arbitrary non-privileged port
|
|
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
|
|
|
|
#s.setsockopt(s, socket.SOL_SOCKET, socket.SO_REUSEADDR)
|
|
|
|
s.bind((host, port))
|
|
|
|
s.bind((host, port))
|
|
|
|
|
|
|
|
print("waiting for connection")
|
|
|
|
s.listen(1)
|
|
|
|
s.listen(1)
|
|
|
|
conn, addr = s.accept()
|
|
|
|
conn, addr = s.accept()
|
|
|
|
print('Connected to', addr)
|
|
|
|
print('Connected to', addr)
|
|
|
|
time.sleep(1)
|
|
|
|
time.sleep(2)
|
|
|
|
waitForPi = True
|
|
|
|
waitForPi = True
|
|
|
|
while waitForPi is True:
|
|
|
|
while waitForPi is True:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
print("waiting for data")
|
|
|
|
data = conn.recv(1024)
|
|
|
|
data = conn.recv(1024)
|
|
|
|
if not data: break
|
|
|
|
if not data: break
|
|
|
|
print "Client: "+data
|
|
|
|
encoding = 'utf-8'
|
|
|
|
|
|
|
|
print ("Client: "+str(data))
|
|
|
|
waitForPi = False
|
|
|
|
waitForPi = False
|
|
|
|
except socket.error:
|
|
|
|
except socket.error:
|
|
|
|
print("Error Occured.")
|
|
|
|
print("Error Occured.")
|
|
|
@ -68,6 +80,7 @@ else :
|
|
|
|
#print('frame')
|
|
|
|
#print('frame')
|
|
|
|
if x > 1:
|
|
|
|
if x > 1:
|
|
|
|
ret,frame = capture.retrieve()
|
|
|
|
ret,frame = capture.retrieve()
|
|
|
|
|
|
|
|
frame = frame[130:1000, 450:1475]
|
|
|
|
items,output = detect.detect(calibration_width, frame, True, True)
|
|
|
|
items,output = detect.detect(calibration_width, frame, True, True)
|
|
|
|
cv2.imshow('Item Sorter', output)
|
|
|
|
cv2.imshow('Item Sorter', output)
|
|
|
|
x = 0
|
|
|
|
x = 0
|
|
|
@ -101,12 +114,6 @@ else :
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
if cv2.waitKey(1)&0xFF == ord('q'):
|
|
|
|
if cv2.waitKey(1)&0xFF == ord('q'):
|
|
|
|
|
|
|
|
s.close()
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
def sendString(string):
|
|
|
|
|
|
|
|
print("Found " + string)
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
conn.sendall(string)
|
|
|
|
|
|
|
|
except socket.error:
|
|
|
|
|
|
|
|
print("Error Occured.")
|
|
|
|
|
|
|
|
break
|
|
|
|
|