[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 | function [maskGvec, maskSkyvec]=gen_predicted_GS(TrainSet,HistFeaType,HistFeaDate,AbsFeaType,AbsFeaDate) |
---|
| 40 | |
---|
| 41 | global 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 | statusFilename = [ClusterExecutionDirectory '/matlabExecutionStatus_depth.txt']; |
---|
| 46 | NuPics = size(filename,2); |
---|
| 47 | NuBatch = ceil(NuPics/batchSize); |
---|
| 48 | NuRow = NuRow_default; |
---|
| 49 | %Horizon = Horizon_default; |
---|
| 50 | %skyBottom = floor(NuRow/2); |
---|
| 51 | batchRow = 1:WeiBatchSize:NuRow; |
---|
| 52 | %GassuianRegularization = true; |
---|
| 53 | %RegularWei = 0.01; |
---|
| 54 | |
---|
| 55 | load([ScratchDataFolder '/data/FeatureSuperpixel.mat']); % load the feature relate to position and shape of superpixel |
---|
| 56 | %load([ScratchDataFolder '/data/MaskGSky.mat']); % maskg is the estimated ground maskSky is the estimated sky |
---|
| 57 | % load estimated sky |
---|
| 58 | for j = 1:NuBatch |
---|
| 59 | tic |
---|
| 60 | load([ScratchDataFolder '/data/feature_Abs_' AbsFeaType int2str(j) '_' AbsFeaDate '.mat']); % 'f' |
---|
| 61 | %toc |
---|
| 62 | %for k = trainIndex{j} |
---|
| 63 | for k = 1:size(f,2)%batchSize |
---|
| 64 | |
---|
| 65 | %================== |
---|
| 66 | % load picsinfo just for the horizontal value |
---|
| 67 | PicsinfoName = strrep(filename{(j-1)*batchSize+k},'img','picsinfo'); |
---|
| 68 | temp = dir([GeneralDataFolder '/PicsInfo/' PicsinfoName '.mat']); |
---|
| 69 | if size(temp,1) == 0 |
---|
| 70 | a = a_default; |
---|
| 71 | b = b_default; |
---|
| 72 | Ox = Ox_default; |
---|
| 73 | Oy = Oy_default; |
---|
| 74 | Horizon = Horizon_default; |
---|
| 75 | else |
---|
| 76 | load([GeneralDataFolder '/PicsInfo/' PicsinfoName '.mat']); |
---|
| 77 | end |
---|
| 78 | |
---|
| 79 | %RowTop=1; |
---|
| 80 | %RowBottom=VertYNuDepth; |
---|
| 81 | maskGvec=[]; |
---|
| 82 | maskSkyvec=[]; |
---|
| 83 | |
---|
| 84 | for WeiBatchNumber = 1:floor(NuRow/WeiBatchSize) |
---|
| 85 | count=1; |
---|
| 86 | for i = batchRow(WeiBatchNumber):min(batchRow(WeiBatchNumber)+WeiBatchSize-1,NuRow) |
---|
| 87 | %i=RowNumber; |
---|
| 88 | % constructing features for each batch of rows from batch featuresa |
---|
| 89 | %l |
---|
| 90 | RowskyBottom = ceil(NuRow/2); |
---|
| 91 | PatchSkyBottom = ceil(VertYNuDepth*(1-Horizon)); |
---|
| 92 | if i <= RowskyBottom |
---|
| 93 | PatchRowRatio = PatchSkyBottom/RowskyBottom; |
---|
| 94 | RowTop = ceil((i-1)*PatchRowRatio+1); |
---|
| 95 | RowBottom = ceil(i*PatchRowRatio); |
---|
| 96 | else |
---|
| 97 | PatchRowRatio = (VertYNuDepth-PatchSkyBottom)/(NuRow-RowskyBottom); |
---|
| 98 | RowTop = ceil((i-RowskyBottom-1)*PatchRowRatio+1)+PatchSkyBottom; |
---|
| 99 | RowBottom = ceil((i-RowskyBottom)*PatchRowRatio)+PatchSkyBottom; |
---|
| 100 | end |
---|
| 101 | ColumnLeft = 1; |
---|
| 102 | ColumnRight = HoriXNuDepth; |
---|
| 103 | |
---|
| 104 | FeaVector = genFeaVector(f{k},FeatureSuperpixel{(j-1)*batchSize+k},... |
---|
| 105 | [RowTop:RowBottom],[ColumnLeft:ColumnRight],(j-1)*batchSize+k,0); %Notice LearnNear is 0; |
---|
| 106 | load([ScratchDataFolder '/../learned_parameter/GrndSkyTheta_' TrainSet '_WeiBatNu' ... |
---|
| 107 | num2str(WeiBatchNumber) '_' AbsFeaType '_AbsFeaDate' AbsFeaDate '_LearnDate.mat']);%TestDisp.mat']); |
---|
| 108 | %FeaWei = []; |
---|
| 109 | % DepthVector = []; |
---|
| 110 | fid = fopen(statusFilename, 'w+'); |
---|
| 111 | fprintf(fid, 'Currently on row number %i\n', i); |
---|
| 112 | fclose(fid); %file opening and closing has to be inside the loop, otherwise the file will not appear over afs |
---|
| 113 | disp(['Going to Run Step 9, WeiBatchNumber = ' num2str(WeiBatchNumber) ' i=' num2str(i) ' j=' num2str(j) ' k=' num2str(k)]); |
---|
| 114 | %thetaG |
---|
| 115 | %thetaS |
---|
| 116 | %pause |
---|
| 117 | %size(FeaVector) |
---|
| 118 | % if (WeiBatchNumber == 4 && count == 5) |
---|
| 119 | % size(thetaG{count-1}) |
---|
| 120 | % size(thetaS{count-1}) |
---|
| 121 | % %pause |
---|
| 122 | % ab=thetaG{count-1}'; |
---|
| 123 | % cd=thetaS{count-1}'; |
---|
| 124 | % else |
---|
| 125 | %size(thetaG{count})% |
---|
| 126 | %size(thetaS{count}) |
---|
| 127 | %pause |
---|
| 128 | ab=thetaG{count}'; |
---|
| 129 | cd=thetaS{count}'; |
---|
| 130 | % end |
---|
| 131 | maskGvec=[maskGvec; ab*[ones(1,305); FeaVector]]; |
---|
| 132 | maskSkyvec=[maskSkyvec; cd*[ones(1,305); FeaVector]]; |
---|
| 133 | count=count+1; |
---|
| 134 | end |
---|
| 135 | end |
---|
| 136 | picNumber=(j-1)*batchSize+k; |
---|
| 137 | maskgD{picNumber}=maskGvec; |
---|
| 138 | maskSkyD{picNumber}=maskSkyvec; |
---|
| 139 | maskg{picNumber}=(1./(1+exp(-maskGvec)))>0.5; |
---|
| 140 | maskSky{picNumber}=(1./(1+exp(-maskSkyvec)))>0.5; |
---|
| 141 | save([ScratchDataFolder '/data/MaskGSky.mat'],'maskg','maskSky','maskgD','maskSkyD'); |
---|
| 142 | disp(['done ... uff for ' num2str(picNumber)]); |
---|
| 143 | %pause; |
---|
| 144 | end |
---|
| 145 | clear f newFea;% Position3DGrid; |
---|
| 146 | toc |
---|
| 147 | end |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | |
---|