How to access OpenCV data root directory?
I would like to access
/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_default.xml
from OpenCV distribution, but in a platform-independent way, e.g. in Python
os.path.join(cv2.OPENCV_DATA_DIR, "haarcascades", "haarcascade_frontalface_default.xml")
Can I? How do I get a reliable OPENCV_DATA_DIR
equivalent? My question is basically the same to what this StackOverflow user is asking.
For example, Qt has QCoreApplication::libraryPaths(). The correct paths are determined at compile / install time, so it should be possible to make them available to the user.
imho, this would be a nice addition !
cmake knows the IINSTALL path at compile time, it shouldn't be too difficult, to wire this into the c++ code while building opencv libs.
@berak What about on Windos where the lib can be installed .. anywhere?
hmm, right. if you build opencv locally, it will have an install path too. but for the prebuild binaries, that may be invalid. hmm.
At install time, it could write a line into some config file that some static function then could fetch. It's still a good idea. :)