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

FaceDetectorYN.detect throws an error #562

Closed
ghost opened this issue Apr 12, 2024 · 1 comment
Closed

FaceDetectorYN.detect throws an error #562

ghost opened this issue Apr 12, 2024 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 12, 2024

  1. Ubuntu 2204lts
  2. The way you installed OpenCV: package
  3. OpenCV version 454
  4. rustc version 1 76
[ERROR:0] global ./modules/dnn/src/dnn.cpp (3551) getLayerShapesRecursively OPENCV/DNN: [Eltwise]:(252): getMemoryShapes() throws exception. inputs=2 outputs=1/1 blobs=0
[ERROR:0] global ./modules/dnn/src/dnn.cpp (3557) getLayerShapesRecursively     input[0] = [ 1 64 109 160 ]
[ERROR:0] global ./modules/dnn/src/dnn.cpp (3557) getLayerShapesRecursively     input[1] = [ 1 64 108 160 ]
[ERROR:0] global ./modules/dnn/src/dnn.cpp (3561) getLayerShapesRecursively     output[0] = [ 1 64 109 160 ]
[ERROR:0] global ./modules/dnn/src/dnn.cpp (3567) getLayerShapesRecursively Exception message: OpenCV(4.5.4) ./modules/dnn/src/layers/eltwise_layer.cpp:247: error: (-215:Assertion failed) inputs[vecIdx][j] == inputs[i][j] in function 'getMemoryShapes'

thread 'main' panicked at src/main.rs:20:41:
called `Result::unwrap()` on an `Err` value: Error { code: "StsAssert, -215", message: "OpenCV(4.5.4) ./modules/dnn/src/layers/eltwise_layer.cpp:247: error: (-215:Assertion failed) inputs[vecIdx][j] == inputs[i][j] in function 'getMemoryShapes'\n" }
use opencv::{
    core::Size,
    imgcodecs,
    objdetect::FaceDetectorYN,
    prelude::*,
};

fn main() {
    let mut detector = FaceDetectorYN::create_def(
        "./face_detection_yunet_2023mar.onnx",
        "",
        Size::new(100, 100),
    )
    .unwrap();

    let img = imgcodecs::imread("./face.png", imgcodecs::IMREAD_COLOR).unwrap();

    detector.set_input_size(img.size().unwrap()).unwrap();
    let mut faces = Mat::default();
    detector.detect(&img, &mut faces).unwrap();
}

I followed the official tutorial, I took the files from the same place

@twistedfall
Copy link
Owner

twistedfall commented Apr 15, 2024

Please check https://github.com/twistedfall/opencv-rust/blob/master/examples/dnn_face_detect.rs for the port of that example to Rust.

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

1 participant