| 12345678910111213141516171819202122232425262728293031323334 |
- import zmq, json
- # def __send_tcp_message(socket, msg):
- # socket.send_string(json.dumps(msg, ensure_ascii=False))
- # rep = socket.recv()
- # str_msg = rep.decode("utf-8")
- # json_msg = json.loads(str_msg)
- # return json_msg
- # LISTEN_REQ = "tcp://127.0.0.1:54543"
- # SET_REQ = "tcp://127.0.0.1:54544"
- # context = zmq.Context()
- # req_socket = context.socket(zmq.REQ)
- # # 设置发送超时为 5000 毫秒(5 秒)
- # req_socket.setsockopt(zmq.RCVTIMEO, 2 * 1000)
- # # 设置接收超时为 5000 毫秒(5 秒)
- # req_socket.setsockopt(zmq.SNDTIMEO, 2 * 1000)
- # req_socket.setsockopt(zmq.LINGER, 0) # 设置为 0 表示不等待未完成的操作
- # req_socket.connect(SET_REQ)
- # req = {}
- # req["msg_type"] = "Request"
- # req["msg_id"] = "GetCamera"
- # req["msg_seq_num"] = 0
- # req["CameraSelection"] = "Single"
- # req["CameraKey"] = "Canon Inc.|Canon EOS 650D|12"
- # json_msg = __send_tcp_message(req_socket,req)
- # cameraInfo = json_msg.get("CameraInfo")
- # print("cameraInfo",json_msg)
- from service.remove_bg_ali import RemoveUltraBackground
- import settings
- settings.USER_TOKEN = "c2f44c4c1171b84d13ee21f770fd32e773b910f2"
- r = RemoveUltraBackground()
- path = r"C:\Users\15001\Desktop\miniso\hb\原始图\hb(1).JPG"
- out_path = "{}._no_bg-out.png".format(path)
- r.get_image_cut(path, out_file_path=out_path)
|