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 []=BuildVrmlMetaModel(NewModelFlag, Fdir, Path, InLinePath, R, T, Scale); |
---|
40 | |
---|
41 | if NewModelFlag |
---|
42 | % open the Path file nad write in the first model inline code |
---|
43 | fp = fopen( Path, 'w'); |
---|
44 | fprintf(fp, '#VRML V2.0 utf8\n'); |
---|
45 | fprintf(fp, 'Transform {\n'); |
---|
46 | fprintf(fp, ' translation %f %f %f\n', T); |
---|
47 | fprintf(fp, ' scale %f %f %f\n', Scale); |
---|
48 | fprintf(fp, ' children [\n'); |
---|
49 | fprintf(fp, ' Transform {\n'); |
---|
50 | fprintf(fp, ' rotation %f %f %f %f\n', R); |
---|
51 | fprintf(fp, ' children [\n'); |
---|
52 | fprintf(fp, ' Inline {\n'); |
---|
53 | fprintf(fp, ' url "%s"\n',InLinePath); |
---|
54 | fprintf(fp, ' }\n'); |
---|
55 | fprintf(fp, ' ]\n'); |
---|
56 | fprintf(fp, ' }\n'); |
---|
57 | fprintf(fp, ' ]\n'); |
---|
58 | fprintf(fp, '}\n'); |
---|
59 | fclose(fp); |
---|
60 | else |
---|
61 | % first read to decide to modify or attach new inline code |
---|
62 | if true % Debug: no delete VRML================== |
---|
63 | fp = fopen( Path, 'r') |
---|
64 | out = 1; |
---|
65 | line = 1; |
---|
66 | while out ~=-1 |
---|
67 | out = fgets(fp); |
---|
68 | if ~isempty( findstr(out,InLinePath)) |
---|
69 | % erase the inline; |
---|
70 | ['sed ' num2str(line-6) ',' num2str(line+3) 'd ' Path '> ' Fdir '/temp.wrl'] |
---|
71 | system(['sed ' num2str(line-8) ',' num2str(line+5) 'd ' Path '> ' Fdir '/temp.wrl']); |
---|
72 | system(['cp ' Fdir '/temp.wrl ' Path]); |
---|
73 | disp('delete old inline'); |
---|
74 | line |
---|
75 | break; |
---|
76 | end |
---|
77 | line = line +1; |
---|
78 | end |
---|
79 | fclose(fp); |
---|
80 | end % ============================================ |
---|
81 | |
---|
82 | % Start add new inline code |
---|
83 | fp = fopen( Path, 'a+'); |
---|
84 | fprintf(fp, 'Transform {\n'); |
---|
85 | fprintf(fp, ' translation %f %f %f\n', T); |
---|
86 | fprintf(fp, ' scale %f %f %f\n', Scale); |
---|
87 | fprintf(fp, ' children [\n'); |
---|
88 | fprintf(fp, ' Transform {\n'); |
---|
89 | fprintf(fp, ' rotation %f %f %f %f\n', R); |
---|
90 | fprintf(fp, ' children [\n'); |
---|
91 | fprintf(fp, ' Inline {\n'); |
---|
92 | fprintf(fp, ' url "%s"\n',InLinePath); |
---|
93 | fprintf(fp, ' }\n'); |
---|
94 | fprintf(fp, ' ]\n'); |
---|
95 | fprintf(fp, ' }\n'); |
---|
96 | fprintf(fp, ' ]\n'); |
---|
97 | fprintf(fp, '}\n'); |
---|
98 | fclose(fp); |
---|
99 | end |
---|