金屬圓柱求取傾斜角度

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

方法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)*求交點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*計算角度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:

list_files ('', ['files','follow_links'], ImageFiles)
tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
for Index := 0 to |ImageFiles| - 1 by 1read_image (Image, ImageFiles[Index])* Image Acquisition 01: Do somethingcount_seconds (Seconds3)mean_image (Image, ImageMean, 30, 30)dyn_threshold (Image, ImageMean, RegionDynThresh, 15, 'light')closing_circle (RegionDynThresh, RegionClosing1, 12.5)fill_up (RegionClosing1, RegionFillUp)connection (RegionFillUp, ConnectedRegions)select_shape_std (ConnectedRegions, SelectedRegions, 'max_area', 70)opening_rectangle1 (SelectedRegions, RegionOpening, 100, 10)skeleton (RegionOpening, Skeleton)gen_contours_skeleton_xld (Skeleton, Contours1, 1, 'filter')fit_line_contour_xld (Contours1, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)gen_region_line (RegionLines, RowBegin, ColBegin, RowEnd, ColEnd)opening_rectangle1 (SelectedRegions, RegionOpening1, 10, 100)dilation_circle (RegionOpening, RegionDilation, 12.5)difference (RegionOpening1, RegionDilation, RegionDifference)connection (RegionDifference, ConnectedRegions1)select_shape_std (ConnectedRegions1, SelectedRegions1, 'max_area', 70)skeleton (SelectedRegions1, Skeleton1)gen_contours_skeleton_xld (Skeleton1, Contours2, 1, 'filter')fit_line_contour_xld (Contours2, 'tukey', -1, 0, 5, 2, RowBegin1, ColBegin1, RowEnd1, ColEnd1, Nr, Nc, Dist)gen_region_line (RegionLines1, RowBegin1, ColBegin1, RowEnd1, ColEnd1)intersection_lines (RowBegin1, ColBegin1, RowEnd1, ColEnd1, RowBegin, ColBegin, RowEnd, ColEnd, Row, Column, IsOverlapping)angle_ll (RowEnd1, ColEnd1,RowBegin1, ColBegin1,RowBegin, ColBegin, RowEnd, ColEnd,   Angle)gen_cross_contour_xld (Cross, Row, Column, 20, rad(45))count_seconds (Seconds4)dev_display(Image)dev_set_line_width (3)dev_set_color ('red')dev_display(RegionLines)dev_display(RegionLines1)dev_set_color ('green')dev_display(Cross)AngleDeg := deg(Angle)disp_message (WindowHandle, 'CT : ' + ((Seconds4-Seconds3)*1000)+' mSec', 'image', 10 , 10, 'slate blue', 'true')  disp_message (WindowHandle, 'AngleDeg : ' + AngleDeg+' 度', 'image', 60 , 10, 'slate blue', 'true')stop()
endfor

在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/254125.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/254125.shtml
英文地址,請注明出處:http://en.pswp.cn/news/254125.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

編程開發之--java多線程學習總結(2)同步代碼塊

1、第一種解決辦法:同步代碼塊,關鍵字synchronized package com.lfy.ThreadsSynchronize;/*** 1、使用同步代碼塊* 語法:synchronized (同步鎖) {//需要同步操作的代碼 }同步鎖:為了保證每個線程都能正常的執行原子操作&a…

swift 隨機數

1.一行代碼生成隨機數 arc4random() 如果要生成一個生成在一定范圍內的隨機整數: func randomIn(#min: Int, max: Int) -> Int { return Int(arc4random()) % (max - min 1) min} 該方法會生成[min, max]范圍內的隨機整數轉載于:https://www.cnblogs.com/qiyiyifan/p/…

u-boot裁減

http://blog.csdn.net/menuconfig/article/details/2276078u-boot裁減的主要方法是通過刪除不需要的命令來減小可執行代碼體積。比如說,如果不需要網絡相關的功能,則可以將網絡相關的所有命令全部刪除,可以節約可觀的flash空間。一般u-boot的…

PhpStudy 升級 MySQL 版本到5.7

1:備份當前數據庫數據、 最好是導成 SQL 文件2:備份 PhpStudy 下的 MySQL 文件夾、以防升級失敗、還可以使用舊版本的數據庫3:下載MySQL5.7、解壓、然后放在 PhpStudy 下的 MySQL 文件夾下地址:https://dev.mysql.com/downloads/f…

使用直線標定板進行相機畸變校正,并且進行9點標定(halcon)

直線標定板圖片: 機械吸頭位置圖片: 處理代碼 read_image (Image, 直線標定板圖片/Left201118140641772.bmp) get_image_size (Image, Width, Height) dev_close_window () dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle) dev_display…

github設置添加SSH

很多朋友在用github管理項目的時候,都是直接使用https url克隆到本地,當然也有有些人使用 SSH url 克隆到本地。然而,為什么絕大多數人會使用https url克隆呢? 這是因為,使用https url克隆對初學者來說會比較方便&…

linux設置套接字緩沖區的大小

系統提供的socket緩沖區大小為8K,你可以將之設置為64K,尤其在傳輸實時視頻時。 socket發送數據時候先把數據發送到socket緩沖區中,之后接受函數再從緩沖區中取數據,如果發送端特別快的時候,緩沖區很快就被填滿&#x…

【Java MyBatis Generator】使用generator自動生成Dao,Mapping和實體文件

具體請參照&#xff1a; http://blog.csdn.net/fengshizty/article/details/43086833 按照上面博客地址&#xff0c;下載Generator的依賴包&#xff1a; 如下是我的配置文件&#xff1a; 1 <?xml version"1.0" encoding"UTF-8"?>2 <!DOCTYPE ge…

h5移動端設備像素比dpr介紹

首先介紹一下概念 devicePixelRatio其實指的是window.devicePixelRatio window.devicePixelRatio是設備上物理像素和設備獨立像素(device-independent pixels (dips))的比例。 公式表示就是&#xff1a;window.devicePixelRatio 物理像素 / dips 好了&#xff0c;到了這里有出…

halcon直線標定板對相機標定的效果評估(對比矯正前后、對比標定板矯正效果)

原圖 程序源碼 * gen_caltab (7, 7, 0.0025, 1/2.5, GB025標定板.descr, GB025標定板.ps) * Calibration 01: Code generated by Calibration 01 * CameraParameters : [0.048105,-44.0585,8.31518e-006,8.3e-006,641.37,588.269,1280,1024] * CameraPose : [-0.000849522,-0.…

【QQ輸入法】QQ輸入法-剪切板 釋放內存

發現一個神奇的情況&#xff1a; 清除和關閉的操作&#xff1a; 1. 2.右鍵 3.點擊 4.清空 5.最后需要關閉 QQ輸入法的進程

Socket編程原理

什么是SocketSocket接口是TCP/IP網絡的API&#xff0c;Socket接口定義了許多函數或例程&#xff0c;程序員可以用它們來開發TCP/IP網絡上的應用程序。要學Internet上的TCP/IP網絡編程&#xff0c;必須理解Socket接口。Socket接口設計者最先是將接口放在Unix操作系統里面的。如果…

【XLL 框架庫函數】 TempActiveCell/TempActiveCell12

這兩個函數創建 XLOPER/XLOPER12 &#xff0c;包含了當前激活工作表上的單元格引用。 LPXLOPER TempActiveCell(WORD row, BYTE col); LPXLOPER12 TempActiveCell12(RW row, COL co); 參數 row 引用行號&#xff0c;行號參數是從0開始的&#xff0c;因此 第一行就是0. col 引用…

POJ 3264 Balanced Lineup【線段樹區間查詢求最大值和最小值】

Balanced Lineup Time Limit: 5000MS Memory Limit: 65536KTotal Submissions: 53703 Accepted: 25237Case Time Limit: 2000MSDescription For the daily milking, Farmer Johns N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to…

halcon測試一張圖片是否過曝或過暗

read_image (Image, 1.bmp) count_obj (Image, Number) if(Number<0)return() endif min_max_gray (Image, Image, 0, Min, Max, Range) if(Min<1)*圖像過暗 endif if(Max>254)*圖像過曝 endif

真的要做一輩子的程序員嗎?來自10年程序員的心聲

經常聽一些同學說&#xff1a;不知道下一份工作該去哪類公司做些什么&#xff0c;我的職場人際一團糟老板不重視我&#xff0c;我現在成長的非常慢所以又想跳槽了&#xff0c;我看不到公司的發展前景好迷茫&#xff0c;其實這一切的困惑都來源于沒有做好職業規劃或者你根本就沒…

網絡編程之 TCP / UDP 及其流程比較

TCP與UDP的區別 1、基于連接與無連接 2、對系統資源的要求&#xff08;TCP較多&#xff0c;UDP少&#xff09;3、UDP程序結構較簡單 流模式與數據報模式 4、TCP保證數據正確性&#xff0c;UDP可能丟包 5、TCP保證數據順序&#xff0c;UDP不保證具體編程時的區別 1、socket()的參…

Tomcat在Linux上的安裝與配置

Tomcat在Linux上的安裝與配置 1、 jdk下載地址&#xff1a; http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html tomcat下載地址:http://tomcat.apache.org/download-70.cg 2、jdk安裝與配置.&#xff08;rpm包&#xff09; (1)jdk安裝…

Spring在3.1版本后的bean獲取方法的改變

xml配置不變&#xff0c;如下 <?xml version"1.0" encoding"UTF-8"?> <beans xmlns"http://www.springframework.org/schema/beans"xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://…

使用halcon選擇點擬合成直線求直線角度

原圖 源碼 read_image (Image, 0.bmp) dev_clear_window () dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle) dev_display (Image)binary_threshold (Image, Region, max_separability, dark, UsedThreshold) connection (Region, ConnectedRegions) select_s…