Stop sign detection Development of visualization part part2 Notify another system by socket communication when an object is detected

Record up to the last time

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.

Functions to be realized

・ Socket communication is performed when the chair detects it.

Implemented code

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)

To next time

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.

bonus

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

Stop sign detection Development of visualization part part2 Notify another system by socket communication when an object is detected
Stop sign detection Development of visualization part part3 Notify by voice using socket communication when an object is detected
Stop sign detection Development of visualization part part4 When an object is detected, it is notified by voice using socket communication (multiple volumes)
Stop sign detection Development of visualization part part5 Display what was detected when an object was detected
Stop sign detection Development of visualization part part1 Detection and recording of objects * This time, the chair is detected (the model is not made by myself)