コード例 #1
0
def send_data_socket(data):
    constant = Constant.get_instance()
    if isinstance(data, str):
        data = data.encode()
    s = SocketUtil()
    s.set_up_client(constant.PORT_SOCKET_1)

    # send data to server
    s.send_data_to_server(data)

    # receive back data from server
    recv_data = s.receive_data_from_server()
    if recv_data != data:
        send_data_socket(data)
コード例 #2
0
    def check_socket(self):
        constant = Constant.get_instance()
        s = SocketUtil()
        s.set_up_server(constant.PORT_SOCKET_1)
        while True:
            try:
                # create connection
                s.create_connection()

                # receive data from client
                data = s.receive_data_from_client()
                print(data)

                # send back data to client
                s.send_data_to_client(data)

                # close connection
                s.close_connection()

                data = data.decode("utf-8")

                # if data is start or end recognition message, then stop all recognition thread  before
                # else add new recognition thread
                face_recognition_model = FaceRecognitionModel.get_instance()
                if data == constant.START_FACE_RECOGNITION_MESSAGE:
                    face_recognition_model.is_face_recognition = True
                elif data == constant.END_FACE_RECOGNITION_MESSAGE:
                    self.stop_all_camera()
                    self.cameras = []
                    face_recognition_model.is_face_recognition = False
                elif data == constant.TRAIN_NEW_FACE_MESSAGE:
                    train_face()
                elif data != b'':
                    self.cameras.append(CameraModel(data))
                    print(f"thread number: {threading.active_count()}")
            except Exception as ex:
                print(__file__)
                print(ex)
                continue
コード例 #3
0
from gui.action_main import btn_show, btn_face_recognition, get_face_detect

all_link_camera = []
# Create Camera Widgets
username = '******'
password = '******'

# Stream links
camera0 = 'rtsp://{}:{}@192.168.1.126/1'.format(username, password)
camera1 = 'rtsp://{}:{}@192.168.1.128/1'.format(username, password)

all_link_camera.append(camera0)
all_link_camera.append(camera1)

# constant
constant = Constant.get_instance()


class WidgetGallery(QDialog):
    def __init__(self, parent=None):
        super(WidgetGallery, self).__init__(parent)

        self.originalPalette = QApplication.palette()

        right_layout = self.create_right_layout()
        self.create_top_left_group_box()
        self.create_bottom_left_group_box()
        self.create_center_group_box()

        mainLayout = QGridLayout()
        mainLayout.addLayout(right_layout, 0, 2, 0, 1)