<?xml version="1.0" encoding="UTF-8"?>
<hdevelop file_version="1.1" halcon_version="13.0">
<procedure name="exhaustive_search_bb">
<interface>
<io>
<par name="RegionSeg" base_type="iconic" dimension="0"/>
</io>
<oo>
<par name="Rectangle" base_type="iconic" dimension="0"/>
</oo>
<ic>
<par name="initial_box_coordinate" base_type="ctrl" dimension="0"/>
<par name="Scale" base_type="ctrl" dimension="0"/>
<par name="Rotation" base_type="ctrl" dimension="0"/>
</ic>
<oc>
<par name="best_overlap" base_type="ctrl" dimension="0"/>
<par name="best_box_coordinate" base_type="ctrl" dimension="0"/>
</oc>
</interface>
<body>
<c> * Copyright (c) MVTec Software GmbH.  All rights reserved.</c>
<c> *</c>
<c> * All use of this software is subject to the terms of the revised BSD</c>
<c> * license.  You should have received a copy of this license along</c>
<c> * with this source code in a file named "license.txt."</c>
<c></c>
<c>* Note 1: Currently, this procedure works correctly only if \
          initial_box_candidate[4] == 0 (which is the use case of the procedure).</c>
<c>* Note 2: This procedure only works for Rotation == false.</c>
<l>get_system('clip_region', ClipRegion)</l>
<l>set_system('clip_region', 'false')</l>
<c></c>
<l>if (Scale == false and Rotation == false)</l>
<c>    *****************************************************</c>
<c>    * Exhaustive search:</c>
<c>    * (Guaranteed optima for the half-pixel precise grid)</c>
<c>    *****************************************************</c>
<l>    InitWidth := initial_box_coordinate[2]</l>
<l>    InitHeight := initial_box_coordinate[3]</l>
<l>    exhaustive_find_best_rectangle1_fixed_scale (RegionSeg, initial_box_coordinate, \
                                                 InitWidth, InitHeight, best_box_coordinate, best_overlap)</l>
<l>    gen_rectangle_b (Rectangle, best_box_coordinate)</l>
<l>elseif (Scale == true and Rotation == false)</l>
<c>    * compute upper bounds on the width and height of best rectangle1</c>
<l>    smallest_rectangle1 (RegionSeg, SRectRow1, SRectColumn1, SRectRow2, SRectColumn2)</l>
<l>    gen_rectangle1 (MaxROI, SRectRow1, SRectColumn1, SRectRow2, SRectColumn2)</l>
<l>    MaxWidth := SRectColumn2 - SRectColumn1 + 1</l>
<l>    MaxHeight := SRectRow2 - SRectRow1 + 1</l>
<c>    * compute lower bound on the area of best rectangle1</c>
<l>    inner_rectangle1 (RegionSeg, IRectRow1, IRectColumn1, IRectRow2, IRectColumn2)</l>
<l>    MinArea := (IRectColumn2-IRectColumn1+1)*(IRectRow2-IRectRow1+1)</l>
<l>    MinWidth := MinArea/MaxHeight</l>
<l>    MinHeight := MinArea/MaxWidth</l>
<c>    * loop over all possible Row1/Row2 combinations subject to \
      these restrictions</c>
<l>    best_overlap := 0.0</l>
<l>    best_row1 := 0</l>
<l>    best_column1 := 0</l>
<l>    best_row2 := 0</l>
<l>    best_column2 := 0</l>
<c>    </c>
<l>    exhaustive_find_best_rectangle1 (RegionSeg, SRectRow1, SRectRow2, MinHeight, SRectColumn1, SRectColumn2, \
                                     MinWidth, best_overlap, best_row1, best_column1, best_row2, best_column2)</l>
<c>   </c>
<l>    gen_rectangle1 (Rectangle, best_row1, best_column1, best_row2, best_column2)</l>
<l>    convert_rectangle1_params_to_box_coordinates (best_row1, best_column1, \
                                                  best_row2, best_column2, \
                                                  best_box_coordinate)</l>
<l>endif</l>
<l>set_system('clip_region', ClipRegion)</l>
<l>return ()</l>
</body>
<docu id="exhaustive_search_bb">
<parameters>
<parameter id="Rectangle"/>
<parameter id="RegionSeg"/>
<parameter id="Rotation"/>
<parameter id="Scale"/>
<parameter id="best_box_coordinate"/>
<parameter id="best_overlap"/>
<parameter id="initial_box_coordinate"/>
</parameters>
</docu>
</procedure>
</hdevelop>
