source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/LearningCode/DataProcess/Depth_error_CMU.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 5.3 KB
Line 
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% */
39function []=Depth_error_CMU(DepthDirectory, SkyExclude, detail,baseline)
40
41global GeneralDataFolder ScratchDataFolder LocalFolder ClusterExecutionDirectory...
42    ImgFolder VertYNuPatch VertYNuDepth HoriXNuPatch HoriXNuDepth a_default b_default Ox_default Oy_default...
43    Horizon_default filename batchSize NuRow_default SegVertYSize SegHoriXSize WeiBatchSize PopUpVertY PopUpHoriX taskName;
44
45% prepare report
46ReportName = [ScratchDataFolder '/result/DepthErrorTable.txt' ];
47check = dir(ReportName)
48DateStamp = date;
49if isempty(check)
50   disp('is empty')
51   fid = fopen(ReportName, 'w+');
52   fprintf(fid, '%s %s %s %s %s %s %s\n', DateStamp,'MeanAbsError','RMSError','MeanAbsLogError','RMSLogError','MeanAbsFraError','RMSFraError');
53   fclose(fid);
54end
55DepthDirectory
56%return;
57
58% ======================= load Rajiv's .mat file
59load([ScratchDataFolder '/data/distError' ImgFolder '.mat']);
60MeanOffSet = mean(offset);
61%CMUdepthNormalized=exp(offset)*CMUdepth;
62% ============================================
63
64NuPics = size(filename,2);
65load([ScratchDataFolder '/data/MaskGSky.mat']);
66l =1;
67for i= 1:NuPics
68    i
69    % in case can't find the laser depth
70    depthfile = strrep(filename{i},'img','depth_sph_corr');
71    check = dir([ScratchDataFolder '/Gridlaserdata/' depthfile '.mat']);
72    if isempty(check)
73       continue;
74    end
75    load([ScratchDataFolder '/Gridlaserdata/' depthfile '.mat']);
76    laserdepth = Position3DGrid(:,:,4);
77    clear Position3DGrid;
78
79    % load learned or predicted depth
80    depthMap = CMUdepth{i}*exp(MeanOffSet);
81 
82    filename{i}   
83    % calculate average abs error RMS error on linear and log scale, and fractional error
84    if SkyExclude == 1
85       disp('Sky Exlude')
86       % remove big error so that it won't effect linear and fractional term
87%       maskBigError = ((depthMap >1000) | (~useMask{i})) | (depthMap <=1); % 80+30
88       maskBigError = ((depthMap >1000) ) | (depthMap <=1); % 80+30
89%       maskBigError = (depthMap >Inf); % 80+30
90
91       mask = ~(maskSky{i}|maskBigError);
92       sum(mask(:))
93%       any(isinf(log10(depthMap(:))))
94%       any(isinf(log10(laserdepth(:))))
95       AbsLogError=abs( log10(depthMap(:))-log10(laserdepth(:)) );
96       AbsLogError = AbsLogError(mask); % get rid of the sky
97       AbsError=abs( (depthMap(:))-(laserdepth(:)) );
98       AbsError = AbsError(mask);
99       AbsFraError = abs( (depthMap(:)-laserdepth(:))./laserdepth(:));
100       AbsFraError = AbsFraError(mask);
101    else
102       AbsLogError=abs( log10(depthMap(:))-log10(laserdepth(:)) );
103       AbsError=abs( (depthMap(:))-(laserdepth(:)) );
104       AbsFraError = abs( (depthMap(:)-laserdepth(:))./laserdepth(:));
105    end
106       
107
108    WholeAbsLogError{l} = AbsLogError;
109    WholeAbsError{l} = AbsError;
110    WholeAbsFraError{l} = AbsFraError;
111    l = l +1;
112
113end
114
115MeanAbsError = mean(cell2mat(WholeAbsError'));
116RMSError = sqrt(mean(cell2mat(WholeAbsError').^2));
117MeanAbsLogError = mean(cell2mat(WholeAbsLogError'));
118RMSLogError = sqrt(mean(cell2mat(WholeAbsLogError').^2));
119MeanAbsFraError = mean(cell2mat(WholeAbsFraError'));
120RMSFraError = sqrt(mean(cell2mat(WholeAbsFraError').^2));
121if detail
122   disp('report detail');
123   save([ScratchDataFolder '/result/DepthErrorReport' DateStamp '.mat'],...
124   'WholeAbsError','WholeAbsLogError','WholeAbsFraError','MeanAbsError','RMSError','MeanAbsLogError','RMSLogError','MeanAbsFraError','RMSFraError');
125end
126
127fid = fopen(ReportName, 'a+');
128fprintf(fid, '%s %g      %g  %g        %g    %g        %g\n %s %d\n', DateStamp,MeanAbsError,RMSError,MeanAbsLogError,RMSLogError,MeanAbsFraError,RMSFraError, 'CMU', baseline);
129fclose(fid);
130
131
Note: See TracBrowser for help on using the repository browser.