diy基于摄像头的激光测距仪

上传人:第*** 文档编号:34613677 上传时间:2018-02-26 格式:DOC 页数:15 大小:191.50KB
返回 下载 相关 举报
diy基于摄像头的激光测距仪_第1页
第1页 / 共15页
diy基于摄像头的激光测距仪_第2页
第2页 / 共15页
diy基于摄像头的激光测距仪_第3页
第3页 / 共15页
diy基于摄像头的激光测距仪_第4页
第4页 / 共15页
diy基于摄像头的激光测距仪_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《diy基于摄像头的激光测距仪》由会员分享,可在线阅读,更多相关《diy基于摄像头的激光测距仪(15页珍藏版)》请在金锄头文库上搜索。

1、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

2、 Sub exit_Click() only if running. If (Timer1.Enabled) ThenTimer1.Enabled = False Stop TimerVideoOCX.StopVideoOCX.CloseEnd IfEndEnd SubPrivate Sub Start_Click() Init VideoOCX Control, allocate memory and start grabbingIf (Not Timer1.Enabled) ThenStart.Caption = Stop Disable internal error messages i

3、n VideoOCXVideoOCX.SetErrorMessages False Init controlIf (Not VideoOCX.Init) Then Init failed. Display error message and end subMsgBox VideoOCX.GetLastErrorString, vbOKOnly, VideoOCX ErrorEnd Else Allocate memory for global image handlecapture_image = VideoOCX.GetColorImageHandle result_image = Vide

4、oOCX_Processed.GetColorImageHandleTimer1.Enabled = True Start capture timer Start Capture modeIf (Not VideoOCX.Start) Then Start failed. Display error message and end subMsgBox VideoOCX.GetLastErrorString, vbOKOnly, VideoOCX ErrorEndEnd IfEnd IfElseStart.Caption = StartTimer1.Enabled = False Stop Ti

5、merVideoOCX.StopVideoOCX.CloseEnd IfEnd SubPrivate Sub Timer1_Timer() Timer for capturing - handles videoOCXToolsDim matrix As VariantDim height, width As IntegerDim r, c As IntegerDim max_r, max_c As IntegerDim max_red As IntegerDim gain, offset As VariantDim h_cm As VariantDim range As IntegerDim

6、pixels_from_center As Integer Calibrated parameter for pixel to distance conversiongain = 0.0024259348offset = -0.056514344h_cm = 5.842max_red = 0 Capture an imageIf (VideoOCX.Capture(capture_image) Then VideoOCX.Show capture_image Matrix transformation initialization matrix = VideoOCX.GetMatrix(cap

7、ture_image)height = VideoOCX.GetHeightwidth = 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

8、 too far awayFor 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) Thenmax_red = matrix(c, r, 2)max_r = rmax_c = cEnd IfNext cNext r Calculate the distance for the laser dot from middle of framepixels_from_center = max_r -

9、120 Calculate range in cm based on calibrated parametersrange = h_cm / Tan(pixels_from_center * gain + offset) Print laser dot position row and column to screenrow_val.Caption = max_rcol_val.Caption = max_c Print range to laser illuminated object to screenrange_val.Caption = range Draw a red vertica

10、l line to intersect targetFor r = 0 To height - 1matrix(max_c, r, 2) = 255Next r Draw a red horizontal line to intersect targetFor c = 0 To width - 1matrix(c, max_r, 2) = 255Next cVideoOCX.ReleaseMatrixToImageHandle (capture_image) End IfVideoOCX.Show capture_imageEnd Sub截屏如下: 首页 上一页 1 2 3 4 5 6 下一页

11、 尾页 跳转到 5 页 转载声明:凡文章出处为 www.RoboticF 的,系本站的原创文章。其它媒体在注明出处为 RoboticF 并给出原始链接后可以自由转载,否则将视为侵权 !上一篇: Wall E 真机演示 下一篇: ASIMO 上班咯!游客10-01-12 分数: 3第 1 楼需要一个可以自动聚焦的摄像头精彩一针见血观点独到说的很对你说的有道理乱七八糟说什么你说的没道理简直是胡说八道游客09-03-10 分数: 3第 2 楼这里用了激光总感到有点不足,激光有一个可见的光点会让人感到不舒服。既然用了透镜成像的原理,何不用二个摄像头来完成这项工作。设想是:物体经过二个透镜会产生不同的图

12、像偏移,偏移量的大小代表了物体的远近。要找出相同图像的偏移量,我想应该有很多办法。当然,物体有远有近,产生的偏移量会不同,图像处理如何简单?我考虑可以加一个红外光,也找最亮的区域进行图像处理,越近越亮。当然,说说容易做做难,这只是我一个想法而已!精彩一针见血观点独到说的很对你说的有道理乱七八糟说什么你说的没道理简直是胡说八道12312308-10-22 分数: 1第 3 楼你 up 物?精彩一针见血观点独到说的很对你说的有道理乱七八糟说什么你说的没道理简直是胡说八道游客08-08-10 分数: 3第 4 楼看不懂.精彩一针见血观点独到说的很对你说的有道理乱七八糟说什么你说的没道理简直是胡说八道

13、08-05-20 分数: 3第 5 楼最后部分是如何 将点改为线进行测距?博创的未来之星机器人上貌似也没找到呢精彩一针见血观点独到说的很对你说的有道理乱七八糟说什么你说的没道理简直是胡说八道08-05-19 分数: 5第 6 楼good精彩一针见血观点独到说的很对你说的有道理乱七八糟说什么你说的没道理简直是胡说八道08-05-14 分数: 3第 7 楼我完全是个外行,提个愚蠢的问题:碰到镜子有没有影响?精彩一针见血观点独到说的很对你说的有道理乱七八糟说什么你说的没道理简直是胡说八道08-05-12 分数: 3第 8 楼呵呵,最后这部分将点改为线进行测距的工作,博创的未来之星机器人上已经有这个实验教程了。

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号