Skip to content

Migration OpenCV5

LucQuebec edited this page Jul 5, 2026 · 1 revision

Migration: OpenCV 4.x → 5.0

In OpenCV 5.0, several modules moved from core to opencv_contrib. Since the official Android AAR ships core only, 4.x code that used these will fail to resolve on the 5.0 official AAR.

Moved core → contrib

4.x core 5.0 location APIs
Classic ML ml (contrib) SVM, KNearest, DTrees, Boost, ANN_MLP, RTrees
Haar / HOG xobjdetect (contrib) Haar CascadeClassifier, HOGDescriptor
Graph API gapi (contrib) cv::gapi::*

Core objdetect still has QR + DNN-based detection in 5.0; only the Haar/HOG paths moved to xobjdetect.

Symptoms

  • Unresolved reference / cannot find symbol for org.opencv.ml.*, HOGDescriptor, Haar-based CascadeClassifier.
  • Classifier XML files that no longer load.

Options

  1. Drop the moved features (official AAR only).
  2. Rebuild the SDK with opencv_contrib (slow, CMake/NDK pain).
  3. Use OpenCV Pro — prebuilt core + contrib for 5.0; your ml / Haar / HOG / G-API code resolves again with one Gradle line.

Full guide: docs/migration-opencv5.md.

Clone this wiki locally