opencv cannot find feature2d/test/test_detectors_regression.impl.hpp file

When compiling opencv 's cmake, I encountered a problem that the feature2d/test/test_detectors_regression.impl.hpp file could not be found.

Where to find this file first:

find -name test_detectors_regression.impl.hpp
  • 1

Found that this path is in the modules directory under opencv:

opencv/modules/feature2d/test/test_detectors_regression.impl.hpp
  • 1

Why can't I find it, I look at the run command of make:

make VERBOSE=1
  • 1

It is found that the sequence of the -I parameter in the gcc execution command that reports the error does not contain the modules path.

Knowing the problem is simple, the solution is to add this parameter.

I did it by modifying the CMakeLists.txt of the project, the simple and violent kind:

vim opencv/CMakeLists.txt
  • 1

Add on line 567:

include_directories("modules")
  • 1

That's it! !

Related: opencv cannot find feature2d/test/test_detectors_regression.impl.hpp file