Search code examples
rowcoordinatespointsregionhalcon

Halcon - Find Row coordinate of 2 points with smallest and biggest Col coordinates


I have a Region that can have any shape. (sample below) I would need to find the ROW coordinates of the two points pointed with an arrow. (the most left and most right pixel coordinates of the region.) I've managed to get the Col coordinates with smallest_rectangle1, but cannot find a way to extract the Row coordinates of given points.

How can this be done?

enter image description here


Solution

  • here the code you can use

    * get the points of the region contour
    get_region_contour (Region, Rows, Columns)
    
    * sort the Columns
    tuple_sort_index ( Columns, Indices)
    
    * Left point
    LeftIndex := Indices[0]
    LeftRow := Rows[LeftIndex]
    LeftColumn :=  Columns[LeftIndex]
    
    * Right point
    RightIndex := Indices[|Indices|-1]
    RightRow := Rows[RightIndex]
    RightColumn :=  Columns[RightIndex]