ok, it won't answer your question, but at least you could start playing with the dnn code by downloading vanillaCNN.caffemodel and vanilla_deploy.prototxt from https://github.com/ishay2b/VanillaCNN... , and modify the caffe_googlenet.cpp sample from the dnn module, like this:
#include <opencv2/dnn.hpp>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace cv::dnn;
using namespace std;
int main(int argc, char **argv)
{
cv::dnn::initModule(); //Required if OpenCV is built as static libs
String modelTxt = "vanilla_deplay.prototxt";
String modelBin = "vanillaCNN.caffemodel";
String imageFile = (argc > 1) ? argv[1] : "face.png";
Net net = dnn::readNetFromCaffe(modelTxt, modelBin);
if (net.empty())
{
std::cerr << "Can't load network by using the following files: " << std::endl;
std::cerr << "prototxt: " << modelTxt << std::endl;
std::cerr << "caffemodel: " << modelBin << std::endl;
exit(-1);
}
Mat img = imread(imageFile);
if (img.empty())
{
std::cerr << "Can't read image from the file: " << imageFile << std::endl;
exit(-1);
}
resize(img, img, Size(40,40)); // size of input (data) layer
cv::cvtColor(img, img, cv::COLOR_BGR2RGB);
dnn::Blob inputBlob = dnn::Blob::fromImages(img); //Convert Mat to dnn::Blob batch of images
net.setBlob(".data", inputBlob); //set the network input
net.forward(); //compute output
dnn::Blob prob = net.getBlob("Dense2"); //gather output of the LAST layer in the prototxt
Mat probMat = prob.matRefConst().reshape(1, 1); //reshape the blob to 1x1000 matrix
cerr << probMat << endl;
for (int i=0; i<5; i++) { // taken from the jupyter notebook
int x = (probMat.at<float>(0,i*2 ) + 0.5) * 40;
int y = (probMat.at<float>(0,i*2+1) + 0.5) * 40;
circle(img, Point(x,y), 2, Scalar(255,0,0), 1);
}
namedWindow("LANDMARKS !",0);
imshow("LANDMARKS !", img);
waitKey();
return 0;
}
accuracy is shoddy, but hey ;)
there simply might not be such a thing yet.
closest from the caffe model zoo might be this one
Hello, can use it with the dnn module that come with opencv??
ignore comments above. there simply is no pretrained caffe model for facedetection .
(and the landmarks model requires pre-cropped face images, so no gain here.)
just use opencv's builtin face detection in the meantime
no there a prebuild caffe model for face detection here it's the link!!!!!! https://github.com/LouieYang/AgeAndGenderEstimation (https://github.com/LouieYang/AgeAndGe...) it's have 3 model for face detection, gender estimation and age estimation!!!
good luck with it !