pub struct StructureResult {
pub input_path: Arc<str>,
pub index: usize,
pub layout_elements: Vec<LayoutElement>,
pub tables: Vec<TableResult>,
pub formulas: Vec<FormulaResult>,
pub text_regions: Option<Vec<TextRegion>>,
pub orientation_angle: Option<f32>,
pub region_blocks: Option<Vec<RegionBlock>>,
pub rectified_img: Option<Arc<RgbImage>>,
}Expand description
Result of document structure analysis.
This struct contains all the results from analyzing a document’s structure, including layout elements, tables, formulas, and OCR results.
§Coordinate System
The coordinate system of bounding boxes depends on which preprocessing was applied:
-
No preprocessing: Boxes are in the original input image’s coordinate system.
-
Orientation correction only (
orientation_angleset,rectified_imgis None): Boxes are transformed back to the original input image’s coordinate system. -
Rectification applied (
rectified_imgis Some): Boxes remain in the rectified image’s coordinate system. Neural network-based rectification (UVDoc) warps cannot be precisely inverted, so userectified_imgfor visualization instead of the original image. -
Both orientation and rectification: Boxes are in the rectified coordinate system (rectification takes precedence since it’s applied after orientation correction).
Fields§
§input_path: Arc<str>Path to the input image file
index: usizeIndex of the image in a batch (0 for single image processing)
layout_elements: Vec<LayoutElement>Detected layout elements (text regions, tables, figures, etc.)
tables: Vec<TableResult>Recognized tables with their structure and content
formulas: Vec<FormulaResult>Recognized mathematical formulas
text_regions: Option<Vec<TextRegion>>OCR text regions (if OCR was integrated)
orientation_angle: Option<f32>Document orientation angle (if orientation correction was used)
region_blocks: Option<Vec<RegionBlock>>Detected region blocks for hierarchical ordering (PP-DocBlockLayout) When present, layout_elements are already sorted by region hierarchy
rectified_img: Option<Arc<RgbImage>>Rectified image (if document rectification was used) Note: Bounding boxes are already transformed back to original coordinates for rotation, but for rectification (UVDoc), boxes are in the rectified image’s coordinate system. Use this image for visualization when rectification was applied.
Implementations§
Source§impl StructureResult
impl StructureResult
Sourcepub fn new(input_path: impl Into<Arc<str>>, index: usize) -> Self
pub fn new(input_path: impl Into<Arc<str>>, index: usize) -> Self
Creates a new structure result.
Sourcepub fn with_layout_elements(self, elements: Vec<LayoutElement>) -> Self
pub fn with_layout_elements(self, elements: Vec<LayoutElement>) -> Self
Adds layout elements to the result.
Sourcepub fn with_tables(self, tables: Vec<TableResult>) -> Self
pub fn with_tables(self, tables: Vec<TableResult>) -> Self
Adds tables to the result.
Sourcepub fn with_formulas(self, formulas: Vec<FormulaResult>) -> Self
pub fn with_formulas(self, formulas: Vec<FormulaResult>) -> Self
Adds formulas to the result.
Sourcepub fn with_text_regions(self, regions: Vec<TextRegion>) -> Self
pub fn with_text_regions(self, regions: Vec<TextRegion>) -> Self
Adds OCR text regions to the result.
Sourcepub fn with_region_blocks(self, blocks: Vec<RegionBlock>) -> Self
pub fn with_region_blocks(self, blocks: Vec<RegionBlock>) -> Self
Adds region blocks to the result (PP-DocBlockLayout).
Region blocks represent hierarchical groupings of layout elements. When set, layout_elements should already be sorted by region hierarchy.
Sourcepub fn to_markdown(&self) -> String
pub fn to_markdown(&self) -> String
Converts the result to a Markdown string.
Follows PP-StructureV3’s formatting rules:
- DocTitle:
# title - ParagraphTitle: Auto-detect numbering (1.2.3 -> ###)
- Formula:
$$latex$$ - Table: HTML with border
- Images:

Note: Low-confidence text elements that overlap with table regions are filtered out to avoid duplicate content from table OCR.
Sourcepub fn to_html(&self) -> String
pub fn to_html(&self) -> String
Converts the result to an HTML string.
Follows PP-StructureV3’s formatting rules with semantic HTML tags.
Sourcepub fn to_json_value(&self) -> Result<Value>
pub fn to_json_value(&self) -> Result<Value>
Converts the result to a JSON Value.
Sourcepub fn save_results(
&self,
output_dir: impl AsRef<Path>,
to_json: bool,
to_markdown: bool,
to_html: bool,
) -> Result<()>
pub fn save_results( &self, output_dir: impl AsRef<Path>, to_json: bool, to_markdown: bool, to_html: bool, ) -> Result<()>
Saves the analysis results to the specified directory.
This generates:
*_res.json: The full structured result*_res.md: A Markdown representation*_res.html: An HTML representation
§Arguments
to_html- If true, save an HTML representation.
Trait Implementations§
Source§impl Clone for StructureResult
impl Clone for StructureResult
Source§fn clone(&self) -> StructureResult
fn clone(&self) -> StructureResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StructureResult
impl Debug for StructureResult
Source§impl<'de> Deserialize<'de> for StructureResult
impl<'de> Deserialize<'de> for StructureResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for StructureResult
impl RefUnwindSafe for StructureResult
impl Send for StructureResult
impl Sync for StructureResult
impl Unpin for StructureResult
impl UnwindSafe for StructureResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.