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 [ Rc1_2 ConS1_2 RoughConS1_2 tempConS1_2] = EndPoint2BoxConS(defaultPara, H, V, x1_2Max, x1_2Min, ExpandAlongEpipoLineFlag) |
---|
40 | |
---|
41 | % [ Rc1_2 ConS1_2 RoughConS1_2] = EndPoint2BoxConS(defaultPara, H, V, x1_2Max, x1_2Min) |
---|
42 | % data structure |
---|
43 | % Rc1_2 - 4 by Num of x1_2Max = size(x1_2Max,2) |
---|
44 | |
---|
45 | Ratio2RegularMatches = 0.1; |
---|
46 | ExpandRatio = 1.25; |
---|
47 | |
---|
48 | % if ExpandAlongEpipoLineFlag == 1 |
---|
49 | % expand the search space along the epipolar line |
---|
50 | if ExpandAlongEpipoLineFlag |
---|
51 | UnitVector = x1_2Max - x1_2Min; |
---|
52 | Len = norm(UnitVector); |
---|
53 | UnitVector = UnitVector/Len; |
---|
54 | Center = (x1_2Max + x1_2Min)/2; |
---|
55 | % Calculate new x1_2Max and x1_2Min |
---|
56 | x1_2Max = Center + UnitVector*(Len/2)*ExpandRatio; |
---|
57 | x1_2Min = Center - UnitVector*(Len/2)*ExpandRatio; |
---|
58 | end |
---|
59 | |
---|
60 | % used the same concept in ../match/CalMatchSearchRegin.m |
---|
61 | |
---|
62 | tRAN = x1_2Max - x1_2Min; |
---|
63 | |
---|
64 | Ptr = tRAN(1,:) < 0; |
---|
65 | %theta_z = -atan(tRAN(2,:)./tRAN(1,:)); |
---|
66 | theta_z = atan(tRAN(2,:)./tRAN(1,:)); |
---|
67 | theta_z(Ptr) = theta_z(Ptr)+pi; |
---|
68 | Rc1_2 = [cos(-theta_z); -sin(-theta_z); sin(-theta_z); cos(-theta_z)]; |
---|
69 | ConS1_2(1:2,:) = x1_2Min; |
---|
70 | ConS1_2(3,:) = sum( Rc1_2(1:2,:).*tRAN,1);% also may check sum( Rc1_2(3:4,:).*tRAN,1) close up to zeros to verify correct or not |
---|
71 | % Re1_2 = sum( Rc1_2(3:4,:).*tRAN,1) |
---|
72 | |
---|
73 | ConS1_2(4,:) = defaultPara.VertVar*max(H,V)*Ratio2RegularMatches; |
---|
74 | % [x_origon; y_origin; x_bound, y_bound(defaultPara.VertVar*max(H,V))] |
---|
75 | |
---|
76 | % generate plot point |
---|
77 | tempConS1_2 = [ ConS1_2(3,:); ConS1_2(4,:); ... |
---|
78 | zeros(1,size(ConS1_2,2)); ConS1_2(4,:);... |
---|
79 | zeros(1,size(ConS1_2,2)); -ConS1_2(4,:);... |
---|
80 | ConS1_2(3,:); -ConS1_2(4,:)]; |
---|
81 | %Rc1_2_transpose = [cos(theta_z); sin(theta_z); -sin(theta_z); cos(theta_z)]; |
---|
82 | Rc1_2_transpose = [cos(theta_z); -sin(theta_z); sin(theta_z); cos(theta_z)]; |
---|
83 | tempConS1_2(1:2,:) = [sum( Rc1_2_transpose(1:2,:).*tempConS1_2(1:2,:), 1); ... |
---|
84 | sum( Rc1_2_transpose(3:4,:).*tempConS1_2(1:2,:), 1)]; |
---|
85 | tempConS1_2(3:4,:) = [sum( Rc1_2_transpose(1:2,:).*tempConS1_2(3:4,:), 1); ... |
---|
86 | sum( Rc1_2_transpose(3:4,:).*tempConS1_2(3:4,:), 1)]; |
---|
87 | tempConS1_2(5:6,:) = [sum( Rc1_2_transpose(1:2,:).*tempConS1_2(5:6,:), 1); ... |
---|
88 | sum( Rc1_2_transpose(3:4,:).*tempConS1_2(5:6,:), 1)]; |
---|
89 | tempConS1_2(7:8,:) = [sum( Rc1_2_transpose(1:2,:).*tempConS1_2(7:8,:), 1); ... |
---|
90 | sum( Rc1_2_transpose(3:4,:).*tempConS1_2(7:8,:), 1)]; |
---|
91 | tempConS1_2 = tempConS1_2 + repmat( x1_2Min, 4, 1); |
---|
92 | RoughConS1_2 = [ min( tempConS1_2([ 1 3 5 7],:), [], 1); max( tempConS1_2([ 1 3 5 7],:), [], 1);... |
---|
93 | min( tempConS1_2([ 2 4 6 8],:), [], 1); max( tempConS1_2([ 2 4 6 8],:), [], 1)]; |
---|
94 | |
---|
95 | % check if tRAN is zero |
---|
96 | MaskZeros = tRAN(1,:) == 0; |
---|
97 | Rc1_2(:, MaskZeros) = 0; |
---|
98 | ConS1_2(:,MaskZeros) = 0; |
---|
99 | RoughConS1_2(:,MaskZeros) = -1; |
---|
100 | return; |
---|