1. 程式人生 > >matlab標定和三維重建的幾個問題(已解決)

matlab標定和三維重建的幾個問題(已解決)

應用matlab程式做標定和三維重建,為什麼三維重建不行?

問題1:列印的棋盤格的第一行和最後一行寬度不足了,不是30*30mm的正方形方格了;

解決:把標定板的第一行和最後一行去掉。

問題2:在matlab標定的程式裡面指定了方格的大小:

squareSize = 108; % millimeters(我猜應該是每個方格的長度,好像不是面積)

解決:修改為我列印的標定板的方格大小:squareSize = 30

squareSize確實是每個小方格的長度,見http://www.mathworks.cn/cn/help/vision/ug/find-camera-parameters-with-the-camera-calibrator.html


問題3:這一段三維重建的座標需要修改。怎麼改?這個值是什麼的值?

% Reduce the number of colors in the image to 128.
[reducedColorImage, reducedColorMap] = rgb2ind(J1, 128);


% Plot the 3D points of each color.
hFig = figure; hold on;
set(hFig, 'Position', [1 1 840   630]);
hAxes = gca;

問題4:校正前的影象本來視差不大,結果校正後的影象反而出現問題。為什麼?

尋求解決:

1、用原來matlab2013a版的校正程式試一下。

2、我拍攝的左右圖看著極線差不多平行,如果跳過校正這步,直接三維重建看看輸出怎樣?

注意事項:

To properly calibrate your camera, follow these rules:

  • Keep the pattern in focus, but do not use auto-focus.相機不能設成自動調焦!焦距需要保持不變!!!

  • Do not change zoom settings between images, otherwise the focal length changes.拍攝影象不要放大縮小,否則焦距會變!!


For best results, use between 10 and 20 images. The calibrator requires at least three images. For greater calibration accuracy:

  • Take the images of the pattern at a distance roughly equal to the distance from your camera to the objects of interest. For example, if you plan to measure objects of interest at a distance of 2 meters, keep your pattern approximately 2 meters from the camera.把棋盤標定板放在需要量測的距離上。

  • Place the checkerboard at an angle less than 45 degrees relative to the camera plane.棋盤版與相機平面的角度小於45度。

  • Do not modify the images. For example, do not crop them.不要裁剪影象。

  • Do not use auto-focus or change the zoom between images.不要用自動調焦和放大縮小影象。

  • Capture the images of a checkerboard pattern at different orientations relative to the camera.拍攝棋盤版不同的朝向。

  • Capture enough different images of the pattern so that you have covered as much of the image frame as possible. Lens distortion increases radially from the center of the image and sometimes is not uniform across the image frame. To capture this lens distortion, the pattern must appear close to the edges.

問題5:錯誤使用 vision.StereoParameters/reconstructSceneImpl (line 228)

You must call rectifyStereoImages on the stereoParams input before calling reconstructScene.
因為用生成的相機引數stereoParams對影象校正有問題,我嘗試採用matlab2013a的影象校正程式對左右影象進行了校正,把校正後的結果代入2014版的程式中,賦值為J1和J2,然後打算進行三維重建,這時候報錯。也就是說,matlab2014a必須採用rectifyStereoImages函式對左右影象校正之後,才能進行三維重建。