3d_coordinates 测量世界坐标中的倾斜物体

  • 测量世界坐标中的倾斜物体
  • Initialize the program
    dev_close_window ()
    dev_open_window (0, 0, 768, 576, ‘black’, WindowHandle)
    dev_update_off ()
    dev_set_draw (‘margin’)
    dev_set_line_width (3)
    set_display_font (WindowHandle, 14, ‘mono’, ‘true’, ‘false’)

    • Calibrate the camera

  • CalTabDescrFile := ‘caltab_big.descr’
    StartCamPar := [0.008,0,0.0000086,0.0000086,384,288,768,576]
    create_calib_data (‘calibration_object’, 1, 1, CalibDataID)
    set_calib_data_cam_param (CalibDataID, 0, ‘area_scan_division’, StartCamPar)
    set_calib_data_calib_object (CalibDataID, 0, CalTabDescrFile)
    NumImages := 10
    for I := 1 to NumImages by 1
    read_image (Image, ‘calib/calib-3d-coord-’ + I$’02d’)
    dev_display (Image)
    Message := ‘Find calibration plate in\nall calibration images (’ + I + ‘/’ + NumImages + ‘)’
    disp_message (WindowHandle, Message, ‘window’, 12, 12, ‘black’, ‘true’)
    • Find the calibration plate
      find_calib_object (Image, CalibDataID, 0, 0, I - 1, [], [])
      get_calib_data (CalibDataID, ‘camera’, 0, ‘init_params’, StartCamPar)
      get_calib_data_observ_points (CalibDataID, 0, 0, I - 1, Row, Column, Index, Pose)
      get_calib_data_observ_contours (Contours, CalibDataID, ‘caltab’, 0, 0, I - 1)
      gen_cross_contour_xld (Cross, Row, Column, 6, 0.785398)
      dev_set_color (‘green’)
      dev_display (Contours)
      dev_set_color (‘yellow’)
      dev_display (Cross)
      endfor
      disp_continue_message (WindowHandle, ‘black’, ‘true’)
      stop ()
      calibrate_cameras (CalibDataID, Error)
      get_calib_data (CalibDataID, ‘camera’, 0, ‘params’, CamParam)
  • 此时得到了Pose和CamParam
  • Perform measurements

  • for I := 1 to NumImages by 1
    read_image (Image, ‘calib/calib-3d-coord-’ + I$’02d’)
    • 现在找到标定板的黑色边缘
    • Now, measure the size of the black border of the plate
      get_measure_positions (Image, PlateRegion, CalibDataID, I, Distance, Phi, RowCenter, ColumnCenter)
      *用矩形的形状创建一个XLD轮廓,依次为矩形的XLD轮廓,中心的行坐标,矩形的中心坐标,矩形的主轴的方向
      gen_rectangle2_contour_xld (Rectangle, RowCenter, ColumnCenter, Phi, Distance * 0.52, 8)
      gen_measure_rectangle2 (RowCenter, ColumnCenter, Phi, Distance * 0.52, 8, 768, 576, ‘nearest_neighbor’, MeasureHandle)
    • 提取垂直于矩形或环形弧的直边共18个点
      measure_pos (Image, MeasureHandle, 1, 40, ‘all’, ‘all’, RowEdge, ColumnEdge, Amplitude, Distance1)
      close_measure (MeasureHandle)
      Rows := [RowEdge[0],RowEdge[|RowEdge| - 1]]
      Columns := [ColumnEdge[0],ColumnEdge[|RowEdge| - 1]]
      gen_cross_contour_xld (Cross, Rows, Columns, 16, Phi)
    • 将两个边界点转换为世界坐标系
    • Transform the two border points into the world coordinate system
      get_calib_data (CalibDataID, ‘calib_obj_pose’, [0,I - 1], ‘pose’, Pose)
      *将图像点转换为z=0的世界坐标系
      image_points_to_world_plane (CamParam, Pose, Rows, Columns, ‘m’, SX, SY)
      distance_pp (SY[0], SX[0], SY[1], SX[1], Width)

      • Display results of width measurement
        dev_display (Image)
        dev_set_color (‘white’)
        dev_set_line_width (3)
        dev_display (Rectangle)
        dev_set_color (‘green’)
        dev_set_draw (‘fill’)
        dev_set_line_width (2)
        dev_display (Cross)
        dev_set_draw (‘margin’)
        disp_message (WindowHandle, ‘Width = ’ + (Width * 100)$’8.3f’ + ‘cm’, ‘window’, 12, 12, ‘black’, ‘true’)
        disp_continue_message (WindowHandle, ‘black’, ‘true’)
        stop ()
    • 现在,测量校准标记点的尺寸
    • Now, measure the size of the calibration marks
    • 提取图像中的圆
    • Extract the ellipses in the image用环状结构元素侵蚀一个区域
      erosion_circle (PlateRegion, ROI, 17.5)
      reduce_domain (Image, ROI, ImageReduced)
      edges_sub_pix (ImageReduced, Edges, ‘canny’, 1, 20, 60)
      select_contours_xld (Edges, SelectedEdges, ‘contour_length’, 20, 99999999, -0.5, 0.5)
    • Fit ellipses to extracted edges,拟合圆
      fit_ellipse_contour_xld (SelectedEdges, ‘fitzgibbon’, -1, 2, 0, 200, 3, 2, Row, Column, Phi, Radius1, Radius2, StartPhi, EndPhi, PointOrder)
      *取均值
      MeanRadius1 := mean(Radius1)
      MeanRadius2 := mean(Radius2)
      DevRadius1 := deviation(Radius1)
      DevRadius2 := deviation(Radius2)
    • Transform the ellipses to world coordinates, where they should be circles
      *吧圆转换到世界坐标
    • and convert the circles from meters to millimeters so that we can see them.
      contour_to_world_plane_xld (SelectedEdges, WorldCircles, CamParam, Pose, ‘mm’)
    • Fit ellipses to the circles in world coordinates
      fit_ellipse_contour_xld (WorldCircles, ‘fitzgibbon’, -1, 2, 0, 200, 3, 2, Row, Column, Phi, RadiusW1, RadiusW2, StartPhi, EndPhi, PointOrder)
      MeanRadiusW1 := mean(RadiusW1)
      MeanRadiusW2 := mean(RadiusW2)
      DevRadiusW1 := deviation(RadiusW1)
      DevRadiusW2 := deviation(RadiusW2)

      • Display results of ellipse measurement
        dev_display (Image)
        dev_set_color (‘yellow’)
        dev_set_line_width (3)
        dev_display (SelectedEdges)
        Message := ‘Measured dimensions of the ellipses’
        Message[0] := ’ Mean Radius1; Mean Radius2; (Standard deviations [%])’
        Message[1] := ‘Image coordinates: ’ + MeanRadius1 5.2f+px;+MeanRadius2 ’5.2f’ + ‘px (’ + (DevRadius1 / MeanRadius1 * 100) 4.2f+,+(DevRadius2/MeanRadius2100) ’4.2f’ + ‘)’
        Message[2] := ‘World coordinates: ’ + (MeanRadiusW1 / 10) 5.2f+cm;+(MeanRadiusW2/10) ’5.2f’ + ‘cm (’ + (DevRadiusW1 / MeanRadiusW1 * 100) 4.2f+,+(DevRadiusW2/MeanRadiusW2100) ’4.2f’ + ‘)’
        disp_message (WindowHandle, Message, ‘window’, 12, 12, ‘black’, ‘true’)
        if (I < 10)
        disp_continue_message (WindowHandle, ‘black’, ‘true’)
        stop ()
        endif
        endfor
        clear_calib_data (CalibDataID)
免费分享大家 [44.38652343750002,10.430224609374989],[44.94296875,10.43671875],[45.81669921875002,10.835888671874997],[46.565039062500006,10.745996093749994],[47.40498046875001,11.174023437499997],[48.01923828125001,11.139355468749997],[48.57255859375002,11.320507812499997],[48.938574218750006,11.258447265624994],[50.11005859375001,11.529296875],[50.79228515625002,11.983691406249989],[51.2548828125,11.830712890624994],[51.08427734375002,11.335644531249997],[51.140625,10.656884765624994],[51.031835937500006,10.444775390624997],[51.19296875,10.554638671874997],[51.390234375,10.422607421875],[50.93007812500002,10.33554687499999],[50.825,9.428173828124997],[50.10283203125002,8.199804687499991],[49.85205078125,7.962548828124994],[49.234960937500006,6.77734375],[49.04931640625,6.173632812499989],[47.97529296875001,4.497021484374997],[46.87880859375002,3.28564453125],[46.05117187500002,2.475146484374989],[44.92021484375002,1.81015625],[43.71757812500002,0.857861328124997],[41.97988281250002,-0.973046875],[41.53271484375,-1.6953125],[41.521875,-1.572265625],[41.42695312500001,-1.449511718750003],[41.24980468750002,-1.220507812500003],[40.97871093750001,-0.870312500000011],[40.964453125,2.814648437499997],[41.341796875,3.20166015625],[41.61347656250001,3.590478515624994],[41.88398437500001,3.977734375],[41.91533203125002,4.031298828124989],[42.02412109375001,4.137939453125],[42.85664062500001,4.32421875],[43.12568359375001,4.644482421874997],[43.58349609375,4.85498046875],[43.988867187500006,4.950537109374991],[44.940527343750006,4.912011718749994],[47.97822265625001,7.9970703125]]]},"properties":{"name":"索马里","childNum":1}},{"geometry":{"type":"Polygon","coordinates":[[[9.579979133936737,47.05856388629306],[9.409458596647225,47.02019676540292],[9.46249431093294,47.09010747968864],[9.46249431093294,47.19858962254578],[9.527658197470123,47.27026989773668],[9.579979133936737,47.05856388629306]]]},"properties":{"name":"列支敦斯登","childNum":1}},{"geometry":{"type":"Polygon","coordinates":[[[-8.683349609375,27.77800740805682],[-13.038761787013554,27.81190166624856],[-12.948925781249926,27.914160156250034],[-11.552685546874955,28.31010742187496],[-10.486474609374994,29.06494140625],[-10.200585937499994,29.380371093750057],[-9.667089843749949,30.10927734375005],[-9.652929687499977,30.447558593750045],[-9.875488281249943,30.717919921874966],[-9.80869140624992,31.42460937499996],[-9.347460937499932,32.086376953124955],[-9.245849609375,32.572460937499955],[-8.512841796874994,33.25244140625003],[-6.900976562499949,33.96904296874999],[-6.353125,34.77607421875001],[-5.924804687499943,35.78579101562502],[-5.277832031249943,35.90273437500002],[-5.252685546874972,35.61474609374997],[-4.628320312499966,35.206396484375006],[-4.329980468749937,35.161474609375006],[-3.693261718749994,35.27998046874998],[-3.394726562499926,35.21181640625005],[-2.972216796874989,35.40727539062499],[-2.839941406249949,35.127832031249994],[-2.731396484374955,35.13520507812498],[-2.636816406249977,35.11269531250002],[-2.423730468749994,35.12348632812498],[-2.219628906249966,35.10419921874998],[-1.795605468749926,34.751904296874955],[-1.67919921875,33.31865234375002],[-1.550732421874955,33.073583984375006],[-1.510009765625,32.877636718749955],[-1.45,32.784814453124966],[-1.352148437499977,32.70336914062497],[-1.29638671875,32.67568359375002],[-1.188232421875,32.608496093750006],[-1.111035156249983,32.55229492187502],[-1.065527343749949,32.46831054687496],[-1.16259765625,32.399169921875],[-1.275341796874983,32.089013671874966],[-2.863427734374937,32.07470703124997],[-2.930859374999926,32.04252929687499],[-2.988232421874983,31.874218749999983],[-3.01738281249996,31.834277343750017],[-3.439794921874949,31.704541015624983],[-3.604589843749949,31.686767578125],[-3.700244140624989,31.70009765625005],[-3.768164062499977,31.689550781250034],[-3.837109374999983,31.512353515624994],[-3.833398437499937,31.197802734375045],[-3.626904296874955,31.000927734374983],[-4.148779296874977,30.8095703125],[-4.322851562500006,30.698876953124994],[-4.52915039062492,30.62553710937499],[-4.778515624999926,30.552392578124994],[-4.968261718749943,30.465380859375045],[-5.061914062499937,30.326416015625057],[-5.180126953124955,30.166162109374994],[-5.293652343749983,30.058642578125045],[-5.44877929687496,29.956933593750023],[-6.00429687499999,29.83125],[-6.479736328124943,29.82036132812499],[-6.520556640624989,29.659863281249983],[-6.59775390624992,29.578955078125006],[-6.635351562499949,29.568798828124983],[-6.755126953125,29.583837890625034],[-6.855566406249949,29.601611328125017],[-7.142431640624949,29.61958007812504],[-7.427685546874983,29.425],[-7.485742187499994,29.392236328124994],[-8.659912109375,28.718603515625063],[-8.683349609375,27.900390625],[-8.683349609375,27.77800740805682]]]},"properties":{"name":"摩洛哥","childNum":1}},{"geometry":{"type":"Polygon","coordinates":[[[-13.038761787013554,27.81190166624856],[-8.683349609375,27.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值