多个华为手机相机文档校正怎么同时校正,和两个华为手机相机文档校正

相机去畸变,以及双目平行校正----极线校正(二)————之双目平行校正详细过程
通过相机标定的程序获取了两个相机各自的内参矩阵和畸变系数,以及两个相机达到平行时各自的旋转矩阵。Opencv和Matlab都给了我们现成的函数,可以利用这些数据进行去畸变或者双目平行校正,因为有需求要将去畸变和平行校正移植到硬件上,那么自己如何利用这些参数和矩阵写去畸变的程序和双目平行校正的程序呢?我本人发现的网上这方面资料较少。在此总结一下。
去畸变的过程就是针对单目相机进行的变换,平行校正就是针对双目相机的操作。
本文针对双目平行校正的方法展开叙述:
做双目平行校正时,是已经通过相机标定获取了左、右相机的内参矩阵和畸变系数,以及左、右相机达到平行时各需要的旋转矩阵,另外,已知左右两个相机拍摄出来的两幅图片。
注:这里双目相机各参数标定是通过左右相机拍摄的15对棋盘格图像,通过opencv双目标定程序获取的。
内参矩阵:
畸变系数:
旋转矩阵:
构建一个两个相机共同的理想内参矩阵:
双目平行校正,它是在左、右相机去畸变的过程中对左、右相机坐标系分别多进行了一步旋转操作。它的操作步骤如下:
(1),分别将两个图像的像素坐标系通过共同的内参矩阵转换到相机坐标系:
(2),分别对两个相机坐标系进行旋转得到新的相机坐标系。通过左乘旋转矩阵R1和R2。
(3),针对新的相机坐标分别进行左、右相机的去畸变操作。
(4),去畸变操作结束后,分别用左、右相机的内参矩阵将左、右两个相机坐标系重新转换到左、右图像像素坐标系。
(5),并分别用左、右源图像的像素值对新左、右图像的像素点进行插值。
编程实例:
左右相机拍摄的图像:
共同显示:
左摄像头处理程序:
f1=1;%焦距倍数
for x=1:W1 %640
for y=1:H1
yy=(y-cy)/%转换到相机坐标系
xx=(x-cx-gama*yy)/
pos=[f1]; %3x1
pos=inv(R1)* %旋转相机坐标系,3x1
xx=pos(1,:)/pos(3,:);%归一化
yy=pos(2,:)/pos(3,:);
r=xx^2+yy^2;
xxx=xx*(1+k11*r+k12*r^2+k13*r^3)+2*p11*xx*yy+p12*(r+2*xx^2);
yyy=yy*(1+k11*r+k12*r^2+k13*r^3)+2*p12*xx*yy+p11*(r+2*yy^2);
xxxx=xxx*fx1+cx1;
yyyy=yyy*fy1+cy1;
if (xxxx&1 && xxxx&=W1 && yyyy&1 && yyyy&=H1)
I11(y,x)=(floor(w+1)-w)*(floor(h+1)-h)*I1(floor(h),floor(w))+(floor(w+1)-w)*(h-floor(h))*I1(floor(h+1),floor(w))+(w-floor(w))*(floor(h+1)-h)*I1(floor(h),floor(w+1))+(w-floor(w))*(h-floor(h))*I1(floor(h+1),floor(w+1));
右摄像头处理程序:
f2=1;%焦距
for x=1:W1 %640
for y=1:H1
yy=(y-cy)/%转换到相机坐标系
xx=(x-cx-gama*yy)/
pos=[f2]; %3x1
pos=inv(R2)* %旋转相机坐标系,3x1
xx=pos(1,:)/pos(3,:);%归一化
yy=pos(2,:)/pos(3,:);
r=xx^2+yy^2;
xxx=xx*(1+k21*r+k22*r^2+k23*r^3)+2*p21*xx*yy+p22*(r+2*xx^2);
yyy=yy*(1+k21*r+k22*r^2+k23*r^3)+2*p22*xx*yy+p21*(r+2*yy^2);
xxxx=xxx*fx2+cx2;
yyyy=yyy*fy2+cy2;
if (xxxx&1 && xxxx&=W2 && yyyy&1 && yyyy&=H2)
I22(y,x)=(floor(w+1)-w)*(floor(h+1)-h)*I2(floor(h),floor(w))+(floor(w+1)-w)*(h-floor(h))*I2(floor(h+1),floor(w))+(w-floor(w))*(floor(h+1)-h)*I2(floor(h),floor(w+1))+(w-floor(w))*(h-floor(h))*I2(floor(h+1),floor(w+1));
经过去畸变和平行校正处理后的图像:
平行放置并划线对比显示可见,两幅图像已经达到极线平行:
相机去畸变,以及双目平行校正----极线校正(一)————之单目畸变校正详细过程
双目相机的畸变校正以及平行校正(极线校正)的入门问题总结
Bouguet极线校正的方法
极线校正续
Bouguet极线校正进一步理解
Fusiello极线校正方法的原理及C++实现
(五) 畸变矫正—让世界不在扭曲
【计算机视觉学习笔记--双目视觉几何框架系列】
没有更多推荐了, 上传我的文档
 上传文档
 下载
 收藏
该文档贡献者很忙,什么也没留下。
 下载此文档
一种彩色相机和深度相机的联合校准和失真矫正算法
下载积分:2990
内容提示:一种彩色相机和深度相机的联合校准和失真矫正算法
文档格式:PDF|
浏览次数:10|
上传日期: 19:59:44|
文档星级:
全文阅读已结束,如果下载本文需要使用
 2990 积分
下载此文档
该用户还上传了这些文档
一种彩色相机和深度相机的联合校准和失真矫正算法
关注微信公众号镜头校正功能怎么用?
您好,我最近新买了一台佳能600D,听说现在的相机里面内置了镜头校正功能,不知道这个镜头校正功能有什么缺点?能使用镜头校正功能的相机多么?镜头校正功能
按时间排序
因为目前世界上没有一直镜头是完美的,就算是目前最顶级的光学厂商所生产的镜头也会有成像失真、镜头边缘光衰减过大的现象。所以现在差不多所有的单反相机都已经内置了镜头校正功能,不过使用镜头校正功能可能会出现色差、图像清晰度降低还有图像边缘被裁切等。在有的相机里面,镜头校正功能属于RAW文件编辑菜单的一部分。最后需要提醒楼主的是并不是所有的镜头都能使用镜头校正功能,目前镜头校正功能有的只适用于原厂镜头。希望以上信息可以对你有所帮助更多摄影技巧和相机产品问答请关注更多关于数码影响的问题可以到进行交流分享
因为目前世界上没有一直镜头是完美的,就算是目前最顶级的光学厂商所生产的镜头也会有成像失真、镜头边缘光衰减过大的现象。所以现在差不多所有的单反相机都已经内置了镜头校正功能,不过使用镜头校正功能可能会出现色差、图像清晰度降低还有图像边缘被裁切等。在有的相机里面,镜头校正功能属于RAW文件编辑菜单的一部分。最后需要提醒楼主的是并不是所有的镜头都能使用镜头校正功能,目前镜头校正功能有的只适用于原厂镜头。
您可以邀请下面用户,快速获得回答
aiyouwoqu3
擅长领域:
在摄影器材分类下共有2454个回答
擅长领域:
在摄影器材分类下共有1670个回答
擅长领域:&&
在摄影器材分类下共有1492个回答
擅长领域:
在摄影器材分类下共有1145个回答
Oo城管大队长oO
擅长领域:&&&&
在摄影器材分类下共有996个回答
fishfish1599
擅长领域:
在摄影器材分类下共有753个回答
加载更多答主
感谢您为社区的和谐贡献力量请选择举报类型
经过核实后将会做出处理感谢您为社区和谐做出贡献
点击可定位违规字符位置
确定要取消此次报名,退出该活动?
请输入私信内容:相机的校正感悟 - haoxing990 - 博客园
&在你看到这篇博文的时候,希望你能先看下我的上一篇博文,对相关的知识点有所了解后再看这篇博文
& 下面的几个函数就是实现相机校正的关键
addChessboardPoints()&函数 - 用于读入一系列的棋盘图像并检测角点;
calibrate()&函数&- 用于进行相机校正,得到相机的参数矩阵和畸变系数;
remap()&函数&- 用于根据相机校正结果修复图像的畸变;//主要靠这个函数实现校正initUndistortRectifyMap
addPoints()&函数&-&addChessboardPoints()&在检测完角点后会调用这个函数。也可自己手动调用这个函数添加已知的角点位置和对应的空间坐标点。
main.c 1 #include &QCoreApplication&
2 #include &iostream&
3 #include &iomanip&
4 #include &vector&
5 #include &opencv2/core/core.hpp&
6 #include &opencv2/imgproc/imgproc.hpp&
7 #include &opencv2/highgui/highgui.hpp&
8 #include &opencv2/features2d/features2d.hpp&
10 #include "CameraCalibrator.h"
12 int main()
cv::namedWindow("Image");
std::vector&std::string&
// generate list of chessboard image filename
for (int i=1; i&=20; i++) {
str && "/home/bi/pic/chessboards/chessboard" && std::setw(2) && std::setfill('0') && i && ".jpg";
std::cout && str.str() && std::
filelist.push_back(str.str());
image= cv::imread(str.str(),0);//直接变为灰度图
//cvtColor(image,image,CV_BGR2GRAY);
cv::imshow("Image",image);
cv::waitKey(1000);
// Create calibrator object
CameraCalibrator cameraC
// add the corners from the chessboard
cv::Size boardSize(6,4);
cameraCalibrator.addChessboardPoints(
// filenames of chessboard image
boardSize);
// size of chessboard
// calibrate the camera
cameraCalibrator.setCalibrationFlag(true,true);
cameraCalibrator.calibrate(image.size());
// Image Undistortion
image = cv::imread(filelist[6]);
cv::Mat uImage= cameraCalibrator.remap(image);
// display camera matrix
cv::Mat cameraMatrix= cameraCalibrator.getCameraMatrix();
std::cout && " Camera intrinsic: " && cameraMatrix.rows && "x" && cameraMatrix.cols && std::
std::cout && cameraMatrix.at&double&(0,0) && " " && cameraMatrix.at&double&(0,1) && " " && cameraMatrix.at&double&(0,2) && std::
std::cout && cameraMatrix.at&double&(1,0) && " " && cameraMatrix.at&double&(1,1) && " " && cameraMatrix.at&double&(1,2) && std::
std::cout && cameraMatrix.at&double&(2,0) && " " && cameraMatrix.at&double&(2,1) && " " && cameraMatrix.at&double&(2,2) && std::
imshow("Original Image", image);
imshow("Undistorted Image", uImage);
cv::waitKey();
CameraCalibrator.h&
addChessboardPoints()&函数 - 用于读入一系列的棋盘图像并检测角点;
calibrate()&函数 - 用于进行相机校正,得到相机的参数矩阵和畸变系数;
remap()&函数 - 用于根据相机校正结果修复图像的畸变;//主要靠这个函数实现校正initUndistortRectifyMap
addPoints()&函数 -&addChessboardPoints()&在检测完角点后会调用这个函数。也可自己手动调用这个函数添加已知的角点位置和对应的空间坐标点。
1 #ifndef CAMERACALIBRATOR_H
2 #define CAMERACALIBRATOR_H
4 #include &vector&
5 #include &iostream&
7 #include &opencv2/core/core.hpp&
8 #include "opencv2/imgproc/imgproc.hpp"
9 #include "opencv2/calib3d/calib3d.hpp"
10 #include &opencv2/highgui/highgui.hpp&
12 class CameraCalibrator {
// input points
std::vector&std::vector&cv::Point3f&& objectP
std::vector&std::vector&cv::Point2f&& imageP
// output Matrices
cv::Mat cameraM
cv::Mat distC
// flag to specify how calibration is done
// used in image undistortion
cv::Mat map1,map2;
bool mustInitU
CameraCalibrator() : flag(0), mustInitUndistort(true) {};
// Open the chessboard images and extract corner points
int addChessboardPoints(const std::vector&std::string&& filelist, cv::Size & boardSize);
// Add scene points and corresponding image points
void addPoints(const std::vector&cv::Point2f&& imageCorners, const std::vector&cv::Point3f&& objectCorners);
// Calibrate the camera
double calibrate(cv::Size &imageSize);
// Set the calibration flag
void setCalibrationFlag(bool radial8CoeffEnabled=false, bool tangentialParamEnabled=false);
// Remove distortion in an image (after calibration)
cv::Mat CameraCalibrator::remap(const cv::Mat &image);
// Getters
cv::Mat getCameraMatrix() { return cameraM }
cv::Mat getDistCoeffs()
{ return distC }
45 #endif // CAMERACALIBRATOR_H
&CameraCalibrator.cpp
1 #include "CameraCalibrator.h"
3 // Open chessboard images and extract corner points
4 int CameraCalibrator::addChessboardPoints(
const std::vector&std::string&& filelist,
cv::Size & boardSize) {
// the points on the chessboard
std::vector&cv::Point2f& imageC
std::vector&cv::Point3f& objectC
// 3D Scene Points:
// Initialize the chessboard corners
// in the chessboard reference frame
// The corners are at 3D location (X,Y,Z)= (i,j,0)
for (int i=0; i&boardSize. i++) {
for (int j=0; j&boardSize. j++) {
objectCorners.push_back(cv::Point3f(i, j, 0.0f));
// 2D Image points:
cv::M // to contain chessboard image
int successes = 0;
// for all viewpoints
for (int i=0; i&filelist.size(); i++) {
// Open the image
image = cv::imread(filelist[i],0);
// Get the chessboard corners
bool found = cv::findChessboardCorners(
image, boardSize, imageCorners);
// Get subpixel accuracy on the corners
cv::cornerSubPix(image, imageCorners,
cv::Size(5,5),
cv::Size(-1,-1),
cv::TermCriteria(cv::TermCriteria::MAX_ITER +
cv::TermCriteria::EPS,
// max number of iterations
// min accuracy
// If we have a good board, add it to our data
if (imageCorners.size() == boardSize.area()) {
// Add image and scene points from one view
addPoints(imageCorners, objectCorners);
successes++;
//Draw the corners
cv::drawChessboardCorners(image, boardSize, imageCorners, found);
cv::imshow("Corners on Chessboard", image);
cv::waitKey(100);
62 // Add scene points and corresponding image points
63 void CameraCalibrator::addPoints(const std::vector&cv::Point2f&& imageCorners, const std::vector&cv::Point3f&& objectCorners) {
// 2D image points from one view
imagePoints.push_back(imageCorners);
// corresponding 3D scene points
objectPoints.push_back(objectCorners);
71 // Calibrate the camera
72 // returns the re-projection error
73 double CameraCalibrator::calibrate(cv::Size &imageSize)
// undistorter must be reinitialized
mustInitUndistort= true;
//Output rotations and translations
std::vector&cv::Mat& rvecs,
// start calibration
calibrateCamera(objectPoints, // the 3D points
imagePoints,
// the image points
imageSize,
// image size
cameraMatrix, // output camera matrix
distCoeffs,
// output distortion matrix
rvecs, tvecs, // Rs, Ts
// set options
,CV_CALIB_USE_INTRINSIC_GUESS);
94 // remove distortion in an image (after calibration)
95 cv::Mat CameraCalibrator::remap(const cv::Mat &image) {
if (mustInitUndistort) { // called once per calibration
cv::initUndistortRectifyMap(
cameraMatrix,
// computed camera matrix
distCoeffs,
// computed distortion matrix
cv::Mat(),
// optional rectification (none)
cv::Mat(),
// camera matrix to generate undistorted
cv::Size(640,480),
image.size(),
// size of undistorted
// type of output map
map1, map2);
// the x and y mapping functions
mustInitUndistort= false;
// Apply mapping functions
cv::remap(image, undistorted, map1, map2,
cv::INTER_LINEAR); // interpolation type
122 // Set the calibration options
123 // 8radialCoeffEnabled should be true if 8 radial coefficients are required (5 is default)
124 // tangentialParamEnabled should be true if tangeantial distortion is present
125 void CameraCalibrator::setCalibrationFlag(bool radial8CoeffEnabled, bool tangentialParamEnabled) {
// Set the flag used in cv::calibrateCamera()
if (!tangentialParamEnabled) flag += CV_CALIB_ZERO_TANGENT_DIST;
if (radial8CoeffEnabled) flag += CV_CALIB_RATIONAL_MODEL;
findChessboardCorners
Finds the positions of internal corners of the chessboard.C++: bool findChessboardCorners(InputArray image, Size patternSize, OutputArray corners, intflags=CV_CALIB_CB_ADAPTIVE_THRESH+CV_CALIB_CB_NORMALIZE_IMAGE)//如果找到了棋盘内部的角点,会返回true这个时候正好对应绘制角点的patternWasFound
Parametersimage & Source chessboard view. It must be an 8-bit grayscale or color image.patternSize & Number of inner corners per a chessboard row and column ( patternSize= cvSize(points_per_row,points_per_colum) = cvSize(columns,rows) ).corners & Output array of detected corners.flags & Various operation flags that can be zero or a combination of the following values:& CV_CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the imageto black and white, rather than a fixed threshold level (computed from the averageimage brightness).& CV_CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma withequalizeHist() before applying fixed or adaptive thresholding.& CV_CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter,square-like shape) to filter out false quads extracted at the contour retrieval stage.& CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboardcorners, and shortcut the call if none is found. This can drastically speed up the call inthe degenerate condition when no chessboard is observed.
drawChessboardCornersRenders the detected chessboard corners.C++: void drawChessboardCorners(InputOutputArray image, Size patternSize, InputArray corners, boolpatternWasFound)Python: cv2.drawChessboardCorners(image, patternSize, corners, patternWasFound)! NoneC: void cvDrawChessboardCorners(CvArr* image, CvSize patternSize, CvPoint2D32f* corners, intcount, int patternWasFound)Python: cv.DrawChessboardCorners(image, patternSize, corners, patternWasFound)! NoneParametersimage & Destination image. It must be an 8-bit color image.patternSize & Number of inner corners per a chessboard row and column (patternSize =cv::Size(points_per_row,points_per_column)).//注意这里表示的是棋盘的大小,别弄错了corners & Array of detected corners, the output of findChessboardCorners.patternWasFound & Parameter indicating whether the complete board was found or not.The return value of findChessboardCorners() should be passed here.The function draws individual chessboard corners detected either as red circles if the board was not found, or ascolored corners connected with lines if the board was found.
initUndistortRectifyMapComputes the undistortion and rectification transformation map.C++: void initUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs, InputArray R,InputArray newCameraMatrix, Size size, int m1type, OutputArraymap1, OutputArray map2)
Parameters&
cameraMatrix & Input camera matrix A =
cameraMatrix //不用解释了吧 相机的内参矩阵
distCoeffs畸变矩阵 & Input vector of distortion coefficients (k1; k2; p1; p2[; k3[; k4; k5; k6]]) of 4,
5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
R代表的是旋转矩阵
R & Optional rectification transformation in the object space (3x3 matrix). R1 or R2 , computedby stereoRectify() can be passed here. If the matrix is empty, the identity transformationis assumed. In cvInitUndistortMap R assumed to be an identity matrix.
newCameraMatrix & New camera matrix A0 =size & Undistorted image size.m1type & Type of the first output map that can be CV_32FC1 or CV_16SC2 . SeeconvertMaps() for details.map1 & The first output map.//即是 u
map2 & The second output map.//即是 vregion-detail-title
照相机,校正相机生产工艺技术【精编新版】-相机,
region-detail-gallery
用阿里巴巴客户端扫码
手机下单享受额外优惠
region-detail-property
享受会员价、淘宝数据等更多权益
手机下单更便宜
(10件可售)
申请已发出!
已选0件/0.00元
一般情况下:
划线价格:划线的价格可能是商品的销售指导价或该商品的曾经展示过的销售价等,并非原价,仅供参考。
未划线价格:未划线的价格是商品在阿里巴巴中国站上的销售标价,具体的成交价格根据商品参加活动,或因用户使用优惠券等发生变化,最终以订单结算页价格为准。
活动预热状态下:
划线价格:划线的价格是商品在目前活动预热状态下的销售标价,并非原价,具体的成交价可能因用户使用优惠券等发生变化,最终以订单结算页价格为准。
未划线价格:未划线的价格可能是商品即将参加活动的活动价,仅供参考,具体活动时的成交价可能因用户使用优惠券等发生变化,最终以活动是订单结算页价格为准。
*注:前述说明仅当出现价格比较时有效。若商家单独对划线价格进行说明的,以商家的表述为准。
联系卖家:
交易勋章:
交易勋章-A级
供应等级:
在线销售产品金额等级,彰显供应商在线销售服务能力
所在地区:
四川 成都市温江区
@88.com 版权所有

我要回帖

更多关于 数码黑白相机 的文章

 

随机推荐