Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

problem with facedetection modell from dnn module

Hello, i am trying to get the face detector caffe model working for a server app. I tries to use this https://docs.opencv.org/master/d5/d86/tutorial_dnn_javascript.html and this https://www.pyimagesearch.com/2018/02/26/face-detection-with-opencv-and-deep-learning/ as a template - but somehow the result from the net is always empty. I made sure the input image exists and contains a face. I am not sure what i am doing wrong, i even made sure the input dimensions for the model (300, 300) are correct.

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/dnn.hpp"
#include <math.h>
#include <iostream>
using namespace cv;
using namespace std;
using namespace dnn;


int main( int argc, char** argv)
{
    Net reconNet = readNetFromCaffe("face_detector.prototxt", "face_detector.caffemodel");     
    Mat img = imread("./arni/arni.jpg");
    //resize to target dimensions
    resize(img, img, Size(300, 300));
    //debugging
    imwrite("arni_resized.jpg", img);

    Mat blob = blobFromImage(img, 1.0, Size(300, 300), Scalar(104.0, 177.0, 123.0), false, false);
    reconNet.setInput(blob);
    Mat result = reconNet.forward().clone();    
    cout << "result from net " << result << endl;        
    return 0;
}

Any hint is highly welcome.

problem with facedetection modell from dnn module

Hello, i am trying to get the face detector caffe model working for a server app. I tries tried to use this https://docs.opencv.org/master/d5/d86/tutorial_dnn_javascript.html and this https://www.pyimagesearch.com/2018/02/26/face-detection-with-opencv-and-deep-learning/ as a template - but somehow the result from the net is always empty. empty (cols and rows are both -1). I made sure the input image exists and contains a face. I am not sure what i am doing wrong, i even made sure the input dimensions for the model (300, 300) are correct.

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/dnn.hpp"
#include <math.h>
#include <iostream>
using namespace cv;
using namespace std;
using namespace dnn;


int main( int argc, char** argv)
{
    Net reconNet = readNetFromCaffe("face_detector.prototxt", "face_detector.caffemodel");     
    Mat img = imread("./arni/arni.jpg");
    //resize to target dimensions
    resize(img, img, Size(300, 300));
    //debugging
    imwrite("arni_resized.jpg", img);

    Mat blob = blobFromImage(img, 1.0, Size(300, 300), Scalar(104.0, 177.0, 123.0), false, false);
    reconNet.setInput(blob);
    Mat result = reconNet.forward().clone();    
    cout << "result from net " << result << endl;        
    return 0;
}

Any hint is highly welcome.

problem with facedetection modell from dnn module

Hello, i am trying to get the face detector caffe model working for a server app. I am using open cv 3.4.1

I tried to use this https://docs.opencv.org/master/d5/d86/tutorial_dnn_javascript.html and this https://www.pyimagesearch.com/2018/02/26/face-detection-with-opencv-and-deep-learning/ as a template - but somehow the result from the net is always empty (cols and rows are both -1). I made sure the input image exists and contains a face. I am not sure what i am doing wrong, i even made sure the input dimensions for the model (300, 300) are correct.

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/dnn.hpp"
#include <math.h>
#include <iostream>
using namespace cv;
using namespace std;
using namespace dnn;


int main( int argc, char** argv)
{
    Net reconNet = readNetFromCaffe("face_detector.prototxt", "face_detector.caffemodel");     
    Mat img = imread("./arni/arni.jpg");
    //resize to target dimensions
    resize(img, img, Size(300, 300));
    //debugging
    imwrite("arni_resized.jpg", img);

    Mat blob = blobFromImage(img, 1.0, Size(300, 300), Scalar(104.0, 177.0, 123.0), false, false);
    reconNet.setInput(blob);
    Mat result = reconNet.forward().clone();    
    cout << "result from net " << result << endl;        
    return 0;
}

Any hint is highly welcome.

click to hide/show revision 4
None

updated 2018-07-05 01:20:33 -0600

berak gravatar image

problem with facedetection modell from dnn module

Hello, i am trying to get the face detector caffe model working for a server app. I am using open cv 3.4.1

I tried to use this https://docs.opencv.org/master/d5/d86/tutorial_dnn_javascript.html and this https://www.pyimagesearch.com/2018/02/26/face-detection-with-opencv-and-deep-learning/ as a template - but somehow the result from the net is always empty (cols and rows are both -1). I made sure the input image exists and contains a face. I am not sure what i am doing wrong, i even made sure the input dimensions for the model (300, 300) are correct.

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/dnn.hpp"
#include <math.h>
#include <iostream>
using namespace cv;
using namespace std;
using namespace dnn;


int main( int argc, char** argv)
{
    Net reconNet = readNetFromCaffe("face_detector.prototxt", "face_detector.caffemodel");     
    Mat img = imread("./arni/arni.jpg");
    //resize to target dimensions
    resize(img, img, Size(300, 300));
    //debugging
    imwrite("arni_resized.jpg", img);

    Mat blob = blobFromImage(img, 1.0, Size(300, 300), Scalar(104.0, 177.0, 123.0), false, false);
    reconNet.setInput(blob);
    Mat result = reconNet.forward().clone();    
    cout << "result from net " << result << endl;        
    return 0;
}

Any hint is highly welcome.