热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

opencv中calibration.cpp程序

参数相机矩阵:包括焦距(fx,fy),光学中心(Cx,Cy)&#x

参数

相机矩阵:包括焦距(fx,fy),光学中心(Cx,Cy),完全取决于相机本身,是相机的固有属性,只需要计算一次,可用矩阵表示如下:[fx, 0, Cx; 0, fy, cy; 0,0,1];

畸变系数:畸变数学模型的5个参数 D = (k1,k2, P1, P2, k3);

相机内参:相机矩阵和畸变系数统称为相机内参,在不考虑畸变的时候,相机矩阵也会被称为相机内参;

相机外参:通过旋转和平移变换将3D的坐标转换为相机2维的坐标,其中的旋转矩阵和平移矩阵就被称为相机的外参;描述的是将世界坐标系转换成相机坐标系的过程。

static void help(char** argv)
{printf( "This is a camera calibration sample.\n""Usage: %s\n"" -w= # the number of inner corners per one of board dimension\n"" -h= # the number of inner corners per another board dimension\n"" [-pt=

] # the type of pattern: chessboard or circles' grid\n"" [-n=] # the number of frames to use for calibration\n"" # (if not specified, it will be set to the number\n"" # of board views actually available)\n"" [-d=] # a minimum delay in ms between subsequent attempts to capture a next view\n"" # (used only for video capturing)\n"" [-s=] # square size in some user-defined units (1 by default)\n"" [-o=] # the output filename for intrinsic [and extrinsic] parameters\n"" [-op] # write detected feature points\n"" [-oe] # write extrinsic parameters\n"" [-oo] # write refined 3D object points\n"" [-zt] # assume zero tangential distortion\n"" [-a=] # fix aspect ratio (fx/fy)\n"" [-p] # fix the principal point at the center\n"" [-v] # flip the captured images around the horizontal axis\n"" [-V] # use a video file, and not an image list, uses\n"" # [input_data] string for the video file name\n"" [-su] # show undistorted images after calibration\n"" [-ws=] # Half of search window for cornerSubPix (11 by default)\n"" [-dt=] # actual distance between top-left and top-right corners of\n"" # the calibration grid. If this parameter is specified, a more\n"" # accurate calibration method will be used which may be better\n"" # with inaccurate, roughly planar target.\n"" [input_data] # input data, one of the following:\n"" # - text file with a list of the images of the board\n"" # the text file can be generated with imagelist_creator\n"" # - name of video file with a video of the board\n"" # if input_data not specified, a live view from the camera is used\n""\n", argv[0] );printf("\n%s",usage);printf( "\n%s", liveCaptureHelp );
}

离线文件


-w=4


-h=5

标定图片示例上图中,横向和纵向分别为9个交点和6个交点,对应上面的命令行的命令参数应该为: -w 9 -h 6


  • 经多次使用发现,不指定 -p参数时计算的结果误差较大,主要表现在对u0,v0的估计误差较大,因此建议使用时加上-p参数

-s=0.025

每格的宽度应设置为实际的毫米数,该参数的实际用途尚待考证。目前看来,即使设置的不准确也无大碍。我使用默认参数50。

50

-o=camera.yml

%YAML:1.0
---
calibration_time: "Fri Apr 29 17:00:05 2022"
nframes: 13
image_width: 640
image_height: 480
board_width: 9
board_height: 6
square_size: 2.5000000372529030e-02
flags: 0
camera_matrix: !!opencv-matrixrows: 3cols: 3dt: ddata: [ 5.3646256689600978e+02, 0., 3.4236865068583234e+02, 0.,5.3641493800336877e+02, 2.3554895558339965e+02, 0., 0., 1. ]
distortion_coefficients: !!opencv-matrixrows: 5cols: 1dt: ddata: [ -2.7864428555798293e-01, 6.7166038149765392e-02,1.8241702364718330e-03, -3.4339100766844229e-04, 0. ]
avg_reprojection_error: 4.0902606790992146e-01
per_view_reprojection_errors: !!opencv-matrixrows: 13cols: 1dt: fdata: [ 1.92254305e-01, 1.22073436e+00, 1.69930875e-01,1.94889039e-01, 1.59580454e-01, 1.80783704e-01, 2.36002639e-01,2.42605597e-01, 3.02249402e-01, 1.67995840e-01, 2.05065876e-01,4.64376807e-01, 1.75895900e-01 ]

输出 


-op
-oe image_list.xml


list_of_views.txt

该txt文件表示的是你在电脑上面需要用以标定的图片列表。

view00.png
view01.png
#view02.png
view03.png
view10.png
one_extra_view.jpg
上面的例子中,前面加“井号”的图片被忽略。

  • 在windows的命令行中,有一种简便的办法来产生此txt文件。在CMD窗口中输入如下命令(假设当前目录里面的所有jpg文件都用作标定,并且生成的文件为a.txt)。

dir *.jpg /B >> a.txt

 launch.vs.json

{"version": "0.2.1","defaults": {},"configurations": [{"type": "default","project": "build\\bin\\Debug\\example_cpp_calibration.exe","name": "example_cpp_calibration.exe(安装)(build\\bin\\Debug\\example_cpp_calibration.exe)","args": ["-w=9 -h=6 -s=0.025 -o=camera.yml -op -oe calibration.yml"]}]
}


推荐阅读
  • SpringBoot uri统一权限管理的实现方法及步骤详解
    本文详细介绍了SpringBoot中实现uri统一权限管理的方法,包括表结构定义、自动统计URI并自动删除脏数据、程序启动加载等步骤。通过该方法可以提高系统的安全性,实现对系统任意接口的权限拦截验证。 ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • eclipse学习(第三章:ssh中的Hibernate)——11.Hibernate的缓存(2级缓存,get和load)
    本文介绍了eclipse学习中的第三章内容,主要讲解了ssh中的Hibernate的缓存,包括2级缓存和get方法、load方法的区别。文章还涉及了项目实践和相关知识点的讲解。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • 本文介绍了在Python3中如何使用选择文件对话框的格式打开和保存图片的方法。通过使用tkinter库中的filedialog模块的asksaveasfilename和askopenfilename函数,可以方便地选择要打开或保存的图片文件,并进行相关操作。具体的代码示例和操作步骤也被提供。 ... [详细]
  • VScode格式化文档换行或不换行的设置方法
    本文介绍了在VScode中设置格式化文档换行或不换行的方法,包括使用插件和修改settings.json文件的内容。详细步骤为:找到settings.json文件,将其中的代码替换为指定的代码。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 个人学习使用:谨慎参考1Client类importcom.thoughtworks.gauge.Step;importcom.thoughtworks.gauge.T ... [详细]
  • HDFS2.x新特性
    一、集群间数据拷贝scp实现两个远程主机之间的文件复制scp-rhello.txtroothadoop103:useratguiguhello.txt推pushscp-rr ... [详细]
author-avatar
mobiledu2502912375
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有