you’re getting OpenCV v2.4.9 or something close to that. Absolutely nobody should be using that anymore. any source code you find these days will be written for OpenCV v4.x or v3.x, and it will have trouble compiling against such an old version. the APIs are much improved now.
you should either get a fresher source of packages, or consider building OpenCV yourself from source.
The version of my OpenCV is v2.4.9. I do know that it is a very old version, but the code which had the error using #include <opencv2/core.hpp> , so I think it is using OpenCV v2.x.
And also it has a problem that is the core.hpp in my opencv 2 is located at opencv2/core/core.hpp , so I changed it to #include <opencv2/core/core.hpp> , otherwise it cannot find the location.
The reason why I used sudo apt install libopencv-dev to install OpenCv is followed the Kinect official instruction, but they only tested in ubuntu 18.04. So I wonder whether the version of OpenCV is installed different by this command in ubuntu 18.04 and ubuntu 16.04?
Maybe I need to try build OpenCV from source, but before that, I need to know the correct version.
Sorry for not provide more clear information before, do you have any ideas about which version I need to build from the source? Thanks again!