Ask Your Question
0

I am getting bug while performing open cv based dnn face detection

asked 2019-08-12 13:06:33 -0500

Shiva_2410 gravatar image

updated 2019-08-12 13:35:56 -0500

This is the error am getting I tried converting image to grayscale but it didnt worked please help its very important to me

C:\Miniconda3\conda-bld\opencv-suite_1534379934306\work\modules\dnn\src\layers\convolution_layer.cpp:212: error: (-215:Assertion failed) blobs.size() != 0 in function 'cv::dnn::ConvolutionLayerImpl::getMemoryShapes''

my code

import numpy as np
import argparse
import cv2

print("[INFO] loading model...")
net = cv2.dnn.readNetFromCaffe('pk.prototxt.txt','sd.caffemodel')

image = cv2.imread('f7.jpg')

(h, w) = image.shape[:2]
blob = cv2.dnn.blobFromImage(cv2.resize(image, (300,300)), 1.0,
    (300,300), (104.0, 177.0, 123.0))
net.setInput(blob)
**detections = net.forward()** // here am getting an error

for i in range(0, detections.shape[2]):
    # extract the confidence (i.e., probability) associated with the
    # prediction
    confidence = detections[0, 0, i, 2]

    if confidence > 0.5:
        box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
        (startX, startY, endX, endY) = box.astype("int")
        text = "{:.2f}%".format(confidence * 100)
        y = startY - 10 if startY - 10 > 10 else startY + 10
        cv2.rectangle(image, (startX, startY), (endX, endY),
            (0, 0, 255), 2)
        cv2.putText(image, text, (startX, y),
            cv2.FONT_HERSHEY_SIMPLEX, 0.45, (0, 0, 255), 2)
cv2.imshow("Output", image)
cv2.waitKey(0)

error - C:\Miniconda3\conda-bld\opencv-suite_1534379934306\work\modules\dnn\src\layers\convolution_layer.cpp:212: error: (-215:Assertion failed) blobs.size() != 0 in function 'cv::dnn::ConvolutionLayerImpl::getMemoryShapes'
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-08-12 13:10:26 -0500

berak gravatar image

updated 2019-08-12 13:12:22 -0500

I tried converting image to grayscale

don't do that.

the facedetection network needs color images

edit flag offensive delete link more

Comments

what to do then am not finding any solution I tried all available solutions

Shiva_2410 gravatar imageShiva_2410 ( 2019-08-12 13:13:23 -0500 )edit

solution to what ? using which code ?

please edit your question, and add more detail.

berak gravatar imageberak ( 2019-08-12 13:15:17 -0500 )edit
1

Done please check now

Shiva_2410 gravatar imageShiva_2410 ( 2019-08-12 13:19:39 -0500 )edit

see here: cv2.imread('f7.jpg',cv2.IMREAD_GRAYSCALE)

drop the grayscale flag, and it will read the image as expected, in color ;)

berak gravatar imageberak ( 2019-08-12 13:25:10 -0500 )edit

thnx I tried it but its not working again am getting error

Shiva_2410 gravatar imageShiva_2410 ( 2019-08-12 13:29:04 -0500 )edit

make sure your image is loaded AT ALL

berak gravatar imageberak ( 2019-08-12 13:38:20 -0500 )edit

Ya I even treid with different images and image is in same working directory

Shiva_2410 gravatar imageShiva_2410 ( 2019-08-12 13:41:26 -0500 )edit

don't assume, give a proof it worked.

berak gravatar imageberak ( 2019-08-12 13:44:44 -0500 )edit

It didnt worked am getting an error I tried all methods

Shiva_2410 gravatar imageShiva_2410 ( 2019-08-12 13:46:24 -0500 )edit

I don't know why am getting this error I tried all sort of techniques to reslove this but none worked

Shiva_2410 gravatar imageShiva_2410 ( 2019-08-12 13:47:34 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-08-12 13:06:33 -0500

Seen: 31 times

Last updated: Aug 12