|
|
@ -30,7 +30,7 @@ def go():
|
|
|
|
#control_motor.goToBin(selectedBin)
|
|
|
|
#control_motor.goToBin(selectedBin)
|
|
|
|
|
|
|
|
|
|
|
|
def sendString(string):
|
|
|
|
def sendString(string):
|
|
|
|
print("[ INFO ] Item found: " + string)
|
|
|
|
print("[ INFO ] Sending message: " + string)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
conn.sendall(string.encode('utf-8'))
|
|
|
|
conn.sendall(string.encode('utf-8'))
|
|
|
|
except socket.error:
|
|
|
|
except socket.error:
|
|
|
@ -42,7 +42,8 @@ if not video:
|
|
|
|
print(elapsed_time)
|
|
|
|
print(elapsed_time)
|
|
|
|
|
|
|
|
|
|
|
|
else :
|
|
|
|
else :
|
|
|
|
#capture = cv2.VideoCapture('tcpclientsrc port=5001 host=192.168.1.129 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! videorate ! video/x-raw,framerate=5/1 ! appsink', cv2.CAP_GSTREAMER)
|
|
|
|
#capture = cv2.VideoCapture('tcpclientsrc port=5000 host=192.168.1.129 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! videorate ! video/x-raw,framerate=5/1 ! appsink', cv2.CAP_GSTREAMER)
|
|
|
|
|
|
|
|
#capture = cv2.VideoCapture('tcpclientsrc host=192.168.1.129 port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! autovideosink sync=false', cv2.CAP_GSTREAMER)
|
|
|
|
capture = cv2.VideoCapture('udpsrc port=9000 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" ! rtph264depay ! avdec_h264 ! videoconvert ! appsink sync=false', cv2.CAP_GSTREAMER)
|
|
|
|
capture = cv2.VideoCapture('udpsrc port=9000 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" ! rtph264depay ! avdec_h264 ! videoconvert ! appsink sync=false', cv2.CAP_GSTREAMER)
|
|
|
|
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
|
|
|
@ -72,6 +73,7 @@ else :
|
|
|
|
x = 0
|
|
|
|
x = 0
|
|
|
|
currentItem = ""
|
|
|
|
currentItem = ""
|
|
|
|
samples = 0
|
|
|
|
samples = 0
|
|
|
|
|
|
|
|
intake = False
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
ret = capture.grab()
|
|
|
|
ret = capture.grab()
|
|
|
|
x+=1
|
|
|
|
x+=1
|
|
|
@ -81,14 +83,16 @@ else :
|
|
|
|
#print('frame')
|
|
|
|
#print('frame')
|
|
|
|
if x > 1:
|
|
|
|
if x > 1:
|
|
|
|
ret,frame = capture.retrieve()
|
|
|
|
ret,frame = capture.retrieve()
|
|
|
|
frame = frame[130:1100, 300:1300]
|
|
|
|
frame = frame[300:1080, 300:1620]
|
|
|
|
#frame = frame[170:900, 475:1100]
|
|
|
|
#frame = frame[170:900, 475:1100]
|
|
|
|
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
|
|
|
|
if len(items) > 0:
|
|
|
|
if len(items) > 0:
|
|
|
|
#items.remove("Penny")
|
|
|
|
#items.remove("Penny")
|
|
|
|
|
|
|
|
if intake is True:
|
|
|
|
sendString("Pause ")
|
|
|
|
sendString("Pause ")
|
|
|
|
|
|
|
|
intake = False
|
|
|
|
itema = items[0]
|
|
|
|
itema = items[0]
|
|
|
|
valid = True
|
|
|
|
valid = True
|
|
|
|
for item in items:
|
|
|
|
for item in items:
|
|
|
@ -105,6 +109,7 @@ else :
|
|
|
|
if samples >= 10:
|
|
|
|
if samples >= 10:
|
|
|
|
samples = 0
|
|
|
|
samples = 0
|
|
|
|
capture.release()
|
|
|
|
capture.release()
|
|
|
|
|
|
|
|
time.sleep(2)
|
|
|
|
sendString(currentItem)
|
|
|
|
sendString(currentItem)
|
|
|
|
waitForPi = True
|
|
|
|
waitForPi = True
|
|
|
|
while waitForPi is True:
|
|
|
|
while waitForPi is True:
|
|
|
@ -122,8 +127,10 @@ else :
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if samples > 0:
|
|
|
|
if samples > 0:
|
|
|
|
samples -= 1
|
|
|
|
samples -= 1
|
|
|
|
if samples == 0:
|
|
|
|
if samples == 0 and intake is False:
|
|
|
|
sendString("Intake")
|
|
|
|
sendString("Intake")
|
|
|
|
|
|
|
|
intake = True
|
|
|
|
|
|
|
|
time.sleep(0.25)
|
|
|
|
if cv2.waitKey(1)&0xFF == ord('q'):
|
|
|
|
if cv2.waitKey(1)&0xFF == ord('q'):
|
|
|
|
print("[ EXIT ] Shutting down.")
|
|
|
|
print("[ EXIT ] Shutting down.")
|
|
|
|
s.shutdown(1)
|
|
|
|
s.shutdown(1)
|
|
|
|