English 中文(简体)
如何将一个区域纳入另一个区域?
原标题:How to fit a region into another region?
  • 时间:2024-07-24 15:23:46
  •  标签:
  • halcon
I m new to Halcon and I can t figure out a way to match the scaling, rotation, and translation of one region to that of another region. Currently, I m trying to find a way to get a HHomMat2D corresponding to the reference region, so that I can use the affine_trans_region function, but can t find the way to do it.
问题回答
You can try this step by step, it handles everything from extracting contours to displaying the aligned regions. // Extract contours from both the source and reference regions get_region_contour(RegionSource, RowSource, ColumnSource); get_region_contour(RegionReference, RowReference, ColumnReference); // Create a shape model from the reference region s contour gen_contour_polygon_xld(ContourReference, RowReference, ColumnReference); create_shape_model_xld(ContourReference, auto , rad(-360), rad(360), auto , auto , ignore_global_polarity , 5, auto , ShapeModelID); // Match the model to the source region to find necessary transformations find_shape_model(ContourSource, ShapeModelID, rad(-360), rad(360), 0.5, 1, 0.5, least_squares , 0, 0.9, RowCheck, ColumnCheck, Angle, Scale, Score); // Generate a transformation matrix using the match results vector_angle_to_rigid(RowReference, ColumnReference, 0, RowCheck, ColumnCheck, Angle, HomMat2D); // Apply the transformation to fit the source region into the reference region affine_trans_region(RegionSource, RegionTrans, HomMat2D, nearest_neighbor ); // Display both regions for visual verification of alignment disp_obj(RegionReference, WindowHandle); set_colored(WindowHandle, 12); disp_obj(RegionTrans, WindowHandle);




相关问题
如何将一个区域纳入另一个区域?

我新来Halcon,我无法想出一个方法来将一个区域的缩放、轮换和翻译与另一个区域的缩放、轮换和翻译相匹配。目前,我正在设法找到一个HomMat2D...

热门标签