Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

objdetect::CascadeClassifier::load fails with OpenCV Error #3

Open
aleksandrpak opened this issue Nov 12, 2014 · 5 comments
Open

objdetect::CascadeClassifier::load fails with OpenCV Error #3

aleksandrpak opened this issue Nov 12, 2014 · 5 comments

Comments

@aleksandrpak
Copy link

Here is my Cargo.toml:

[package]

name = "rust-haar"
version = "0.0.1"
authors = ["alekspak <[email protected]>"]

[dependencies.opencv]
git="https://github.com/woxtu/rust-opencv"

Trying to run following piece of code:

extern crate opencv;

use opencv::objdetect;
use std::path::posix::Path;

fn main() {
    let face_cascade_path = "/Users/alekspak/Projects/rust-haar/cascades/haarcascade_frontalface_alt.xml";
    let face_cascade = load_cascade(face_cascade_path);
}

fn load_cascade(path_string: &str) -> objdetect::CascadeClassifier {
    match objdetect::CascadeClassifier::load(&Path::new(path_string)) {
        Ok(cascade) => cascade,
        Err(error) => panic!("Cannot load cascade file {} with error {}", path_string, error)
    }
}

I receive following error:

OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file /tmp/opencv-s7yTJ5/opencv-2.4.9/modules/core/src/persistence.cpp, line 4991

haarcascade_frontalface_alt.xml file is taken from opencv github repository: https://github.com/Itseez/opencv/blob/master/data/haarcascades/haarcascade_frontalface_alt.xml

And following example is working with exact same file.

opencv is installed using brew. My OS is Mac OS Yosemite 10.10.1.

@jonysy
Copy link
Contributor

jonysy commented Nov 12, 2014

@aleksandrpak I believe that has something to do with the deprecation of the OpenCV C API (which is what rust-opencv uses) so you should load the older xml file using the code you've written.

@jonysy
Copy link
Contributor

jonysy commented Nov 12, 2014

@woxtu OpenCV-Java loads the new haar-cascade files without a problem. Have you worked this out?

@woxtu
Copy link
Owner

woxtu commented Nov 13, 2014

I suppose old format file raises this error, but I don't know the details.

Try to use /usr/local/Cellar/opencv/2.4.9/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml instead. It works well for now.

@vladiim
Copy link

vladiim commented Dec 11, 2014

Thanks @woxtu - that worked for me

@chfakht
Copy link

chfakht commented Jul 25, 2015

Hi , i'm using Ubuntu 14.04 with opencv 2.4.10
i get those errors
OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file /home/chfakht/opencv/opencv-2.4.10/modules/core/src/persistence.cpp, line 4991
terminate called after throwing an instance of 'cv::Exception'
what(): /home/chfakht/opencv/opencv-2.4.10/modules/core/src/persistence.cpp:4991: error: (-2) The node does not represent a user object (unknown type?) in function cvRead
any help ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants