0

I am loading a yml file which has "160470 * 199" points. Its taking more than a minute in my machine. How can I make it fast?

I used the below code to load a yml file.

 Mat sd;
 string Fsd  = "//home//Desktop//YML//sd.yml";
 FileStorage fsDemo1( Fsd, FileStorage::READ);
 fsDemo1["sd"] >> sd;
2
  • This may help. Feb 27, 2013 at 11:10
  • @Krishna Am reading it using FileStorage from opencv. Can you please give me an example?\
    – 2vision2
    Feb 27, 2013 at 11:17

2 Answers 2

0

You can assume that the file read in the FileStorage class of OpenCV is sufficiently well tuned for performance.

What you should be more worried about is, do you really need the niceties of FileStorage. The disadvantage of using this method is that a full grammar YAML/XML parser will be run on your large file. This in my opinion will be far more slower than the time taken to actually read the file from disk.

My advise is that if you are really looking for fast reads from disks and immediate use (no parsing required), I would advise that you store your data in binary files. The advantage of using such files is that the only time spent is in reading the files, you dont have to parse these. You can read a C struct or a C++ class out of them straight away.

However, the downside is that if you do write your data to a binary file, you might face some really irritating errors when you migrate to another machine(different architecture), especially with endianness, or maybe even variable length of int type. But in my view this will be rare, because most people use Intel or Intel compatible processors anyway.

2
  • I would advise at least to be careful when dumping classes as binary data straight away to the file. IMO writing a routine/method to to (de)serialize a binary is far more robust and worth putting this little effort into it. Imagine you add one property to your class, some statistical param regarding the data, anything. Whole binary dump becomes incompatibile, while the binary data associated to the class often would not change. IMO straight (memory) binary dumps should be avoided for non-volatile storage.
    – luk32
    Feb 27, 2013 at 11:41
  • i assumed that 2vision2 had a consistent api which would not change over time.
    – ssb
    Feb 27, 2013 at 14:18
0

Run the Program in Release mode.It will increase the speed of program 5 times.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.