Skip to content

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

@aleksandrpak

Description

@aleksandrpak

Here is my Cargo.toml:

[package]

name = "rust-haar"
version = "0.0.1"
authors = ["alekspak <alekspak@icloud.com>"]

[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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions