自制简易激光测距仪(3)
时间:2015-06-30 16:50 来源:未知 作者:admin 点击:次
| // 找到了画十字线标注 for (row = 0; row < H; row++) { for (col = 0; col < W; col++) { i = (unsigned long)(row*3*W + 3*col); if ((row == max_row) || (col == max_col)) *(img_d + i) = *(img_d + i + 1) = *(img_d + i + 2) = 255; } } pixels_from_center = max_row - H/2; // 算出距离并打印出来 range = h_cm / tan(pixels_from_center * gain + offset); cout << "W= " << W << ", H= " << H << ", Max Value at x=" << max_col << ", y= " << max_row << ", range= " << range << endl; cvShowImage( "Example", frame ); char c = cvWaitKey(10); if( c == 27 ) break; } cvReleaseCapture( &capture ); cvDestroyWindow( "Example" ); } 实际测试中误差还算可以,在5%以内,最主要是激光点的判断还有很大提高空间,opencv提供了不少API,网上也有一些文章 距离64cm:  距离152cm:  (责任编辑:admin) | 
- 上一篇:汽车专用试灯电笔制作方法
- 下一篇:LCD1602液晶屏 电压表电流表功率表制作