mapillary / OpenSfM

Open source Structure-from-Motion pipeline
https://www.opensfm.org/
BSD 2-Clause "Simplified" License
3.38k stars 858 forks source link

ttributeError: 'module' object has no attribute 'Index' #228

Closed Liron-2 closed 6 years ago

Liron-2 commented 6 years ago

Hi,

When I run the command $bin/opensfm_run_all data/berlin/ there is an error:

2017-10-26 17:15:14,535 Extracting ROOT_HAHOG features for image 01.jpg 2017-10-26 17:15:14,535 Extracting ROOT_HAHOG features for image 02.jpg 2017-10-26 17:15:14,535 Extracting ROOT_HAHOG features for image 03.jpg 2017-10-26 17:15:14,700 Found mask to apply for image 01.jpg 2017-10-26 17:15:14,701 Found mask to apply for image 03.jpg 2017-10-26 17:15:14,715 Found mask to apply for image 02.jpg 2017-10-26 17:15:15,733 Found 4791 points in 0.891205072403s 2017-10-26 17:15:15,735 Found 4749 points in 0.895270109177s 2017-10-26 17:15:15,736 Found 4810 points in 0.882534980774s Traceback (most recent call last): File "/home/liron/Documents/carbam/Structure_from_motion/OpenSfM-master/bin/opensfm", line 35, in command.run(args) File "/home/liron/Documents/carbam/Structure_from_motion/OpenSfM-master/opensfm/commands/detect_features.py", line 34, in run p.map(detect, arguments) File "/usr/lib/python2.7/multiprocessing/pool.py", line 251, in map return self.map_async(func, iterable, chunksize).get() File "/usr/lib/python2.7/multiprocessing/pool.py", line 567, in get raise self._value AttributeError: 'module' object has no attribute 'Index'

what is the problem? I couldn't find it.

Thank you

paulinus commented 6 years ago

We have recently updated the way we run parallel tasks. The error you hit seems to be on a previous version. Could you try updating to current master?

Liron-2 commented 6 years ago

Thank you for your answer. I updated the files. I installed loky by $pip install loky, and I still have the same error (but now in loky):

bin/opensfm_run_all data/berlin 2017-10-29 10:01:19,419 Extracting focal lengths for image 01.jpg 2017-10-29 10:01:19,424 Extracting focal lengths for image 02.jpg 2017-10-29 10:01:19,427 Extracting focal lengths for image 03.jpg 2017-10-29 10:01:20,017 Extracting ROOT_HAHOG features for image 01.jpg 2017-10-29 10:01:20,167 Found mask to apply for image 01.jpg 2017-10-29 10:01:20,266 Extracting ROOT_HAHOG features for image 02.jpg 2017-10-29 10:01:20,423 Found mask to apply for image 02.jpg 2017-10-29 10:01:20,523 Extracting ROOT_HAHOG features for image 03.jpg 2017-10-29 10:01:20,677 Found mask to apply for image 03.jpg 2017-10-29 10:01:21,203 Found 4791 points in 0.911629915237s 2017-10-29 10:01:21,417 Found 4810 points in 0.870511054993s 2017-10-29 10:01:21,669 Found 4749 points in 0.873190164566s Traceback (most recent call last): File "/home/liron/Documents/carbam/OpenSfM-master/bin/opensfm", line 34, in command.run(args) File "/home/liron/Documents/carbam/OpenSfM-master/opensfm/commands/detect_features.py", line 29, in run parallel_map(detect, arguments, processes) File "/home/liron/Documents/carbam/OpenSfM-master/opensfm/context.py", line 20, in parallel_map return list(e.map(func, args)) File "/usr/local/lib/python2.7/dist-packages/loky/process_executor.py", line 769, in _chain_from_iterable_of_lists for element in iterable: File "/usr/local/lib/python2.7/dist-packages/loky/_base.py", line 584, in result_iterator yield future.result() File "/usr/local/lib/python2.7/dist-packages/loky/_base.py", line 431, in result return self.get_result() File "/usr/local/lib/python2.7/dist-packages/loky/_base.py", line 382, in get_result raise self._exception AttributeError: 'module' object has no attribute 'Index'

paulinus commented 6 years ago

Thanks for trying. My guess is that there is something wrong with the installed version of OpenCV since Index might be related to OpenCV's FLANN library.

The actual error message is being hidden by the multiprocessing layer. Could you try running on a single process to get a simpler error message? You can do so by setting

processes: 1

in data/berlin/config.yaml.

Liron-2 commented 6 years ago

Thank you. It seems you are right. the error now is :

2017-10-31 11:06:21,134 Extracting focal lengths for image 01.jpg 2017-10-31 11:06:21,168 Extracting focal lengths for image 02.jpg 2017-10-31 11:06:21,180 Extracting focal lengths for image 03.jpg 2017-10-31 11:06:21,621 Extracting ROOT_HAHOG features for image 01.jpg 2017-10-31 11:06:21,782 Found mask to apply for image 01.jpg 2017-10-31 11:06:22,730 Found 4791 points in 0.824751853943s Traceback (most recent call last): File "/home/liron/Documents/carbam/OpenSfM-master/bin/opensfm", line 34, in command.run(args) File "/home/liron/Documents/carbam/OpenSfM-master/opensfm/commands/detect_features.py", line 29, in run parallel_map(detect, arguments, processes) File "/home/liron/Documents/carbam/OpenSfM-master/opensfm/context.py", line 17, in parallel_map return map(func, args) File "/home/liron/Documents/carbam/OpenSfM-master/opensfm/commands/detect_features.py", line 63, in detect index = features.build_flann_index(f_sorted, data.config) File "/home/liron/Documents/carbam/OpenSfM-master/opensfm/features.py", line 299, in build_flann_index flann_Index = cv2.flann.Index if context.OPENCV3 else cv2.flann_Index AttributeError: 'module' object has no attribute 'Index'

Do you know what is the solution for it?

paulinus commented 6 years ago

For some releases of OpenCV version 3, the flann index class was accessible from python in a different way than in OpenCV 2. We have a condition checking for the opencv version because of that.

I've just tested version 3.2 and 3.3 and that is no longer the case. So I'll remove the condition.

paulinus commented 6 years ago

Please check with the lastest master branch. Thanks!