feat: 增加标注相关功能

This commit is contained in:
2025-10-26 14:25:30 +08:00
parent c8dfec6cf4
commit 856669de69
4 changed files with 795 additions and 42 deletions

View File

@@ -4,7 +4,7 @@ import uuid
import time
class ImageClient:
def __init__(self, server_address="tcp://10.42.70.1:54321", client_id=None):
def __init__(self, server_address="tcp://:54321", client_id=None):
self.server_address = server_address
self.client_id = client_id or f"client_{uuid.uuid4().hex[:8]}"
self.socket = None
@@ -43,7 +43,7 @@ class ImageClient:
"""发送同步请求到服务器"""
socket = None
try:
# 每次都创建一个新的socket实例以避免复用已关闭的socket
# 每次都创建一个新的 socket 实例以避免复用已关闭的 socket
socket = pynng.Req0()
socket.dial(self.server_address, block=True) # 使用阻塞模式确保连接建立
client_id_bytes = self.client_id.encode('utf-8')
@@ -54,7 +54,7 @@ class ImageClient:
print(f"Client {self.client_id} error: {e}")
return None
finally:
# 确保socket在使用后被正确关闭
# 确保 socket 在使用后被正确关闭
if socket:
try:
socket.close()