0

I have following code:

image_points_to_world_plane (CamParam, Pose, intersection_points_row, intersection_points_col, 'mm', X1, Y1)
distance_pp (X1[2], Y1[2], X1[3], Y1[3], Measure1)

this code retunrs the values in mm.

now the code goes on as shown below, and I would need the area of the Regions1 in mm². Instead i get them in pixel..

access_channel(Image, ImageMono, 1)

threshold(ImageMono, Region, 0, 100)
fill_up(Region, RegionFillUp)

reduce_domain(ImageMono, RegionFillUp, ImageReduced)

threshold (ImageReduced, Regions1, 230, 255)
connection (Regions1, Connection)
select_shape(Connection, Labels, 'area', 'and', 2000, 99999)
area_center(Labels, AreaLabels, RowLabels, ColumnLabels)

AreaLabels is in px² and i would need it in mm². but couldnt find anything like region_to_world_plane... how can this be done?

sharkyenergy
  • 3,842
  • 10
  • 46
  • 97

1 Answers1

1

Try looking at the operator "image_to_world_plane". It will transform the image so that the pixel size is in metric units (or whatever you prefer). It will also warp the image so that it looks as if the picture was taken directly from overhead. Then any area calculations you perform on this transformed image will be in the units you specified (mm, m, etc).

Jake Chittle
  • 316
  • 1
  • 2
  • 4
  • thank you Jake, I already tried that and it worked, but was wondering if it could be done without warping the image.. I'm still trying and learning, so exploring different paths to solve problems.. thank you! – sharkyenergy May 22 '20 at 05:13
  • 1
    Hey I'm not sure the best way to do it but "image_to_world_plane" seems easiest to me. Due to the perspective of the images you showed us, each pixel in the area would be a different size (ie farther pixels = smaller area). The reason that "image_to_world_plane" warps the image is so that each pixel would now be sized identically. If you had your camera directly over top instead of on an angle, you could convert px^2 to mm^2 directly and get a good approximation. But that is only if your camera was mounted directly over top of the part. – Jake Chittle May 22 '20 at 09:40
  • thanks I am trying it with that system now and am on a good point.. having few problems that I posted on a new question.. Thank you very much! – sharkyenergy May 22 '20 at 09:42
  • 1
    You could also technically try "projective_transform_region". This will take your region and warp it. You would need to calculate the transformation matrix for it. Again this transform would have to be calculated as if your camera was directly over top of your part. Then you could convert units directly from px^2 to mm^2 etc. – Jake Chittle May 22 '20 at 10:07
  • than you! do you have the time to have a look at this question as it is closely related to your answer? https://stackoverflow.com/questions/61951550/halcon-image-to-world-plane-of-partial-image – sharkyenergy May 22 '20 at 10:28