sort_regionsort_regionSortRegionSortRegionsort_region (算子)

名称

sort_regionsort_regionSortRegionSortRegionsort_region — 根据相对位置对区域进行排序。

签名

sort_region(Regions : SortedRegions : SortMode, Order, RowOrCol : )

Herror sort_region(const Hobject Regions, Hobject* SortedRegions, const char* SortMode, const char* Order, const char* RowOrCol)

Herror T_sort_region(const Hobject Regions, Hobject* SortedRegions, const Htuple SortMode, const Htuple Order, const Htuple RowOrCol)

void SortRegion(const HObject& Regions, HObject* SortedRegions, const HTuple& SortMode, const HTuple& Order, const HTuple& RowOrCol)

HRegion HRegion::SortRegion(const HTuple& SortMode, const HString& Order, const HString& RowOrCol) const

HRegion HRegion::SortRegion(const HTuple& SortMode, const char* Order, const char* RowOrCol) const

HRegion HRegion::SortRegion(const HTuple& SortMode, const wchar_t* Order, const wchar_t* RowOrCol) const   ( Windows only)

static void HOperatorSet.SortRegion(HObject regions, out HObject sortedRegions, HTuple sortMode, HTuple order, HTuple rowOrCol)

HRegion HRegion.SortRegion(HTuple sortMode, string order, string rowOrCol)

def sort_region(regions: HObject, sort_mode: MaybeSequence[Union[int, float, str]], order: str, row_or_col: str) -> HObject

描述

算子 sort_regionsort_regionSortRegionSortRegionSortRegionsort_region sorts the regions with respect to their relative position. All sorting methods with the exception of 'character'"character""character""character""character""character" use one point of the region. With the help of the parameter RowOrColRowOrColRowOrColRowOrColrowOrColrow_or_col = 'row'"row""row""row""row""row" these points will be sorted according to their row and then according to their column. By using 'column'"column""column""column""column""column", the column value will be used first. The following values are available for the parameter SortModeSortModeSortModeSortModesortModesort_mode:

'character'"character""character""character""character""character"

The regions are treated like characters, which can be read horizontally or vertically. They are sorted according to the reading direction given by RowOrColRowOrColRowOrColRowOrColrowOrColrow_or_col with the following specifications:

  • 'row'"row""row""row""row""row":Regarded as rows, the reading direction is firstly from left to right and then from top to bottom.

  • 'column'"column""column""column""column""column":Regarded as columns, the reading direction is firstly from top to bottom and then from left to right.

For SortModeSortModeSortModeSortModesortModesort_mode 'character'"character""character""character""character""character", a second numeric value can be passed to SortModeSortModeSortModeSortModesortModesort_mode in addition to 'character'"character""character""character""character""character". This value specifies the maximum percentage of overlap. This overlap depends on the parameter RowOrColRowOrColRowOrColRowOrColrowOrColrow_or_col and is determined as follows:

whereas the percentage of overlap is calculated using the smaller one of the overlapping regions (with respect to the specified axis). Regions that do not overlap in their coordinates or have an overlap of less than the set percentage are seen as being in different rows (or columns, respectively) and sorted accordingly. In case the overlap is larger, the regions are seen as being in the same row (or column) instead and therefore sorted within the row (or column). For example when this additional parameter is set to 0, all regions that overlap in their row (or column) coordinates are sorted within the same row (or column). The default value of this parameter is 15 which means that adjacent rows (or columns) can have an overlap of maximum 15% in order to be considered as different rows (or columns). Note that for OrderOrderOrderOrderorderorder = 'false'"false""false""false""false""false", the characters are sorted in a reversed order to the one described above.

'first_point'"first_point""first_point""first_point""first_point""first_point"

The point with the lowest column value in the first row of the region.

'last_point'"last_point""last_point""last_point""last_point""last_point"

The point with the highest column value in the last row of the region.

'upper_left'"upper_left""upper_left""upper_left""upper_left""upper_left"

Upper left corner of the surrounding rectangle.

'upper_right'"upper_right""upper_right""upper_right""upper_right""upper_right"

Upper right corner of the surrounding rectangle.

'lower_left'"lower_left""lower_left""lower_left""lower_left""lower_left"

Lower left corner of the surrounding rectangle.

'lower_right'"lower_right""lower_right""lower_right""lower_right""lower_right"

Lower right corner of the surrounding rectangle.

The parameter OrderOrderOrderOrderorderorder determines whether the sorting order is increasing or decreasing: using 'true'"true""true""true""true""true" the order will be increasing, using 'false'"false""false""false""false""false" the order will be decreasing.

执行信息

参数

RegionsRegionsRegionsRegionsregionsregions (输入对象)  region-array objectHRegionHObjectHRegionHobject

Regions to be sorted.

SortedRegionsSortedRegionsSortedRegionsSortedRegionssortedRegionssorted_regions (输出对象)  region-array objectHRegionHObjectHRegionHobject *

Sorted regions.

SortModeSortModeSortModeSortModesortModesort_mode (输入控制)  tuple(-array) HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)

Kind of sorting.

默认值: 'first_point' "first_point" "first_point" "first_point" "first_point" "first_point"

值列表: 'character'"character""character""character""character""character", 'first_point'"first_point""first_point""first_point""first_point""first_point", 'last_point'"last_point""last_point""last_point""last_point""last_point", 'lower_left'"lower_left""lower_left""lower_left""lower_left""lower_left", 'lower_right'"lower_right""lower_right""lower_right""lower_right""lower_right", 'upper_left'"upper_left""upper_left""upper_left""upper_left""upper_left", 'upper_right'"upper_right""upper_right""upper_right""upper_right""upper_right"

OrderOrderOrderOrderorderorder (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Increasing or decreasing sorting order.

默认值: 'true' "true" "true" "true" "true" "true"

值列表: 'false'"false""false""false""false""false", 'true'"true""true""true""true""true"

RowOrColRowOrColRowOrColRowOrColrowOrColrow_or_col (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Sorting first with respect to row, then to column.

默认值: 'row' "row" "row" "row" "row" "row"

值列表: 'column'"column""column""column""column""column", 'row'"row""row""row""row""row"

结果

如果参数正确,算子 sort_regionsort_regionSortRegionSortRegionSortRegionsort_region 返回值 2 ( H_MSG_TRUE )。否则将抛出异常。

可能的后继

do_ocr_multi_class_mlpdo_ocr_multi_class_mlpDoOcrMultiClassMlpDoOcrMultiClassMlpDoOcrMultiClassMlpdo_ocr_multi_class_mlp, do_ocr_single_class_mlpdo_ocr_single_class_mlpDoOcrSingleClassMlpDoOcrSingleClassMlpDoOcrSingleClassMlpdo_ocr_single_class_mlp

模块

基础