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

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

Added original make3d

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