无法解决cv.getOptimalNewCameraMatrix名称。

5视图(30天)
我不解决这个问题。我试图解决在许多方面。请人帮助我。
我发现这个问题:
无法解决cv.getOptimalNewCameraMatrix名称。
错误undistortion > undistorb_images(第92行)
[newcameramtx, roi] =简历。getOptimalNewCameraMatrix (camera_matrix dist,(宽度、高度),0,
(宽度、高度));
undistortion误差(1号线)
undistorb_images ([] []);
undistorb_images ([] []);
函数[tvec, rvec camera_matrix dist] = read_wp2c (input_name)
% input_name =“output_wp2camera.json”;
生= fileread (input_name);
input_params = jsondecode(生);
camera_matrix = input_params.camera_matrix;
dist = input_params.dist_coefs;
tvec_json = input_params.translational_vectors;
% tvec = struct2cell (tvec_json);
rvec_json = input_params.rotational_vectors;
% rvec = struct2cell (rvec_json);
tvec = [];
rvec = [];
len =长度(tvec_json);
我= 1:兰
% tvec。追加(数组(tvec_json(图片+字符串(i))))
% tvec.append.tvec_json(我);
tvec = struct2cell (tvec_json (i));
% ({}):
% tvec.append (input_params.translational_vectors.image0);
% rvec。追加(数组(rvec_json(图片+字符串(i))));
rvec = struct2cell (rvec_json (i));
结束
结束
函数undistorb_images (inputParams,结果)
%如果结果是没有:
如果isempty(结果)
input_name =“output_wp2camera.json”;
[tvec, rvec camera_matrix dist] = read_wp2c (input_name);
其他的
(4)tvec =结果;
(3)rvec =结果;
(1)camera_matrix =结果;
(2)dist =结果;
结束
如果isempty (inputParams)
image_path =“图片”;
其他的
image_path = inputParams.opencv_storage.settings.Images_Folder;
结束
% image_files = [];
文件= [dir (fullfile (image_path,‘* . jpg”));dir (fullfile (image_path,‘* . png”));dir (fullfile (image_path,‘* . jpeg‘));dir (fullfile (image_path,‘* . png”)));
文件% = dir (fullfile (image_path *。(jpg | png)));
L =长度(文件);
% kk = 0;
% i = 1: L
%的文件(我). name =文件;
% image_files = (image_files、文件)
%
%
%结束
% disp (image_files)
% f = dir (image_path)
% % ext = image_path(分裂(低(f)));
% % disp (f)
% %如果f.endsWith ([jpg, jpeg, png, " . png "])
% % image_files.append (f);
% %结束
%结束
image_file_name = [];
如果~ isempty(文件)
i = 1: L
文件(i) . name =文件;
image_file_name = (image_file_name、文件);
% disp (image_file_name)
形象= imread (image_path +“\”+文件);
% disp(图片);
% (imagePoints boardSize] = detectCheckerboardPoints (image_file_name);
% squareSize = 29;
% worldPoints = generateCheckerboardPoints (boardSize squareSize);
%
% I = readimage(图1);
%图象尺寸=[(我,1),大小(我,2)];
~ % (params, estimationErrors] = estimateCameraParameters (imagePoinsts worldPoints,图象尺寸);
尺寸(高度、宽度)=(图片);
% disp字符串(字符串(高度)+ " " +(宽度))
% [newCameraMatrix w] =简历。getOptimalNewCameraMatrix (cameraMatrix dist,(宽度、高度));
[newcameramtx, roi] =简历。getOptimalNewCameraMatrix (camera_matrix dist,(宽度、高度),0,(宽度、高度));
% dst = cv2。undistort(图片、camera_matrix dist、没有newcameramtx)
% imageFileNames{我}= fullfile (matlabroot,“工具箱”,“愿景”、“visiondata”,“校准”,“摄像头”,image_file_name);
~ % [imagePoints, imagesUsed] = detectCheckerboardPoints (imageFileNames, PartialDetections,假);
% imageFileNames = imageFileNames (imagesUsed);
% i = 1:元素个数(imageFileNames)
我% I = imread (imageFileNames {});
%次要情节(2,2,我);
% imshow(我);
%等;
%的阴谋(imagePoints(:, 1,我),imagePoints(:, 2,我),“罗”);
%结束
[mapx, mapy] =简历。在itUndistortRectifyMap(camera_matrix, dist, None, newcameramtx, [width,height], 5);
dst =简历。重新映射(图像、mapx mapy INTER_LINEAR);
x, y, w h = roi;
dst = dst (y, y + h x: x + w);
尺寸(高度、宽度)= (dst);
打印(string(高度)+”“+字符串(宽度));
imwrite (“undistortion /”+文件,dst);
结束
结束
结束

答案(0)

类别

找到更多的在读、写和修改图像帮助中心文件交换

下载188bet金宝搏


释放

R2021a

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!