[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 [ImgInfo]=ExtractGPSInfo(defaultPara,Fdir, ImgInfo) |
---|
| 40 | |
---|
| 41 | % This function extract the GPS information |
---|
| 42 | % ex: Longitude Latitude Altitude (Maybe more in future) |
---|
| 43 | % Then attach the Info on the ImgInfo if applicable |
---|
| 44 | |
---|
| 45 | % initialize file identifier |
---|
| 46 | temp = dir([Fdir '/info/*.ubx']); |
---|
| 47 | fid = fopen([Fdir '/info/' temp.name]); |
---|
| 48 | SumAltitude = 0; |
---|
| 49 | |
---|
| 50 | PriorTime = '0'; |
---|
| 51 | i = 1; |
---|
| 52 | % extract GPS info from .ubx file |
---|
| 53 | while i <= length(ImgInfo) |
---|
| 54 | GPSWorks = true; |
---|
| 55 | TargetTime = ImgInfo(i).ExifInfo.DateTime; |
---|
| 56 | Ptr = strfind(TargetTime,' ')+1; |
---|
| 57 | TargetTime = TargetTime(Ptr:end); |
---|
| 58 | TargetTime = strrep(TargetTime,':',''); |
---|
| 59 | % finding $GPGGA |
---|
| 60 | inline_tmp = []; |
---|
| 61 | while str2num(TargetTime) > str2num(PriorTime) |
---|
| 62 | nline = fgetl(fid); |
---|
| 63 | if nline==-1 |
---|
| 64 | disp('end of file'); |
---|
| 65 | break; |
---|
| 66 | end |
---|
| 67 | if strcmp( nline(1:6), '$GPGGA') |
---|
| 68 | inline_tmp = nline; |
---|
| 69 | PriorTime = nline(8:13); |
---|
| 70 | end |
---|
| 71 | end |
---|
| 72 | nline = inline_tmp; |
---|
| 73 | % locate |
---|
| 74 | Ptr = strfind(nline,','); |
---|
| 75 | % Latitude info in $GPGGA line |
---|
| 76 | ImgInfo(i).Geo.Latitude = str2num( (nline( (Ptr(2)+1): (Ptr(2)+2) ) ) ) + str2num( (nline( (Ptr(2)+3): (Ptr(3)-1) ) ) )/60; |
---|
| 77 | if isempty(ImgInfo(i).Geo.Latitude) |
---|
| 78 | disp('Latitude empty'); |
---|
| 79 | GPSWorks = false; |
---|
| 80 | end |
---|
| 81 | if strcmp( nline(Ptr(3)+1), 'S') |
---|
| 82 | ImgInfo(i).Geo.Latitude = - ImgInfo(i).Geo.Latitude; |
---|
| 83 | end |
---|
| 84 | |
---|
| 85 | % Longitude |
---|
| 86 | ImgInfo(i).Geo.Longitude = str2num(nline( (Ptr(4)+1):(Ptr(4)+3) ))+str2num(nline( (Ptr(4)+4):(Ptr(5)-1)))/60; |
---|
| 87 | if isempty(ImgInfo(i).Geo.Longitude) |
---|
| 88 | disp('Longtitude empty'); |
---|
| 89 | TargetTime |
---|
| 90 | PriorTime |
---|
| 91 | i |
---|
| 92 | ImgInfo(i).ExifInfo.name |
---|
| 93 | GPSWorks = false; |
---|
| 94 | end |
---|
| 95 | if strcmp( nline( Ptr(5)+1 ), 'W') |
---|
| 96 | ImgInfo(i).Geo.Longitude = - ImgInfo(i).Geo.Longitude; |
---|
| 97 | end |
---|
| 98 | |
---|
| 99 | % altitude in meters |
---|
| 100 | ImgInfo(i).Geo.altitude = str2num(nline( (Ptr(9)+1):(Ptr(10)-1) )); |
---|
| 101 | if isempty(ImgInfo(i).Geo.altitude) |
---|
| 102 | disp('altitude empty'); |
---|
| 103 | GPSWorks = false; |
---|
| 104 | end |
---|
| 105 | |
---|
| 106 | % % transform into X Y Z coordinate |
---|
| 107 | % [X] = Polar2Cartesian(defaultPara, ImgInfo(i).Geo.Longitude, ImgInfo(i).Geo.Latitude, ImgInfo(i).Geo.altitude, true); |
---|
| 108 | % ImgInfo(i).X_world = X; |
---|
| 109 | |
---|
| 110 | % move on on other image |
---|
| 111 | SumAltitude = SumAltitude + ImgInfo(i).Geo.altitude; |
---|
| 112 | i = i + 1; |
---|
| 113 | end |
---|
| 114 | SumAltitude = SumAltitude/length(ImgInfo); |
---|
| 115 | |
---|
| 116 | for i = 1:length(ImgInfo) |
---|
| 117 | % Force the same Altitude |
---|
| 118 | ImgInfo(i).Geo.altitude = SumAltitude; |
---|
| 119 | end |
---|
| 120 | |
---|
| 121 | return; |
---|