fix: add #

This commit is contained in:
havocrao 2025-08-18 23:02:49 +08:00
parent 7499bf26a3
commit fe2e8e55b1

View File

@ -116,16 +116,12 @@ class ImageSubscriber(Node):
def image_callback(self, msg):
"""安全的图像回调"""
if getattr(self, '_shutdown_flag', False):
self.get_logger().warning('image_callback, shutdown')
print('image_callback, shutdown')
return
current_time = time.time()
elapsed = current_time - self.start_time
if elapsed >= self.total_duration:
self.get_logger().info("已完成30秒截图任务")
self._shutdown_flag = True
return
try:
self.cv_image = self.bridge.imgmsg_to_cv2(msg, 'bgr8')
@ -196,7 +192,7 @@ class ImageProcessor:
def get_current_image(self):
return self.image_subscriber.cv_image
def decode_qrcodes(self, img=None):
def decode_all_qrcodes(self, img=None):
"""使用pyzbar解码QR码"""
if img is None:
img = self.get_current_image()
@ -284,7 +280,8 @@ class ImageProcessor:
if img is not None:
try:
self.is_scanning = True
qr_data = self.decode_qrcode(img)
qr_data = self.decode_all_qrcodes(img)
print(qr_data)
self.is_scanning = False
with self.scan_lock:
@ -297,7 +294,9 @@ class ImageProcessor:
self.is_scanning = False
# self.log.error(f"异步 QR 码扫描出错: {e}", "错误")
print(f"异步 QR 码扫描出错: {e}")
else:
print('no img')
last_scan_time = current_time
# 短暂休眠避免占用过多 CPU