how can i open .out extension file in matlab ?

16 views (last 30 days)
I'm trying to open a bundle.out file in matlab. Does anyone has any idea of how to do so ?
  6 Comments
dpb
dpb on 9 Aug 2014
Edited: dpb on 9 Aug 2014
Looks like a link, acts like a link, is a link...excepting no target given. Don't do that in future, please... most confusing at first, then irritating when discover what poster has done.
You can use bold or italic (or both) to emphasize and/or identify items--I tend to use bold for Matlab functions and italics for variables in my postings but that's just my personal convention, no Forum protocol specifically.
ba
ba on 11 Aug 2014
Okay! Will take care of this from next time.

Sign in to comment.

Accepted Answer

dpb
dpb on 8 Aug 2014
line no. 4 to 6 is a 3x3 matrix. how can i read it?
Create a dummy file w/ a 3x3 array...
>> dlmwrite('ba.txt',rand(3)*10,'precision','%12.8e','delimiter',' ')
>> type ba.txt
5.67821641e+00 5.30797553e+00 1.29906208e+00
7.58542896e-01 7.79167230e+00 5.68823661e+00
5.39501187e-01 9.34010684e+00 4.69390641e+00
Read it back...
>> fid=fopen('ba.txt');
>> x=fscanf(fid,'%f',[3,3]).'
x =
5.6782 5.3080 1.2991
0.7585 7.7917 5.6882
0.5395 9.3401 4.6939
>> fid=fclose(fid);
>>
NB: the .' element transpose to order by row since Matlab fills in column order on reading the nine values. You can, of course, also simply read 9 values and reshape and transpose...
As outlined in initial answer, use a combination of textscan and/or fscanf and friends that operate on an open file handle with the rosetta stone of how the file is structured to return the various pieces in sequence using things like your magic number of 5*NumCameras and knowing it's a 3x3 array where appropriate.
It's not really terribly difficult, but is as (I believe it was IA?) mentioned, drudgery initially to work through and get going. Once done, however, if done properly, you should be able to parse any file of the given structure easily.

More Answers (1)

dpb
dpb on 4 Aug 2014
Edited: dpb on 9 Aug 2014
num_cameras num_points [two integers]
f k1 k2 [the focal length, followed by two radial distortion coeffs]
R [a 3x3 matrix representing the camera rotation]
t [a 3-vector describing the camera translation]
position [a 3-vector describing the 3D position of the point]
Well, reading in the camera and position points doesn't appear too difficult; but there are some uncertainties left --
1) I presume perhaps there are num_cameras datasets in the file, maybe?
2) How does one determine the length of this list array?
fid=fopen('yourfile');
n=fscanf(fid,'%d %d'); % the two number values--camera, points-->[n(1) n(2)]
t=cell2mat(textscan(fid,'%f %f %f','headerlines',2)); % camera position???
p=cell2mat(textscan(fid,'%f %f %f')); % point position
Now the question is as above, what need to get to the next group. In general one builds a small snippet for each file section like the above and then place that in a loop for either a counted number of times or while(~feof(fid)) if length is unknown.
  13 Comments
ba
ba on 12 Aug 2014
Can anyone tell me how to project all the points and camera poses in 3D in matlab after reading the bundle.out file?
dpb
dpb on 12 Aug 2014
Don't know what, precisely, project all the points and camera poses in 3D means, but look at
help graph3d
for the list of 3D plotting routines and see if anything there seems to fit the bill.
I've never used any of it, but the camera control sections may be what you're looking for?

Sign in to comment.

Categories

Find more on MATLAB Support Package for IP Cameras in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!