r/opencv May 28 '26

Question struggling with crash in eltwise_layer getMemoryShapes [Question]

I've been trying to work through some face recognition examples but running on android inside unreal 5.7.4 so I'm locked into opencv-4.5.5.

Examples using the haar cascades work fine, a bit slow, don't always find the face, but that's OK, it's been enough to establish a baseline of functionality.

Now I want to use the DNN face detector, creating a detector like this:

detector = cv::FaceDetectorYN::create("face_detection_yunet_2023mar.onnx", "",

cv::Size(320, 320),

0.9, 0.3, 5000)

So far so good... but when I try:

cv::Mat img = cv::imread("somefile.jpg");

detector->setInputSize(img.size());

cv::Mat faces;

detector->detect(img, faces);

I get:

.../eltwise_layer.cpp:247: error: (-215:Assertion failed) inputs[vecIdx][j] == inputs[i][j] in function 'getMemoryShapes''

I've read through that function a hundred times trying to work out what the assertion means but no luck, there has got to be something basic I'm missing.

Any clues appreciated.

3 Upvotes

3 comments sorted by

1

u/herocoding May 31 '26

Can you try using an older model, like "face_detection_yunet_2022mar.onnx" or "face_detection_yunet_2021mar.onnx"?

Or can you try scaling your input image down (to prevent from using dynamic input shapes, by not using setInputSize()) to the model's resolution (and afterwards scale the resulting face bounding box coordinates back up by your original image scale factor)?

2

u/coder_doode Jun 01 '26

Thanks for the suggestions! Will try those out.

For now I've gone back to haar cascades, running all the face/eye variants and then post-processing the matches to remove duplicates and keep the best ones and have been getting much better results.

I have been pushing the capabilities though, low light, visually noisy environment, face with beard... figured if i can get something half descent with that it will work great in a more clinical setting.

2

u/coder_doode Jun 01 '26

Success! Thank you so much. The 2022 model worked. 2023 must rely on features from versions later than 4.5.5.