AttributeError: 'module' object has no attribute 'xfeatures2d' [python/opencv 3.1.0 dev]

By : Glachas

To resolve this error I tried to add extra module opencv-contrib-master from I followed the steps given in the file but while running 'make' I am getting the following output:

[  4%] Built target libwebp
[  4%] Built target opencv_core_pch_dephelp
[  4%] Built target pch_Generate_opencv_core
Scanning dependencies of target opencv_core
[  4%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.o
Linking CXX shared library ../../lib/
[  7%] Built target opencv_core
[  7%] Built target opencv_ts_pch_dephelp
[  7%] Built target pch_Generate_opencv_ts
[  7%] Built target opencv_imgproc_pch_dephelp
[  8%] Built target pch_Generate_opencv_imgproc
Linking CXX shared library ../../lib/
[ 11%] Built target opencv_imgproc
[ 11%] Built target opencv_imgcodecs_pch_dephelp
[ 11%] Built target pch_Generate_opencv_imgcodecs
Linking CXX shared library ../../lib/
[ 12%] Built target opencv_imgcodecs
[ 12%] Built target opencv_videoio_pch_dephelp
[ 12%] Built target pch_Generate_opencv_videoio
Linking CXX shared library ../../lib/
[ 13%] Built target opencv_videoio
[ 13%] Built target opencv_highgui_pch_dephelp
[ 13%] Built target pch_Generate_opencv_highgui
Linking CXX shared library ../../lib/
[ 14%] Built target opencv_highgui
[ 14%] Built target opencv_ts
[ 14%] Built target opencv_perf_core_pch_dephelp
[ 14%] Built target pch_Generate_opencv_perf_core
Linking CXX executable ../../bin/opencv_perf_core
[ 16%] Built target opencv_perf_core
[ 16%] Built target opencv_test_core_pch_dephelp
[ 16%] Generating test_precomp.hpp.gch/opencv_test_core_RELEASE.gch
In file included from <command-line>:0:0:
/usr/include/stdc-predef.h:1:0: fatal error: can’t create precompiled header /home/chandu/Opencv/opencv/release/modules/core/test_precomp.hpp.gch/opencv_test_core_RELEASE.gch: Permission denied
 /* Copyright (C) 1991-2014 Free Software Foundation, Inc.
  compilation terminated.
  Preprocessed source stored into /tmp/cchn5Yvk.out file, please attach this to your bugreport.
 ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/_usr_lib_gcc_x86_64-linux-gnu_4.9_cc1plus.1000.crash'
 make[2]: *** [modules/core/test_precomp.hpp.gch/opencv_test_core_RELEASE.gch] Error 1
 make[1]: *** [modules/core/CMakeFiles/pch_Generate_opencv_test_core.dir/all] Error 2
 make: *** [all] Error 2

Somewhere it was told that there may be problem in gcc version but I updated gcc version but no success. I am using gcc of version 4.9.4 and ubuntu of version 14.04.1. Before 'make' step I ran:


I approached many resources but no results. Any kind of help is appreciable.

By : Glachas


Did you tried prepending the command with sudo?

The problem is that xfeatures2d was not being exported from opencv-contrib module. So, when I was running 'make' command it was not able to add that module to opencv build module. I ran the following command followed by make command:

 export xfeatures2d=/path/to/opencv_contrib/modules/ 

It worked for me.

By : Glachas

This video can help you solving your question :)
By: admin