已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
DIY基于摄像头的激光测距仪作者:Rockets 文章来源: www.RoboticF 更新时间:2008年05月11日 打印此文 浏览数: 20296 软件我通过两个方式编写了这个软件,一个是vc+,一个是VB。你能发现VB版本的软件会比VC的软件更容易一些,但是各有取舍。VC+版本能够自由的加入其他软件中?VB版本需要第三方软件支持(在Visual Studio中)Visual Basicvb_laser_ranger.zip 这里可以下载到我的VB版本软件。要使用上面的程序,你必须要安装VideoOCX ActiveX 控件主程序如下: Private Sub exit_Click() only if running. If (Timer1.Enabled) Then Timer1.Enabled = False Stop Timer VideoOCX.Stop VideoOCX.Close End If EndEnd SubPrivate Sub Start_Click() Init VideoOCX Control, allocate memory and start grabbing If (Not Timer1.Enabled) Then Start.Caption = Stop Disable internal error messages in VideoOCX VideoOCX.SetErrorMessages False Init control If (Not VideoOCX.Init) Then Init failed. Display error message and end sub MsgBox VideoOCX.GetLastErrorString, vbOKOnly, VideoOCX Error End Else Allocate memory for global image handle capture_image = VideoOCX.GetColorImageHandle result_image = VideoOCX_Processed.GetColorImageHandle Timer1.Enabled = True Start capture timer Start Capture mode If (Not VideoOCX.Start) Then Start failed. Display error message and end sub MsgBox VideoOCX.GetLastErrorString, vbOKOnly, VideoOCX Error End End If End If Else Start.Caption = Start Timer1.Enabled = False Stop Timer VideoOCX.Stop VideoOCX.Close End If End SubPrivate Sub Timer1_Timer() Timer for capturing - handles videoOCXTools Dim matrix As Variant Dim height, width As Integer Dim r, c As Integer Dim max_r, max_c As Integer Dim max_red As Integer Dim gain, offset As Variant Dim h_cm As Variant Dim range As Integer Dim pixels_from_center As Integer Calibrated parameter for pixel to distance conversion gain = 0.0024259348 offset = -0.056514344 h_cm = 5.842 max_red = 0 Capture an image If (VideoOCX.Capture(capture_image) Then VideoOCX.Show capture_image Matrix transformation initialization matrix = VideoOCX.GetMatrix(capture_image) height = VideoOCX.GetHeight width = VideoOCX.GetWidth Image processing code The laser dot should not be seen above the middle row (with a little pad) For r = height / 2 - 20 To height - 1 Our physical setup is roughly calibrated to make the laser dot in the middle columns.dont bother lookng too far away For c = width / 2 - 25 To width / 2 + 24 Look for the largest red pixel value in the scene (red laser) If (matrix(c, r, 2) max_red) Then max_red = matrix(c, r, 2) max_r = r max_c = c End If Next c Next r Calculate the distance for the laser dot from middle of frame pixels_from_center = max_r - 120 Calculate range in cm based on calibrated parameters range = h_cm / Tan(pixels_from_center * gain + offset) Print laser dot position row and column to screen row_val.Caption = max_r col_val.Caption = max_c Print range to laser illuminated object to screen range_val.Caption = range Draw a red vertical line to intersect target For r = 0 To height - 1 matrix(max_c, r, 2) = 255 Next r Draw a red horizontal line to intersect target For c = 0 To width - 1 matrix(c, max_r, 2) = 255 Next c VideoOCX.ReleaseMatrixToImageHandle (capture_image)RoboticFan End If VideoOCX.Show capture_imageEnd Sub截屏如下: 首页 上一页 1 2 3 4 5 6 下一页 尾页 跳转到页 转载声明:凡文章出处为www.RoboticF的,系本站的原创文章。其它媒体在注明出处为RoboticF并给出原始链接后可以自由转载,否则将视为侵权!上一篇:Wall E 真机演示 下一篇:ASIMO上班咯!游客10-01-12 分数: 3第1楼需要一个可以自动聚焦的摄像头精彩一针见血观点独到说的很对你说的有道理乱七八糟说什么你说的没道理简直是胡说八道游客09-03-10 分数: 3第2楼这里用了激光总感到有点不足,激光有一个可见的光点会让人感到不舒服。既然用了透镜成像的原理,何不用二个摄像头来完成这项工作。设想是:物体经过二个透镜会产生不同的图像偏移,偏移量的大小代表了物体的远近。要找出相同图像的偏移量,我想应该有很多办法。当然,物体有远有近,产生的偏移量会不同,图像处理如何简单?我考虑可以加一个红外光,也找最亮的区域进行图像处理,越近越亮。当然,说说容易做做难,这只是我一个想法而已!精彩一针见血观点独到说的很对你说的有道理乱七八糟说什么你说的没道理简直是胡说八道12312308-10-22 分数: 1第3楼你up物?精彩一针见血观点独到说的很对你说的有道理乱七八糟说什么你说的没道理简直是胡说八道游客08-08-10 分数: 3第4楼看不懂.精彩一针见血观点独到说的很对你说的有道理乱七八糟说什么你说的没道理简直是胡说八道08-05-20 分数: 3第5楼最后部分是如何 将点改为线进行测距?博创的未来之星机器人上貌似也没找到呢精彩一针见血观点独到说的很对你说的有道理乱七八糟说什么你说的没道理简直是胡说八道08-05-1
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026 儿童专注力持续稳定训练课件
- 护理应用课件模板下载专区
- AutoCAD机械设计教程课件 项目10-减速器机座零件图绘制
- 2026年国开行政策性业务考核试题及答案
- 月子中心新生儿异常应急演练脚本
- (完整版)建筑外窗保温性能检测报告
- 2026年装饰装修工程施工考核试题及答案
- 2026年社区护理主管护师考试题库及答案
- 2026年村级关爱网格员宣传员考试真题及答案
- 普外科护理人文关怀
- (2026年)一例心衰患者的护理查房课件
- (2026版)医疗保障基金使用监督管理条例实施细则培训课件
- 新苏教版科学三年级下册《声音的产生》课件
- 预拌混凝土试验仪器作业指导书
- 2026年最佳男朋友测试题目及答案
- 国家事业单位招聘2024国家基础地理信息中心考察对象笔试历年参考题库典型考点附带答案详解
- 三级模块二-项目七-认知训练 -任务二 定向力训练
- 检验科抽血课件
- 高低压配电柜设备验收与安装规范
- 2025年公文竞赛题库及答案解析
- JBT 7334-2016 手拉葫芦标准
评论
0/150
提交评论