|
|
|
@ -30,7 +30,7 @@ def go():
|
|
|
|
|
#control_motor.goToBin(selectedBin)
|
|
|
|
|
|
|
|
|
|
def sendString(string):
|
|
|
|
|
print("[ INFO ] Item found: " + string)
|
|
|
|
|
print("[ INFO ] Sending message: " + string)
|
|
|
|
|
try:
|
|
|
|
|
conn.sendall(string.encode('utf-8'))
|
|
|
|
|
except socket.error:
|
|
|
|
@ -42,7 +42,8 @@ if not video:
|
|
|
|
|
print(elapsed_time)
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
host = '' # Symbolic name meaning all available interfaces
|
|
|
|
|
port = 9001 # Arbitrary non-privileged port
|
|
|
|
@ -72,6 +73,7 @@ else :
|
|
|
|
|
x = 0
|
|
|
|
|
currentItem = ""
|
|
|
|
|
samples = 0
|
|
|
|
|
intake = False
|
|
|
|
|
while True:
|
|
|
|
|
ret = capture.grab()
|
|
|
|
|
x+=1
|
|
|
|
@ -81,14 +83,16 @@ else :
|
|
|
|
|
#print('frame')
|
|
|
|
|
if x > 1:
|
|
|
|
|
ret,frame = capture.retrieve()
|
|
|
|
|
frame = frame[130:1100, 300:1300]
|
|
|
|
|
frame = frame[300:1080, 300:1620]
|
|
|
|
|
#frame = frame[170:900, 475:1100]
|
|
|
|
|
items,output = detect.detect(calibration_width, frame, True, True)
|
|
|
|
|
cv2.imshow('Item Sorter', output)
|
|
|
|
|
x = 0
|
|
|
|
|
if len(items) > 0:
|
|
|
|
|
#items.remove("Penny")
|
|
|
|
|
if intake is True:
|
|
|
|
|
sendString("Pause ")
|
|
|
|
|
intake = False
|
|
|
|
|
itema = items[0]
|
|
|
|
|
valid = True
|
|
|
|
|
for item in items:
|
|
|
|
@ -105,6 +109,7 @@ else :
|
|
|
|
|
if samples >= 10:
|
|
|
|
|
samples = 0
|
|
|
|
|
capture.release()
|
|
|
|
|
time.sleep(2)
|
|
|
|
|
sendString(currentItem)
|
|
|
|
|
waitForPi = True
|
|
|
|
|
while waitForPi is True:
|
|
|
|
@ -122,8 +127,10 @@ else :
|
|
|
|
|
else:
|
|
|
|
|
if samples > 0:
|
|
|
|
|
samples -= 1
|
|
|
|
|
if samples == 0:
|
|
|
|
|
if samples == 0 and intake is False:
|
|
|
|
|
sendString("Intake")
|
|
|
|
|
intake = True
|
|
|
|
|
time.sleep(0.25)
|
|
|
|
|
if cv2.waitKey(1)&0xFF == ord('q'):
|
|
|
|
|
print("[ EXIT ] Shutting down.")
|
|
|
|
|
s.shutdown(1)
|
|
|
|
|