diff --git a/captured_images/dual_path/image_info_20250817_144238.txt b/captured_images/dual_path/image_info_20250817_144238.txt deleted file mode 100755 index d2083c2..0000000 --- a/captured_images/dual_path/image_info_20250817_144238.txt +++ /dev/null @@ -1,8 +0,0 @@ -图像信息记录 - 20250817_144238 -图像尺寸: 1920 x 1080 -编码格式: rgb8 -步长: 5760 -数据大小: 6220800 字节 -ROS节点: simple_image_subscriber -话题: /rgb_camera/image_raw -图像数据已成功接收,ROS模块工作正常! diff --git a/task_1/task_1.py b/task_1/task_1.py index 1dbd063..422f059 100755 --- a/task_1/task_1.py +++ b/task_1/task_1.py @@ -21,7 +21,6 @@ from utils.log_helper import LogHelper, get_logger, section, info, debug, warnin logger = get_logger("任务1") observe = True - direction = True def run_task_1(ctrl, msg, time_sleep=5000): diff --git a/utils/image_raw.py b/utils/image_raw.py index 960ac43..d61fe44 100755 --- a/utils/image_raw.py +++ b/utils/image_raw.py @@ -63,7 +63,6 @@ from threading import Thread, Lock import time import queue from datetime import datetime -from utils.log_helper import get_logger # 导入AI相机服务 from protocol.srv import CameraService # qrcode @@ -81,7 +80,8 @@ class ImageSubscriber(Node): # 创建服务客户端 self.camera_client = self.create_client(CameraService, '/camera_service') while not self.camera_client.wait_for_service(timeout_sec=1.0): - self.get_logger().info('等待AI相机服务...') + print('waiting for camera service...') + # self.get_logger().info('等待AI相机服务...') # 图像订阅 self.image_sub = self.create_subscription( @@ -137,14 +137,14 @@ class ImageSubscriber(Node): rclpy.spin_until_future_complete(self, future) result = future.result() - self.get_logger().info(f'服务返回: [code={result.result}, msg="{result.msg}"]') + print(f'服务返回: [code={result.result}, msg="{result.msg}"]') if result.result == 0: - self.get_logger().info('相机启动成功') + print('相机启动成功') self.camera_started = True return True else: - self.get_logger().error(f'启动失败 (错误码 {result.result})') + print(f'启动失败 (错误码 {result.result})') return False def stop_camera(self): @@ -160,14 +160,14 @@ class ImageSubscriber(Node): rclpy.spin_until_future_complete(self, future, timeout_sec=2.0) if future.result().result == 0: - self.get_logger().info('相机已停止') + print('相机已停止') self.camera_started = False return True else: - self.get_logger().error(f'停止失败: {future.result().msg}') + print(f'停止失败: {future.result().msg}') return False except Exception as e: - self.get_logger().error(f'停止异常: {str(e)}') + print(f'停止异常: {str(e)}') return False def save_image(self, image, prefix): @@ -179,10 +179,10 @@ class ImageSubscriber(Node): timestamp = datetime.now().strftime("%Y%m%d_%H%M%S_%f") filename = f"{self.save_dir}/{prefix}_{timestamp}.jpg" cv2.imwrite(filename, image) - # self.get_logger().info(f"已保存 {prefix} 图像: {filename}") + print(f"已保存 {prefix} 图像: {filename}") return True except Exception as e: - self.get_logger().error(f"保存{prefix}图像失败: {str(e)}") + print(f"保存{prefix}图像失败: {str(e)}") return False def image_callback_rgb(self, msg): @@ -200,7 +200,7 @@ class ImageSubscriber(Node): self.save_image(self.cv_image_rgb, 'rgb') self.last_save_time['rgb'] = time.time() except Exception as e: - self.get_logger().error(f"RGB图像处理错误: {str(e)}") + print(f"RGB图像处理错误: {str(e)}") def image_callback_left(self, msg): try: @@ -209,7 +209,7 @@ class ImageSubscriber(Node): self.save_image(self.cv_image_left, 'left') self.last_save_time['left'] = time.time() except Exception as e: - self.get_logger().error(f"左图像处理错误: {str(e)}") + print(f"左图像处理错误: {str(e)}") def image_callback_right(self, msg): try: @@ -218,7 +218,7 @@ class ImageSubscriber(Node): self.save_image(self.cv_image_right, 'right') self.last_save_time['right'] = time.time() except Exception as e: - self.get_logger().error(f"右图像处理错误: {str(e)}") + print(f"右图像处理错误: {str(e)}") def image_callback_ai(self, msg): try: @@ -227,7 +227,7 @@ class ImageSubscriber(Node): self.save_image(self.cv_image_ai, 'ai') self.last_save_time['ai'] = time.time() except Exception as e: - self.get_logger().error(f"ai图像处理错误: {str(e)}") + print(f"ai图像处理错误: {str(e)}") def safe_spin(self): """安全spin循环""" @@ -367,7 +367,7 @@ class ImageProcessor: """ if self.scan_thread is not None and self.scan_thread.is_alive(): # self.log.warning("异步扫描已经在运行中", "警告") - print('scan,warn') + print('[ImageProcessor] scan,warn') return self.enable_async_scan = True @@ -376,7 +376,7 @@ class ImageProcessor: self.scan_thread.daemon = True # 设为守护线程,主线程结束时自动结束 self.scan_thread.start() # self.log.info("启动异步 QR 码扫描线程", "启动") - print('start') + print('[ImageProcessor] start async scan') def stop_async_scan(self): """停止异步 QR 码扫描""" @@ -384,7 +384,7 @@ class ImageProcessor: if self.scan_thread and self.scan_thread.is_alive(): self.scan_thread.join(timeout=1.0) # self.log.info("异步 QR 码扫描线程已停止", "停止") - print('stop') + print('[ImageProcessor] stop async scan') def _async_scan_worker(self, interval): """异步扫描工作线程""" @@ -400,7 +400,7 @@ class ImageProcessor: try: self.is_scanning = True qr_data = self.decode_all_qrcodes(img) - print(qr_data) + print(f"[ImageProcessor] 异步扫描到 QR 码: {qr_data}") self.is_scanning = False with self.scan_lock: @@ -408,13 +408,13 @@ class ImageProcessor: self.last_qr_result = qr_data self.last_qr_time = current_time # self.log.success(f"异步扫描到 QR 码: {qr_data}", "扫描") - print(f"异步扫描到 QR 码: {qr_data}") + print(f"[ImageProcessor] 异步扫描到 QR 码: {qr_data}") except Exception as e: self.is_scanning = False # self.log.error(f"异步 QR 码扫描出错: {e}", "错误") - print(f"异步 QR 码扫描出错: {e}") + print(f"[ImageProcessor] 异步 QR 码扫描出错: {e}") else: - print('no img') + print('[ImageProcessor] no img') last_scan_time = current_time