[37] | 1 | % * This code was used in the following articles:
|
---|
| 2 | % * [1] Learning 3-D Scene Structure from a Single Still Image,
|
---|
| 3 | % * Ashutosh Saxena, Min Sun, Andrew Y. Ng,
|
---|
| 4 | % * In ICCV workshop on 3D Representation for Recognition (3dRR-07), 2007.
|
---|
| 5 | % * (best paper)
|
---|
| 6 | % * [2] 3-D Reconstruction from Sparse Views using Monocular Vision,
|
---|
| 7 | % * Ashutosh Saxena, Min Sun, Andrew Y. Ng,
|
---|
| 8 | % * In ICCV workshop on Virtual Representations and Modeling
|
---|
| 9 | % * of Large-scale environments (VRML), 2007.
|
---|
| 10 | % * [3] 3-D Depth Reconstruction from a Single Still Image,
|
---|
| 11 | % * Ashutosh Saxena, Sung H. Chung, Andrew Y. Ng.
|
---|
| 12 | % * International Journal of Computer Vision (IJCV), Aug 2007.
|
---|
| 13 | % * [6] Learning Depth from Single Monocular Images,
|
---|
| 14 | % * Ashutosh Saxena, Sung H. Chung, Andrew Y. Ng.
|
---|
| 15 | % * In Neural Information Processing Systems (NIPS) 18, 2005.
|
---|
| 16 | % *
|
---|
| 17 | % * These articles are available at:
|
---|
| 18 | % * http://make3d.stanford.edu/publications
|
---|
| 19 | % *
|
---|
| 20 | % * We request that you cite the papers [1], [3] and [6] in any of
|
---|
| 21 | % * your reports that uses this code.
|
---|
| 22 | % * Further, if you use the code in image3dstiching/ (multiple image version),
|
---|
| 23 | % * then please cite [2].
|
---|
| 24 | % *
|
---|
| 25 | % * If you use the code in third_party/, then PLEASE CITE and follow the
|
---|
| 26 | % * LICENSE OF THE CORRESPONDING THIRD PARTY CODE.
|
---|
| 27 | % *
|
---|
| 28 | % * Finally, this code is for non-commercial use only. For further
|
---|
| 29 | % * information and to obtain a copy of the license, see
|
---|
| 30 | % *
|
---|
| 31 | % * http://make3d.stanford.edu/publications/code
|
---|
| 32 | % *
|
---|
| 33 | % * Also, the software distributed under the License is distributed on an
|
---|
| 34 | % * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
---|
| 35 | % * express or implied. See the License for the specific language governing
|
---|
| 36 | % * permissions and limitations under the License.
|
---|
| 37 | % *
|
---|
| 38 | % */
|
---|
| 39 | [Matches1 CoeffM1 Inliers1]=CorrolationMatch( defaultPara, Pair, I1, I2, PointPix1(:,Mask1), POriReprojM1(:,Mask1), FieldOccluPix1(:,Mask1), [minRatio maxRatio]); |
---|
| 40 | save([defaultPara.Fdir '/data/' Img1 '_' Img2 '_' PostFixStrAfter 'FirstCorrMatches.mat'],'Matches1','CoeffM1','Inliers1'); |
---|
| 41 | Pair2_1.R = Pair.R'; |
---|
| 42 | Pair2_1.T = -Pair.R'*Pair.T; |
---|
| 43 | [Matches2 CoeffM2 Inliers2]=CorrolationMatch( defaultPara, Pair2_1, I2, I1, PointPix2(:,Mask2), POriReprojM2(:,Mask2), FieldOccluPix2(:,Mask2), [1/maxRatio 1/minRatio]); |
---|
| 44 | save([defaultPara.Fdir '/data/' Img1 '_' Img2 '_' PostFixStrAfter 'SecondCorrMatches.mat'],'Matches2','CoeffM2','Inliers2'); |
---|
| 45 | |
---|
| 46 | if true |
---|
| 47 | if defaultPara.Flag.FlagRefinementDisp |
---|
| 48 | disp('CorrolationMatch.m Finished'); |
---|
| 49 | end |
---|
| 50 | Matches1 = Matches1(:,Inliers1); |
---|
| 51 | Matches2 = Matches2(:,Inliers2); |
---|
| 52 | CoeffM1 = CoeffM1(:,Inliers1); |
---|
| 53 | CoeffM2 = CoeffM2(:,Inliers2); |
---|
| 54 | |
---|
| 55 | % Check if the Matches are not mutual discard the one with less Coeff(Cross-Corrolation value) =============== |
---|
| 56 | Matches = [ Matches1 [Matches2(3:4,:); Matches2(1:2,:)]]; |
---|
| 57 | CoeffM = [ CoeffM1 CoeffM2]; |
---|
| 58 | % Min used different algorithm than SurFeature Matches |
---|
| 59 | [Inliers] = CleanMatch(Matches, CoeffM(1,:)); % choose the matches with higher Coeff is the matches is not mutual |
---|
| 60 | [InliersReverse] = CleanMatch(Matches(:,Inliers), CoeffM(1,Inliers)); % choose the matches with higher Coeff is the matches is not mutual |
---|
| 61 | Inliers = Inliers(InliersReverse); |
---|
| 62 | Matches = Matches(:,Inliers); |
---|
| 63 | CoeffM = CoeffM(:,Inliers); |
---|
| 64 | |
---|
| 65 | if defaultPara.Flag.FlagRefinementDisp |
---|
| 66 | figure; plotmatches(I1,I2,Matches(1:2,:), Matches(3:4,:),repmat(1:size(Matches,2),2,1), 'Stacking','v','Interactive', 3); |
---|
| 67 | end |
---|
| 68 | |
---|
| 69 | % use Coeff as threshould to filter out error matches |
---|
| 70 | CoeffMask = CoeffM(1,:) > defaultPara.CoeffMThre; |
---|
| 71 | [inlier, Residual] = EpipoPrune(defaultPara, Pair, Matches, ImgScale1); |
---|
| 72 | EpipolarResidualMask = Residual < defaultPara.ResidualThre; |
---|
| 73 | CoeffRationMask = CoeffM(2,:)./CoeffM(1,:) < defaultPara.coeffratioThre; |
---|
| 74 | Mark = CoeffMask & CoeffRationMask & EpipolarResidualMask; |
---|
| 75 | % ======================================================================= |
---|
| 76 | if ~isempty(Matches) |
---|
| 77 | tempf1 = Matches(1:2,Mark); |
---|
| 78 | tempf2 = Matches(3:4,Mark); |
---|
| 79 | x_calib = [ inv(defaultPara.InrinsicK1)*[ tempf1; ones(1,size(tempf1,2))];... |
---|
| 80 | inv(defaultPara.InrinsicK2)*[ tempf2; ones(1,size(tempf2,2))]]; |
---|
| 81 | [ lamda1 lamda2 Error] = triangulation( defaultPara, Pair.R, Pair.T, x_calib); |
---|
| 82 | % notice lamda re-scale to local model scale |
---|
| 83 | lamda1 = lamda1./GlobalScale(1); |
---|
| 84 | lamda2 = lamda2./GlobalScale(2); |
---|
| 85 | % Storage the match result for later ReInference |
---|
| 86 | AddMatch2Model(defaultPara, Wrlname, lamda1, Matches(1:2,Mark), ImgInfo1, ImgScale1, Img1Index, Img2Index, PostFixStrAfter, Error); |
---|
| 87 | AddMatch2Model(defaultPara, Wrlname, lamda2, Matches(3:4,Mark), ImgInfo2, ImgScale2, Img2Index, Img1Index, PostFixStrAfter, Error); |
---|
| 88 | save([defaultPara.Fdir '/data/' Img1 '_' Img2 '_' PostFixStrAfter 'TestScript.mat'],'Matches','CoeffM','Error','Mark'); |
---|
| 89 | end |
---|
| 90 | |
---|
| 91 | % Storage the New Matches |
---|
| 92 | if defaultPara.Flag.FlagRefinementDisp |
---|
| 93 | disp('Storaging Occlusion Surf Features Matches'); |
---|
| 94 | end |
---|
| 95 | |
---|
| 96 | end |
---|