|
@@ -383,7 +383,7 @@ class OCRLayoutManager:
|
|
|
# st.header("🖼️ 原图标注")
|
|
# st.header("🖼️ 原图标注")
|
|
|
|
|
|
|
|
# 图片控制选项
|
|
# 图片控制选项
|
|
|
- col1, col2, col3, col4 = st.columns(4, vertical_alignment="center", border= False)
|
|
|
|
|
|
|
+ col1, col2, col3, col4, col5 = st.columns(5, vertical_alignment="center", border= False)
|
|
|
|
|
|
|
|
with col1:
|
|
with col1:
|
|
|
# 判断{layout_type}_show_all_boxes是否有值,如果有值直接使用,否则默认False
|
|
# 判断{layout_type}_show_all_boxes是否有值,如果有值直接使用,否则默认False
|
|
@@ -410,6 +410,11 @@ class OCRLayoutManager:
|
|
|
st.rerun()
|
|
st.rerun()
|
|
|
|
|
|
|
|
with col3:
|
|
with col3:
|
|
|
|
|
+ # 显示当前角度状态
|
|
|
|
|
+ current_angle = self.get_rotation_angle()
|
|
|
|
|
+ st.metric("当前角度", f"{current_angle}°", label_visibility="collapsed")
|
|
|
|
|
+
|
|
|
|
|
+ with col4:
|
|
|
if st.button("↺ 重置角度", key=f"{layout_type}_reset_angle"):
|
|
if st.button("↺ 重置角度", key=f"{layout_type}_reset_angle"):
|
|
|
self.rotated_angle = 0.0
|
|
self.rotated_angle = 0.0
|
|
|
st.success("已重置旋转角度")
|
|
st.success("已重置旋转角度")
|
|
@@ -418,10 +423,10 @@ class OCRLayoutManager:
|
|
|
self.validator.process_data()
|
|
self.validator.process_data()
|
|
|
st.rerun()
|
|
st.rerun()
|
|
|
|
|
|
|
|
- with col4:
|
|
|
|
|
- # 显示当前角度状态
|
|
|
|
|
- current_angle = self.get_rotation_angle()
|
|
|
|
|
- st.metric("当前角度", f"{current_angle}°", label_visibility="collapsed")
|
|
|
|
|
|
|
+ with col5:
|
|
|
|
|
+ if st.button("🧹 清除选择"):
|
|
|
|
|
+ st.session_state.selected_text = None
|
|
|
|
|
+ st.rerun()
|
|
|
|
|
|
|
|
# 使用增强的图像加载方法
|
|
# 使用增强的图像加载方法
|
|
|
image = self.load_and_rotate_image(self.validator.image_path)
|
|
image = self.load_and_rotate_image(self.validator.image_path)
|
|
@@ -454,67 +459,6 @@ class OCRLayoutManager:
|
|
|
config=plot_config,
|
|
config=plot_config,
|
|
|
key=f"{layout_type}_plot"
|
|
key=f"{layout_type}_plot"
|
|
|
)
|
|
)
|
|
|
- # st.markdown('</div>', unsafe_allow_html=True)
|
|
|
|
|
-
|
|
|
|
|
- # # 显示选中文本的详细信息
|
|
|
|
|
- # if st.session_state.selected_text and st.session_state.selected_text in self.validator.text_bbox_mapping:
|
|
|
|
|
- # st.subheader("📍 选中文本详情")
|
|
|
|
|
-
|
|
|
|
|
- # info = self.validator.text_bbox_mapping[st.session_state.selected_text][0]
|
|
|
|
|
- # bbox = info['bbox']
|
|
|
|
|
-
|
|
|
|
|
- # info_col1, info_col2 = st.columns(2)
|
|
|
|
|
- # with info_col1:
|
|
|
|
|
- # st.write(f"**文本内容:** {st.session_state.selected_text[:30]}...")
|
|
|
|
|
- # st.write(f"**类别:** {info['category']}")
|
|
|
|
|
- # # 显示旋转信息
|
|
|
|
|
- # rotation_angle = self.get_rotation_angle()
|
|
|
|
|
- # if rotation_angle != 0:
|
|
|
|
|
- # st.write(f"**旋转角度:** {rotation_angle}°")
|
|
|
|
|
-
|
|
|
|
|
- # with info_col2:
|
|
|
|
|
- # st.write(f"**位置:** [{', '.join(map(str, bbox))}]")
|
|
|
|
|
- # if len(bbox) >= 4:
|
|
|
|
|
- # st.write(f"**大小:** {bbox[2] - bbox[0]} x {bbox[3] - bbox[1]} px")
|
|
|
|
|
-
|
|
|
|
|
- # # 错误标记功能
|
|
|
|
|
- # col1, col2 = st.columns(2)
|
|
|
|
|
- # with col1:
|
|
|
|
|
- # if st.button("❌ 标记为错误", key=f"{layout_type}_mark_error"):
|
|
|
|
|
- # st.session_state.marked_errors.add(st.session_state.selected_text)
|
|
|
|
|
- # st.rerun()
|
|
|
|
|
-
|
|
|
|
|
- # with col2:
|
|
|
|
|
- # if st.button("✅ 取消错误标记", key=f"{layout_type}_unmark_error"):
|
|
|
|
|
- # st.session_state.marked_errors.discard(st.session_state.selected_text)
|
|
|
|
|
- # st.rerun()
|
|
|
|
|
-
|
|
|
|
|
- # # 增强的调试信息
|
|
|
|
|
- # with st.expander("🔍 图像和坐标调试信息", expanded=False):
|
|
|
|
|
- # rotation_angle = self.get_rotation_angle()
|
|
|
|
|
- # rotation_config = get_ocr_tool_rotation_config(self.validator.ocr_data, self.config)
|
|
|
|
|
-
|
|
|
|
|
- # col_debug1, col_debug2, col_debug3 = st.columns(3)
|
|
|
|
|
- # with col_debug1:
|
|
|
|
|
- # st.write("**图像信息:**")
|
|
|
|
|
- # st.write(f"原始尺寸: {image.width} x {image.height}")
|
|
|
|
|
- # st.write(f"缩放后尺寸: {resized_image.width} x {resized_image.height}")
|
|
|
|
|
- # st.write(f"当前角度: {rotation_angle}°")
|
|
|
|
|
-
|
|
|
|
|
- # with col_debug2:
|
|
|
|
|
- # st.write("**坐标信息:**")
|
|
|
|
|
- # if selected_bbox:
|
|
|
|
|
- # st.write(f"选中框: {selected_bbox}")
|
|
|
|
|
- # st.write(f"总框数: {len(all_boxes)}")
|
|
|
|
|
- # st.write(f"文本框数: {len(self.validator.text_bbox_mapping)}")
|
|
|
|
|
-
|
|
|
|
|
- # with col_debug3:
|
|
|
|
|
- # st.write("**配置信息:**")
|
|
|
|
|
- # st.write(f"工具类型: {rotation_config.get('coordinates_are_pre_rotated', 'unknown')}")
|
|
|
|
|
- # st.write(f"缓存状态: {len(self._rotated_image_cache)} 项")
|
|
|
|
|
- # if hasattr(self, 'rotated_angle'):
|
|
|
|
|
- # st.write(f"自动检测角度: {self.rotated_angle}°")
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
st.error(f"❌ 图片处理失败: {e}")
|
|
st.error(f"❌ 图片处理失败: {e}")
|