how can i open .out extension file in matlab ?
Show older comments
I'm trying to open a bundle.out file in matlab. Does anyone has any idea of how to do so ?
6 Comments
dpb
on 4 Aug 2014
*fopen*, maybe???
What is the content of the file? One presumes it probably is simply a text file, but how are we to know unless you give us some clues...
per isakson
on 5 Aug 2014
The links I tried return
The page you were looking for doesn't exist.
ba
on 5 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
on 11 Aug 2014
Accepted Answer
More Answers (1)
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
on 5 Aug 2014
ba
on 5 Aug 2014
Edited: Walter Roberson
on 14 Jan 2025
dpb
on 5 Aug 2014
What error(s) did you get?
ba
on 5 Aug 2014
while(true)
No space between the while and the paren's...check the doc's for proper syntax.
I'd write
while true
as the parens are totally superfluous here.
ba
on 5 Aug 2014
Image Analyst
on 6 Aug 2014
Still not acceptable. Very very bad, dangerous code. There's no failsafe! Possibility of getting stuck in infinite loop. You need so pick some number that you know will never be exceeded and check for. Like you know for a fact that if c ever hits 10 or 100 or 1000, something went very wrong.
while c < 10 % Failsafe : quit if c ever gets as high as 10.
c = c + 1
% more code
end
if c >= 10
uiwait(warndlg('Error: did not find whatever.....'));
end
Maybe you think you'll never need it, but you should write code to be robust enough to handle unexpected situations.
dpb
on 6 Aug 2014
Actually, as I had mentioned before, this is the
while ~feof(fid)
loop. Hadn't look at the actual code enough to really tell previously; just fixed the syntax problem. That'll die, eventually, if nothing else does first on a bum file.
I agree the "do forever" loop is generally a bad idea unless that's what's really intended.
dpb
on 8 Aug 2014
Not sure at this point what you're referring to as "first format" and "the other format" but you've given a clue that wasn't there before in the phrase until the line no. is 5 times the no. of cameras. It's that fixed repetition that's the key--once you read the number of cameras, then you have the piece of information to know either how many iterations of a given format or how large an array it is to be read.
ba
on 8 Aug 2014
ba
on 12 Aug 2014
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?
Categories
Find more on Data Import and Export in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!