I have created a program to detect a stop sign from the last time. Last time, as a program to visualize when the stop sign was detected, record when the chair in the house was detected for the time being. I created a program. This time, we will create a program that performs socket communication to another program when it is detected.
・ Socket communication is performed when the chair detects it.
Client side
detect.py
if label1=="chair":
print("Detected a chair.")
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s2:
s2.connect(('127.0.0.1', 50007))
s2.sendall(b'isukenti')
data = s2.recv(1024)
server side
server.py
#Create socket server
import socket
# AF =Means IPv4
# TCP/For IP, SOCK_Use STREAM
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
#Specify IP address and port
s.bind(('127.0.0.1', 50007))
#1 connection
s.listen(1)
#Wait until you connect
while True:
#When someone visits, enter the connection and address
conn, addr = s.accept()
with conn:
while True:
#Receive data
data = conn.recv(1024)
if not data:
break
print('data : {}, addr: {}'.format(data, addr))
#Return data to client(b ->Must be byte)
conn.sendall(b'Received: ' + data)
Next, I would like to make a part to visualize in earnest. Specifically, I do not use the stop sign yet, but when I detected the chair, I used voice synthesis to "detect the chair". I'm thinking of a talkative program. Later, if possible, I would like to consider the visualization part that can be seen visually.
For the time being, some people may think that they are doing it in a chair and using the stop sign, so for the time being! You can do what you're doing with the stop sign, but you can't experiment because there's no stop sign in the house. So, I want to have the necessary functions before I take it outside, so I am trying to detect the chair I am sitting on for the time being. Please stop until the required functions can be implemented and wait for signboard detection. In addition, the details of the model are described above. For the time being, I would like to do something with the map and this program as the final target point. that's all.
Recommended Posts