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

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

Added original make3d

File size: 5.8 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(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
56check = dir([DepthDirectory]);
57if isempty(check)
58   disp('empty')
59end
60%return;
61
62NuPics = size(filename,2);
63load([ScratchDataFolder '/data/MaskGSky.mat']);
64l =1;
65for i= 1:NuPics
66    % in case can't find the laser depth
67    depthfile = strrep(filename{i},'img','depth_sph_corr');
68    check = dir([ScratchDataFolder '/Gridlaserdata/' depthfile '.mat']);
69    if isempty(check)
70       continue;
71    end
72    load([ScratchDataFolder '/Gridlaserdata/' depthfile '.mat']);
73    laserdepth = Position3DGrid(:,:,4);
74    clear Position3DGrid;
75
76    % load learned or predicted depth
77    depthfile = strrep(filename{i},'img','depth_learned');
78    if baseline ==1
79       disp('load baseline')
80       check = dir([DepthDirectory '_baseline/' depthfile '.mat']);
81       if isempty(check)
82          continue;
83       end
84       load([DepthDirectory '_baseline/' depthfile '.mat']);
85       depthMap = depthMap_base;
86    elseif baseline == 2
87       disp('load baseline2')
88       check = dir([DepthDirectory '_baseline2/' depthfile '.mat']);
89       if isempty(check)
90          continue;
91       end
92       load([DepthDirectory '_baseline2/' depthfile '.mat']);
93       depthMap = depthMap_base2;
94    else
95       check = dir([DepthDirectory '/' depthfile '.mat']);
96       if isempty(check)
97          continue;
98       end
99       load([DepthDirectory '/' depthfile '.mat']);
100    end
101
102    i
103    filename{i}   
104    % calculate average abs error RMS error on linear and log scale, and fractional error
105    if SkyExclude == 1
106       disp('Sky Exlude')
107       % remove big error so that it won't effect linear and fractional term
108%       maskBigError = (depthMap >70); % 80+30
109       depthMap(depthMap >80) =80;
110       maskBigError = (laserdepth >7000); % 80+30
111%       maskBigError = (depthMap >Inf); % 80+30
112
113       mask = ~(maskSky{i}|maskBigError);
114       sum(mask(:))
115       AbsLogError=abs( log10(depthMap(:))-log10(laserdepth(:)) );
116       AbsLogError = AbsLogError(mask); % get rid of the sky
117       AbsError=abs( (depthMap(:))-(laserdepth(:)) );
118
119%       mean( abs(depthMap - laserdepth),2)     
120       AbsError = AbsError(mask);
121       AbsFraError = abs( (depthMap(:)-laserdepth(:))./laserdepth(:));
122       AbsFraError = AbsFraError(mask);
123    else
124       AbsLogError=abs( log10(depthMap(:))-log10(laserdepth(:)) );
125       AbsError=abs( (depthMap(:))-(laserdepth(:)) );
126       AbsFraError = abs( (depthMap(:)-laserdepth(:))./laserdepth(:));
127    end
128       
129
130    WholeAbsLogError{l} = AbsLogError;
131    WholeAbsError{l} = AbsError;
132    WholeAbsFraError{l} = AbsFraError;
133    l = l +1;
134
135end
136
137MeanAbsError = mean(cell2mat(WholeAbsError'));
138RMSError = sqrt(mean(cell2mat(WholeAbsError').^2));
139MeanAbsLogError = mean(cell2mat(WholeAbsLogError'));
140RMSLogError = sqrt(mean(cell2mat(WholeAbsLogError').^2));
141MeanAbsFraError = mean(cell2mat(WholeAbsFraError'));
142RMSFraError = sqrt(mean(cell2mat(WholeAbsFraError').^2));
143if detail
144   disp('report detail');
145   save([ScratchDataFolder '/result/DepthErrorReport' DateStamp '.mat'],...
146   'WholeAbsError','WholeAbsLogError','WholeAbsFraError','MeanAbsError','RMSError','MeanAbsLogError','RMSLogError','MeanAbsFraError','RMSFraError');
147end
148
149fid = fopen(ReportName, 'a+');
150fprintf(fid, '%s %g      %g  %g        %g    %g        %g\n %s %d\n', DateStamp,MeanAbsError,RMSError,MeanAbsLogError,RMSLogError,MeanAbsFraError,RMSFraError, DepthDirectory, baseline);
151fclose(fid);
152
153
Note: See TracBrowser for help on using the repository browser.