IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.6k stars 4.83k forks source link

I am getting an error while doing face detection with openCV DNN #4623

Closed shiva2410 closed 5 years ago

shiva2410 commented 5 years ago

Required Info
Camera Model { R200 / F200 / SR300 / ZR300 / D400 }
Firmware Version (Open RealSense Viewer --> Click info)
Operating System & Version {Win (8.1/10) / Linux (Ubuntu 14/16/17) / MacOS
Kernel Version (Linux Only) (e.g. 4.14.13)
Platform python.
SDK Version { legacy / 2.<?>.<?> }
Language {C/C#/labview/nodejs/opencv/pcl/python/unity }
Segment {Robot/Smartphone/VR/AR/others }

Issue Description

My code snippet

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()

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)

I am getting this error OpenCV(3.4.2) 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'

Please help its very urgent and important

MartyG-RealSense commented 5 years ago

There was a case on this forum with OpenCV DNN in 2018 that had a very similar error. The link below contains the advice that was given by a member of the support team.

https://github.com/IntelRealSense/librealsense/issues/1604#issuecomment-390071039

jawad-tech commented 5 years ago

I also faced this problem and i solved this problem by

Downloading the .caffemodel and .prototxt file from MobileNet-SSD-master repository. The file name on this repository is different so you will first rename these files according to the files you already have in your build folder. Then replace the downloaded files in your build folder. Hope it helps

RealSenseCustomerSupport commented 5 years ago

Hi @shiva2410,

Do you need any further clarifications regarding this topic?

shiva2410 commented 5 years ago

no

On Tue, Sep 24, 2019 at 6:05 AM RealSense Customer Support < notifications@github.com> wrote:


Hi @shiva2410 https://github.com/shiva2410,

Do you need any further clarifications regarding this topic?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/IntelRealSense/librealsense/issues/4623?email_source=notifications&email_token=AJW4UPNL3XK4P2QB3M7SJVDQLFOFTA5CNFSM4ILD5WK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7MVS4Y#issuecomment-534337907, or mute the thread https://github.com/notifications/unsubscribe-auth/AJW4UPLEFSSSCCX5ZM426NLQLFOFTANCNFSM4ILD5WKQ .