1

OpenCV 3.2.0 seems does not have RTrees library.

But internet is full of examples of cv2.RTrees. I thought maybe be the issue of versions mismatching - maybe version is wrong ? Should it be 3.2.0-dev ?

But on Fedora 24 i cant seem to find this package nor on the internet. All i see that only ubuntu users can install 3.2.0-dev. Am i missing something ?

>>> import cv2
>>> cv2.__version__
'3.2.0'
>>> cv2.RTrees
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'RTrees'
>>> cv2.ml.RTrees
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'RTrees'
Laimonas Sutkus
  • 3,247
  • 2
  • 26
  • 47

1 Answers1

1

Most examples of RTrees you could find before this date on the internet are from versions 2.4.x. This is because as of mid January there was still no wrapper for Python of the RTrees model of OpenCV, as we can see in this question on the OpenCV answers page. Quoting from it (user berak on Jan 12 '17:

unfortunately, this is not possible atm., as of opencv3.2, only SVM and ANN_MLP have correctly wrapped load methods.

(yes, it's a bug)

Searching a bit more it was found that this issue was fixed recently (as pointed out in this question); you can see this functionality was added in this pull request on the OpenCV git.

Therefore, updating to the latest master branch and rebuilding should fix the problem.

Note: Remember to clone the main repository (opencv), which is the one who actually contains the RTrees model, and if you are using it also clone the contrib repository (opencv_contrib). Do checkout the same version on each to avoid compatibility issues.

Bonus: Check this great installation guide for OpenCV, which also provides some additional recommendations like using venv for the installation (it also has guides for other OS).

Community
  • 1
  • 1
DarkCygnus
  • 7,420
  • 4
  • 36
  • 59
  • Cloned https://github.com/opencv/opencv.git https://github.com/opencv/opencv_contrib.git Then did chekout on 3.2.0 version Installed using cmake and make (whatever is written in tutorials) Still cant find the method. – Laimonas Sutkus Jun 23 '17 at 05:17
  • Did you also updated and rebuilt the main repo (not only the "contrib" one)? Remember that the contrib one only has the extra modules (usually not fully supported and experimental). You should be cloning this one also: https://github.com/opencv/opencv . I will update my answer to clarify that, and also share a great link for OpenCV installation I found. – DarkCygnus Jun 23 '17 at 15:12
  • Yes. Thank you. Marked as an answer. – Laimonas Sutkus Jul 09 '17 at 20:51