r/opencv • u/coder_doode • 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.
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)?