source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/image3dstiching/useful/InitPoseMeas.m @ 37

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

Added original make3d

File size: 3.7 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 [R T] = InitPoseMeas(defaultPara, ImgInfo1, ImgInfo2);
40
41% This function establish the Pose(Rotation, Translation)
42% from the initial measured data (GPS and Compass)
43% Input:
44%       defaultPara - camera intrinsic matrix is used
45%       ImgInfo - all info of image     
46% Return:
47%       R - [R1_2; R2_1] stack rotation matrix of (R1_2) convert local coordinate of image 1 to 2, visa versa
48%       T - [T2; T1] stack translation matrix of (T2) translation under local coordinate of image 2, visa versa
49 
50 % Notice Two Step rotation correctio
51 if ~isfield(ImgInfo1,'Rw') || ~isfield(ImgInfo2,'Rw') || ~isfield(ImgInfo1,'Geo') || ~isfield(ImgInfo2,'Geo')
52        R = [];
53        T = [];
54        return; % retrun empty POSE if no Pre Acquire info
55 end
56 R1_world = Build3DRotationM( ImgInfo1.Rw(2), -ImgInfo1.Rw(1), -ImgInfo1.Rw(3),{'x','y','z'},true)';
57 Rworld_2 = Build3DRotationM( ImgInfo2.Rw(2), -ImgInfo2.Rw(1), -ImgInfo2.Rw(3),{'x','y','z'},true);
58
59 % 1) R and T for 1_2
60 [X1_2]=World2LocalCoord(defaultPara, ImgInfo1.X_world, ImgInfo2.Geo, ImgInfo2.Rw);
61 [X2_2]=World2LocalCoord(defaultPara, ImgInfo2.X_world, ImgInfo2.Geo, ImgInfo2.Rw);
62 T2 = (X1_2 - X2_2);
63 R1_2 = Rworld_2*R1_world;
64%  R1_2_old = Build3DRotationM(-(ImgInfo1.Rw(2)-ImgInfo2.Rw(2)),0,0,{'x','y','z'},true);
65
66 % Important!! permute the entry of T and R according to the image homogeous coordinate
67 T2 = T2([2 1 3]);
68 R1_2 = R1_2(:,[2 1 3]);
69 R1_2 = R1_2([2 1 3],:);
70 
71 % 2) R and T for 2_1
72 [X2_1]=World2LocalCoord(defaultPara, ImgInfo2.X_world, ImgInfo1.Geo, ImgInfo1.Rw);
73 [X1_1]=World2LocalCoord(defaultPara, ImgInfo1.X_world, ImgInfo1.Geo, ImgInfo1.Rw);
74 T1 = (X2_1- X1_1);
75 R2_1 = R1_world'*Rworld_2';
76%  R2_1_old = Build3DRotationM(-(ImgInfo2.Rw(2)-ImgInfo1.Rw(2)),0,0,{'x','y','z'},true);
77
78 % Important!! permute the entry of T and R according to the image homogeous coordinate
79 T1 = T1([2 1 3]);
80 R2_1 = R2_1(:,[2 1 3]);
81 R2_1 = R2_1([2 1 3],:);
82
83 % stack
84 R = [R1_2; R2_1];
85 T = [T2; T1];
86 return;
Note: See TracBrowser for help on using the repository browser.