Search code examples
lineintersectionregionhalcon

Halcon - get lowest pixel of a region along a line


I have a random region, and would need the coordinates in the world plane of the intersection between the region and the center of the image, with the highest y coordinate.

this is what I have so far:

fill_up(SelectedRegions, RegionFillUp)
get_image_size(Image, w,h)
gen_region_line(RegionLine,0,w/2,h,w/2)
disp_line (3600, 0, w/2, h, w/2)
intersection (RegionFillUp, RegionLine, RegionIntersection)

enter image description here

*EDIT

I've made some progress and have now all the intersections. But cannot figure out how to get the last entry of the array if the array is bigger than one...

gen_contour_region_xld (RegionFillUp, Contours, 'border')
get_image_size(Image, w,h)
gen_contour_polygon_xld (Line1,[0,h],[w/2,w/2])
intersection_line_contour_xld(Contours,0,w/2,h,w/2,rowcoords, columncoords, isOverlapping)

Solution

  • Solved it this way:

    fill_up(SelectedRegions, RegionFillUp)
    gen_contour_region_xld (RegionFillUp, Contours, 'border')
    get_image_size(Image, w,h)
    intersection_line_contour_xld(Contours,0,w/2,h,w/2,rowcoords, columncoords, isOverlapping)
    disp_cross (3600, rowcoords, columncoords, 6, 0)
    tuple_length (rowcoords,Length)
    Position := 0
    if (Length > 0) 
        Position := rowcoords[Length-1]
    endif
    
    image_points_to_world_plane (CamParam, Pose, Position, w/2, 1, X1, Y1)