openvslam icon indicating copy to clipboard operation
openvslam copied to clipboard

why load dbow2 file cast very long time (few minutes) on iphone xs Max?

Open taontech opened this issue 6 years ago • 5 comments

loadFromBinaryFile method cast very long time, I don't know where is the problem .

taontech avatar Aug 12 '19 10:08 taontech

Could you tell me the behavior in detail?

shinsumicco avatar Aug 15 '19 13:08 shinsumicco

If load binary vocabulary is slow, the cause maybe DBoW2's loadFromBinaryFile method in TemplatedVocabulary.h.

You may notice one line: m_nodes.at(n_id).descriptor = cv::Mat(1, F::L, CV_8U); which lies in a while loop. Usually the quantity of words is large. Meanwhile the cv::Mat constructor may trigger reallocate which sometimes can be slow.

The solution is create a sufficiently large cv::Mat outside the loop, and assign one row to m_nodes's descriptor each time accordingly, i.e.

m_nodes.at(n_id).descriptor = yourMat.row(row_index)

riematrix avatar Aug 30 '19 03:08 riematrix

I have the same problem,especially with iOS 13

Dylanooo avatar Nov 27 '19 12:11 Dylanooo

@taontech @riematrix @Dylanooo Thanks for reporting. We'll fix DBoW2 according to the solution provided by @riematrix.

shinsumicco avatar Nov 29 '19 03:11 shinsumicco

I have a PR that fixed this issue for me in case anyone is interested

https://github.com/shinsumicco/DBoW2/pull/8

adelpit avatar Jan 26 '21 07:01 adelpit