热门标签 | 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"]}]
}


推荐阅读
  • 本文详细介绍了如何构建一个高效的UI管理系统,集中处理UI页面的打开、关闭、层级管理和页面跳转等问题。通过UIManager统一管理外部切换逻辑,实现功能逻辑分散化和代码复用,支持多人协作开发。 ... [详细]
  • 优化ListView性能
    本文深入探讨了如何通过多种技术手段优化ListView的性能,包括视图复用、ViewHolder模式、分批加载数据、图片优化及内存管理等。这些方法能够显著提升应用的响应速度和用户体验。 ... [详细]
  • 本文介绍如何在 Android 中通过代码模拟用户的点击和滑动操作,包括参数说明、事件生成及处理逻辑。详细解析了视图(View)对象、坐标偏移量以及不同类型的滑动方式。 ... [详细]
  • Explore how Matterverse is redefining the metaverse experience, creating immersive and meaningful virtual environments that foster genuine connections and economic opportunities. ... [详细]
  • 导航栏样式练习:项目实例解析
    本文详细介绍了如何创建一个具有动态效果的导航栏,包括HTML、CSS和JavaScript代码的实现,并附有详细的说明和效果图。 ... [详细]
  • 本文介绍了Java并发库中的阻塞队列(BlockingQueue)及其典型应用场景。通过具体实例,展示了如何利用LinkedBlockingQueue实现线程间高效、安全的数据传递,并结合线程池和原子类优化性能。 ... [详细]
  • 主要用了2个类来实现的,话不多说,直接看运行结果,然后在奉上源代码1.Index.javaimportjava.awt.Color;im ... [详细]
  • 使用 Azure Service Principal 和 Microsoft Graph API 获取 AAD 用户列表
    本文介绍了一段通用代码示例,该代码不仅能够操作 Azure Active Directory (AAD),还可以通过 Azure Service Principal 的授权访问和管理 Azure 订阅资源。Azure 的架构可以分为两个层级:AAD 和 Subscription。 ... [详细]
  • Android 渐变圆环加载控件实现
    本文介绍了如何在 Android 中创建一个自定义的渐变圆环加载控件,该控件已在多个知名应用中使用。我们将详细探讨其工作原理和实现方法。 ... [详细]
  • 在使用 DataGridView 时,如果在当前单元格中输入内容但光标未移开,点击保存按钮后,输入的内容可能无法保存。只有当光标离开单元格后,才能成功保存数据。本文将探讨如何通过调用 DataGridView 的内置方法解决此问题。 ... [详细]
  • 本文介绍了如何在C#中启动一个应用程序,并通过枚举窗口来获取其主窗口句柄。当使用Process类启动程序时,我们通常只能获得进程的句柄,而主窗口句柄可能为0。因此,我们需要使用API函数和回调机制来准确获取主窗口句柄。 ... [详细]
  • RecyclerView初步学习(一)
    RecyclerView初步学习(一)ReCyclerView提供了一种插件式的编程模式,除了提供ViewHolder缓存模式,还可以自定义动画,分割符,布局样式,相比于传统的ListVi ... [详细]
  • 本文探讨了如何在给定整数N的情况下,找到两个不同的整数a和b,使得它们的和最大,并且满足特定的数学条件。 ... [详细]
  • 本文详细介绍了Java中org.w3c.dom.Text类的splitText()方法,通过多个代码示例展示了其实际应用。该方法用于将文本节点在指定位置拆分为两个节点,并保持在文档树中。 ... [详细]
  • 本文详细介绍了 Apache Jena 库中的 Txn.executeWrite 方法,通过多个实际代码示例展示了其在不同场景下的应用,帮助开发者更好地理解和使用该方法。 ... [详细]
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社区 版权所有