利用cvFindExtrinsicCameraParams2求取相机外参数
cvFindExtrinsicCameraParams2函数的定义:
void cvFindExtrinsicCameraParams2( const CvMat* object_points,
const CvMat* image_points,
const CvMat* intrinsic_matrix,
const CvMat* distortion_coeffs,
CvMat* rotation_vector,
CvMat* translation_vector );

#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <stdlib.h> int n_boards = ; //Will be set by input list
const int board_dt = ;
int board_w;
int board_h; void help()
{
printf("Calibration from disk. Call convention:\n\n"
"Where: board_{w,h} are the # of internal corners in the checkerboard\n"
" width (board_w) and height (board_h)\n"
" image_list is space separated list of path/filename of checkerboard\n"
" images\n\n"
"Hit 'p' to pause/unpause, ESC to quit. After calibration, press any other key to step through the images\n\n");
} int main(int argc, char* argv[])
{ CvCapture* capture;// = cvCreateCameraCapture( 0 );
// assert( capture ); if(argc != )
{
help();
return -;
}
help();
board_w = atoi(argv[]);
board_h = atoi(argv[]);
int board_n = board_w * board_h;
CvSize board_sz = cvSize( board_w, board_h );
FILE *fptr = fopen(argv[],"r");
char names[];
//COUNT THE NUMBER OF IMAGES:
while(fscanf(fptr,"%s ",names)==)
{
n_boards++;
}
rewind(fptr); cvNamedWindow( "Calibration" );
//ALLOCATE STORAGE
CvMat* image_points = cvCreateMat(board_n,,CV_32FC1);
CvMat* object_points = cvCreateMat(board_n,,CV_32FC1);
//CvMat* point_counts = cvCreateMat(1,CV_32SC1); CvMat *intrinsic = (CvMat*)cvLoad("Intrinsicsr.xml");
CvMat *distortion = (CvMat*)cvLoad("Distortionr.xml");
CvMat* rotation_vector=cvCreateMat(,,CV_32FC1);
CvMat* translation_vector=cvCreateMat(,,CV_32FC1);
CvMat* rotation_mat=cvCreateMat(,,CV_32FC1);
CvMat* jacobian=cvCreateMat(,,CV_32FC1); IplImage* image = ;// = cvQueryFrame( capture );
IplImage* gray_image = ; //for subpixel
CvPoint2D32f* corners = new CvPoint2D32f[ board_n ];
int corner_count; fscanf(fptr,"%s ",names);
image = cvLoadImage( names);
if(gray_image == && image) //We'll need this for subpixel accurate stuff
gray_image = cvCreateImage(cvGetSize(image),,); if(!image)
printf("null image\n"); int found = cvFindChessboardCorners(
image,
board_sz,
corners,
&corner_count,
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS
); //Get Subpixel accuracy on those corners
cvCvtColor(image, gray_image, CV_BGR2GRAY);
cvFindCornerSubPix(gray_image, corners, corner_count,
cvSize(,),cvSize(-,-), cvTermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, , 0.1 ));
//Draw it cvDrawChessboardCorners(image, board_sz, corners, corner_count, found);
cvShowImage( "Calibration", image );
if( corner_count == board_n )
printf("Found = %d for %s\n",found,names);
for( int i=; i<board_n; ++i )
{
CV_MAT_ELEM(*image_points, float,i,) = corners[i].x;
CV_MAT_ELEM(*image_points, float,i,) = corners[i].y;
CV_MAT_ELEM(*object_points,float,i,) = i/board_w;
CV_MAT_ELEM(*object_points,float,i,) = i%board_w;
CV_MAT_ELEM(*object_points,float,i,) = 0.0f;
} cvFindExtrinsicCameraParams2(
object_points,image_points,intrinsic,distortion,rotation_vector,translation_vector
);
cvRodrigues2(
rotation_vector,rotation_mat,jacobian=NULL
);
cvSave("Rotationr.xml",rotation_mat);
cvSave("Translationr.xml",translation_vector);
}
利用cvFindExtrinsicCameraParams2求取相机外参数的更多相关文章
- [笔记]ACM笔记 - 利用FFT求卷积(求多项式乘法)
卷积 给定向量:, 向量和: 数量积(内积.点积): 卷积:,其中 例如: 卷积的最典型的应用就是多项式乘法(多项式乘法就是求卷积).以下就用多项式乘法来描述.举例卷积与DFT. 关于多项式 对于多项 ...
- poj 1523Tarjan算法的含义——求取割点可以分出的连通分量的个数
poj 1523Tarjan算法的含义——求取割点可以分出的连通分量的个数 题目大意:如题目所示 给你一些关系图——连通图,想要问你有没有个节点,损坏后,可以生成几个互相独立的网络(也就是连通分量), ...
- Acme Corporation UVA - 11613 拆点法+最大费用最大流(费用取相反数)+费用有正负
/** 题目:Acme Corporation UVA - 11613 拆点法+最大费用最大流(费用取相反数)+费用有正负 链接:https://vjudge.net/problem/UVA-1161 ...
- 利用JS获取地址栏的中文参数
地址栏中为:localhost:22865/ZYHSYY.aspx?BQH=305&DoctorName=张三&DoctorId=100我想利用JS获取到“张三”,请问该如何写js?目 ...
- C#利用phantomJS抓取AjAX动态页面
在C#中,一般常用的请求方式,就是利用HttpWebRequest创建请求,返回报文.但是有时候遇到到动态加载的页面,却只能抓取部分内容,无法抓取到动态加载的内容. 如果遇到这种的话,推荐使用phan ...
- 使用C#版OpenCV进行圆心求取
OpenCVSharp是OpenCV的.NET wrapper,是一名日本工程师开发的,项目地址为:https://github.com/shimat/opencvsharp. 该源码是 BSD开放协 ...
- 第3节 mapreduce高级:8、9、自定义分区实现分组求取top1
自定义GroupingComparator求取topN GroupingComparator是mapreduce当中reduce端的一个功能组件,主要的作用是决定哪些数据作为一组,调用一次reduce ...
- 图像Stride求取
原文:图像Stride求取 做这个日志也许你会觉得多余,但是,如果只给你了图像的流文件,和图像的Width,让你还原原始图像,那么你会发现一个问题,就是Stride未知的问题,这时就需要根据图像的Wi ...
- 线性时间求取第 K 大数
求 Top K 的算法主要有基于快速排序的和基于堆的这两种,它们的时间复杂度都为 \(O(nlogK)\).借助于分治思想,以及快速排序的区间划分,我们可以做到 \(O(n)\) 时间复杂度.具体算法 ...
随机推荐
- SPOJ 题目705 New Distinct Substrings(后缀数组,求不同的子串个数)
SUBST1 - New Distinct Substrings no tags Given a string, we need to find the total number of its di ...
- angularjs --- ngResource 类似于 ajax发送请求。
<!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="C ...
- angularjs 服务供应商
<!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="C ...
- 12.Intellij IDEA 添加jar包的三种方式
转自:https://blog.csdn.net/zwj1030711290/article/details/56678353/ 一.直接复制:(不推荐) 方法:直接将硬盘上的jar包复制粘贴到项目的 ...
- Word或Excel里画柱状图和折线图组合体
不多说,直接上干货! 最近,在帮导师,干此项目.其中需要 现在,我带你来一步一步地画出来. 第一步:插入 -> 图表 第二步: 第三步:弹出,默认的数据和图表. 第四步: 第五步: 第六步: ...
- append生成新变量的时候,没有如预期(It's a feature,not a bug?)
这是我在写一个项目中,遇到的一个golang的feature,如代码所示,我在for循环里,每次用append生成一个新的数组,(当然我以前一直以为可以这样,直到我在stackoverflow上发现不 ...
- rem自适应布局-移动端自适应必备:flexible.js
http://caibaojian.com/flexible-js.html
- Ambari Confirm Hosts Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).解决 Permanently added 'hdp21,192. ...
- The IDL compiler
The IDL compiler or bindings generator transcompiles Web IDL to C++ code, specifically bindings betw ...
- 十一 模板匹配match template
一.介绍 1.模板匹配 通俗讲就是以图找图,通过图中的一部分来找它在图中的位置(模板匹配就是在整个图像区域发现与给定子图像匹配的小块区域). 模板匹配是一种最原始.最基本的模式识别方法,研究某一特定对 ...