Merge branch 'main' of http://121.37.111.42:3000/ThbTech/BodyBalanceEvaluation
This commit is contained in:
commit
67a3ff35f2
1
.gitignore
vendored
1
.gitignore
vendored
@ -21419,3 +21419,4 @@ backend/data/patients/202508060001/20250820102556/feet.mp4
|
||||
frontend/src/renderer/src/services/api.js
|
||||
frontend/src/renderer/src/services/api.js
|
||||
frontend/src/renderer/src/services/api.js
|
||||
frontend/src/renderer/src/services/api.js
|
||||
|
@ -109,7 +109,7 @@ class RecordingManager:
|
||||
self.current_session_id = session_id
|
||||
self.current_patient_id = patient_id
|
||||
self.recording_start_time = datetime.now()
|
||||
|
||||
data_base_path = os.path.join('data', 'patients', patient_id, session_id)
|
||||
# 创建存储目录
|
||||
if getattr(sys, 'frozen', False):
|
||||
# 打包后的exe文件路径
|
||||
@ -145,8 +145,8 @@ class RecordingManager:
|
||||
self.logger.error(f'更新会话状态为录制中失败 - 会话ID: {session_id}')
|
||||
|
||||
# 更新视频文件路径
|
||||
self.db_manager.update_session_normal_video_path(session_id, feet_video_path)
|
||||
self.db_manager.update_session_screen_video_path(session_id, screen_video_path)
|
||||
self.db_manager.update_session_normal_video_path(session_id, os.path.join(data_base_path, 'feet.mp4'))
|
||||
self.db_manager.update_session_screen_video_path(session_id, os.path.join(data_base_path, 'screen.mp4'))
|
||||
|
||||
self.logger.debug(f'数据库视频路径更新成功 - 会话ID: {session_id}')
|
||||
except Exception as db_error:
|
||||
@ -498,43 +498,7 @@ class RecordingManager:
|
||||
'screen_writer_active': self.screen_video_writer is not None and self.screen_video_writer.isOpened() if self.screen_video_writer else False
|
||||
}
|
||||
|
||||
def capture_images(self, session_id: str, patient_id: str, data_dir) -> Dict[str, str]:
|
||||
"""
|
||||
采集屏幕截图和足部视频截图
|
||||
|
||||
Args:
|
||||
session_id: 检测会话ID
|
||||
patient_id: 患者ID
|
||||
data_dir: 数据存储目录路径
|
||||
|
||||
Returns:
|
||||
Dict: 包含截图文件路径的字典
|
||||
"""
|
||||
result = {
|
||||
'screen_image': None,
|
||||
'foot_image': None
|
||||
}
|
||||
|
||||
try:
|
||||
# 1. 采集屏幕截图
|
||||
screen_image_path = self._capture_screen_image(data_dir)
|
||||
if screen_image_path:
|
||||
result['screen_image'] = str(screen_image_path)
|
||||
self.logger.debug(f'屏幕截图保存成功: {screen_image_path}')
|
||||
|
||||
# 2. 采集足部视频截图
|
||||
if self.camera_manager and self.camera_manager.is_connected:
|
||||
foot_image_path = self._capture_foot_image(data_dir)
|
||||
if foot_image_path:
|
||||
result['foot_image'] = str(foot_image_path)
|
||||
self.logger.debug(f'足部截图保存成功: {foot_image_path}')
|
||||
else:
|
||||
self.logger.warning('相机设备未连接,跳过足部截图')
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f'截图采集失败: {e}')
|
||||
|
||||
return result
|
||||
|
||||
def collect_detection_data(self, session_id: str, patient_id: str) -> Dict[str, Any]:
|
||||
"""
|
||||
@ -549,11 +513,11 @@ class RecordingManager:
|
||||
"""
|
||||
# 生成采集时间戳
|
||||
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S_%f')[:-3] # 精确到毫秒
|
||||
data_dir=""
|
||||
data_base_dir= Path(f'data/patients/{patient_id}/{session_id}/{timestamp}')
|
||||
if getattr(sys, 'frozen', False):
|
||||
# 打包后的exe文件路径
|
||||
exe_dir = os.path.dirname(sys.executable)
|
||||
data_dir=(os.path.join(exe_dir, 'data/patients/{patient_id}/{session_id}/{timestamp}'))
|
||||
data_dir = Path(os.path.join(exe_dir, 'data', 'patients', patient_id, session_id, timestamp))
|
||||
else:
|
||||
data_dir = Path(f'data/patients/{patient_id}/{session_id}/{timestamp}')
|
||||
# 创建数据存储目录
|
||||
@ -601,7 +565,7 @@ class RecordingManager:
|
||||
try:
|
||||
body_image_path = self._capture_body_image(data_dir)
|
||||
if body_image_path:
|
||||
data['body_image'] = str(body_image_path)
|
||||
data['body_image'] = str(os.path.join(data_base_dir,body_image_path))
|
||||
self.logger.debug(f'身体截图保存成功: {body_image_path}')
|
||||
except Exception as e:
|
||||
self.logger.error(f'采集身体截图异常: {e}')
|
||||
@ -617,20 +581,20 @@ class RecordingManager:
|
||||
if self.camera_manager and self.camera_manager.is_connected:
|
||||
foot_image_path = self._capture_foot_image(data_dir)
|
||||
if foot_image_path:
|
||||
data['foot_image'] = str(foot_image_path)
|
||||
data['foot_image'] = str(os.path.join(data_base_dir,foot_image_path))
|
||||
self.logger.debug(f'足部截图保存成功: {foot_image_path}')
|
||||
|
||||
# 6. 生成足底压力数据图(从压力传感器数据生成)
|
||||
if self.pressure_manager and hasattr(self.pressure_manager, 'is_connected') and self.pressure_manager.is_connected:
|
||||
foot_data_image_path = self._generate_foot_pressure_image(data_dir)
|
||||
if foot_data_image_path:
|
||||
data['foot_data_image'] = str(foot_data_image_path)
|
||||
self.logger.debug(f'足底压力数据图生成成功: {foot_data_image_path}')
|
||||
# # 6. 生成足底压力数据图(从压力传感器数据生成)
|
||||
# if self.pressure_manager and hasattr(self.pressure_manager, 'is_connected') and self.pressure_manager.is_connected:
|
||||
# foot_data_image_path = self._generate_foot_pressure_image(data_dir)
|
||||
# if foot_data_image_path:
|
||||
# data['foot_data_image'] = str(foot_data_image_path)
|
||||
# self.logger.debug(f'足底压力数据图生成成功: {foot_data_image_path}')
|
||||
|
||||
# 7. 采集屏幕截图
|
||||
screen_image_path = self._capture_screen_image(data_dir)
|
||||
if screen_image_path:
|
||||
data['screen_image'] = str(screen_image_path)
|
||||
data['screen_image'] = str(os.path.join(data_base_dir,screen_image_path))
|
||||
self.logger.debug(f'屏幕截图保存成功: {screen_image_path}')
|
||||
|
||||
self.logger.debug(f'数据采集完成: {session_id}, 时间戳: {timestamp}')
|
||||
@ -680,7 +644,7 @@ class RecordingManager:
|
||||
cv2.imwrite(str(file_path), frame)
|
||||
|
||||
# 返回相对路径
|
||||
return str(file_path.relative_to(Path.cwd()))
|
||||
return str(filename)
|
||||
else:
|
||||
self.logger.warning('FemtoBolt相机未获取到有效帧')
|
||||
return None
|
||||
@ -764,12 +728,12 @@ class RecordingManager:
|
||||
image_path = Path(data_dir) / 'screen_image.png'
|
||||
screenshot.save(str(image_path))
|
||||
|
||||
# 返回相对路径
|
||||
abs_image_path = image_path.resolve()
|
||||
abs_cwd = Path.cwd().resolve()
|
||||
relative_path = abs_image_path.relative_to(abs_cwd)
|
||||
# # 返回相对路径
|
||||
# abs_image_path = image_path.resolve()
|
||||
# abs_cwd = Path.cwd().resolve()
|
||||
# relative_path = abs_image_path.relative_to(abs_cwd)
|
||||
|
||||
return str(relative_path)
|
||||
return str('screen_image.png')
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f'屏幕截图失败: {e}')
|
||||
@ -806,11 +770,11 @@ class RecordingManager:
|
||||
cv2.imwrite(str(image_path), resized_frame)
|
||||
|
||||
# 返回相对路径
|
||||
abs_image_path = image_path.resolve()
|
||||
abs_cwd = Path.cwd().resolve()
|
||||
relative_path = abs_image_path.relative_to(abs_cwd)
|
||||
# abs_image_path = image_path.resolve()
|
||||
# abs_cwd = Path.cwd().resolve()
|
||||
# relative_path = abs_image_path.relative_to(abs_cwd)
|
||||
|
||||
return str(relative_path)
|
||||
return str(image_path)
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f'足部截图失败: {e}')
|
||||
|
Loading…
Reference in New Issue
Block a user