金属圆柱求取倾斜角度
生活随笔
收集整理的這篇文章主要介紹了
金属圆柱求取倾斜角度
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
方法1:
count_seconds (Seconds1)read_image (Image, '9_7750_f3d301de6764d94.jpg')get_image_size (Image, Width, Height)dev_open_window (0, 0, Width, Height, 'black', WindowHandle)dev_display (Image)rgb1_to_gray (Image, GrayImage)dev_display (GrayImage) threshold (GrayImage, Region, 75, 100)closing_circle (Region, RegionClosing, 5)gen_contour_region_xld (RegionClosing, Contours, 'border')segment_contours_xld (Contours, ContoursSplit, 'lines', 50, 10, 10) *擬合水平線select_contours_xld (ContoursSplit, SelectedContours0, 'direction', rad(-5), rad(5), rad(-0.5), rad(0.5))select_shape_xld (SelectedContours0, Stamps, 'row', 'and', 20, 35)length_xld (Stamps, Length0)tuple_max (Length0, Max0)gen_empty_obj (EmptyObject0)count_obj (SelectedContours0, Number0)for i := 1 to Number0 by 1select_obj (SelectedContours0, ObjectSelected, i)length_xld (ObjectSelected, Length0)if (Length0=Max0)concat_obj (EmptyObject0, ObjectSelected, EmptyObject0)endifendfor*擬合垂直線select_contours_xld (ContoursSplit, SelectedContours1, 'direction', rad(85), rad(95),rad(-0.5), rad(0.5)) length_xld (SelectedContours1, Length1)tuple_max (Length1, Max1)gen_empty_obj (EmptyObject1)count_obj (SelectedContours1, Number1) for j := 1 to Number1 by 1select_obj (SelectedContours1, ObjectSelected, j)length_xld (ObjectSelected, Length1)if (Length1=Max1)concat_obj (EmptyObject1, ObjectSelected, EmptyObject1)endifendfor fit_line_contour_xld (EmptyObject0, 'tukey', -1, 0, 5, 2, RowBegin0, ColBegin0, RowEnd0, ColEnd0, Nr0, Nc0, Dist0)gen_region_line(RegionLine0, RowBegin0, ColBegin0, RowEnd0, ColEnd0)fit_line_contour_xld (EmptyObject1, 'tukey', -1, 0, 5, 2, RowBegin1, ColBegin1, RowEnd1, ColEnd1, Nr1, Nc1, Dist1)gen_region_line(RegionLine1, RowBegin1, ColBegin1, RowEnd1, ColEnd1)*求交點(diǎn)intersection_lines (RowBegin1, ColBegin1, RowEnd1, ColEnd1, RowBegin0, ColBegin0, RowEnd0, ColEnd0, Row, Column, IsOverlapping) dev_clear_window()dev_display (Image)dev_set_color ('magenta')dev_set_line_width (2)distance_pp(Row,Column,RowEnd0, ColEnd0, DistanceEnd)distance_pp(Row,Column,RowBegin0, ColBegin0, DistanceBegin)if (DistanceBegin > DistanceEnd)disp_line(WindowHandle,RowBegin0, ColBegin0,Row, Column)elsedisp_line(WindowHandle,RowEnd0, ColEnd0,Row, Column)endifdistance_pp(Row,Column,RowEnd1, ColEnd1, DistanceEnd)distance_pp(Row,Column,RowBegin1, ColBegin1, DistanceBegin)if (DistanceBegin > DistanceEnd)disp_line(WindowHandle,RowBegin1, ColBegin1,Row, Column)elsedisp_line(WindowHandle,RowEnd1, ColEnd1,Row, Column)endif*計(jì)算角度dev_set_color ('green')gen_region_points(Region,Row, Column)gen_cross_contour_xld (Cross, Row, Column, 20, rad(45))dev_display(Cross)angle_ll (RowBegin1, ColBegin1, RowEnd1, ColEnd1, RowBegin0, ColBegin0, RowEnd0, ColEnd0, Angle)AngleDeg := deg(Angle)count_seconds (Seconds2)disp_message (WindowHandle, 'CT : ' + ((Seconds2-Seconds1)*1000)+' mSec', 'image', 10 , 10, 'slate blue', 'true') disp_message (WindowHandle, 'AngleDeg : ' + AngleDeg+' 度', 'image', 60 , 10, 'slate blue', 'true') stop()
方法2:
總結(jié)
以上是生活随笔為你收集整理的金属圆柱求取倾斜角度的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle数据库查看用户相关语句
- 下一篇: 还不会财务管理分析?Python爬取全网