资源简介
资源中是通过加载自己的权值和框架框出人脸,同时读取FDDB的标签将标准人脸还原出来,通过IOU来判断自己的框架是否框对人脸,最后计算准确率
代码片段和文件信息
#include“opencv2/opencv.hpp“
#include “opencv2/highgui/highgui.hpp“
#include“opencv2/imgproc/imgproc.hpp“
#include “opencv2/core/core.hpp“
#include“iostream“
#include
using namespace std;
using namespace cv;
using namespace cv::dnn;
const size_t inWidth = 300;
const size_t inHeight = 300;
const double inScaleFactor = 1.0;
const Scalar meanVal(104.0 177.0 123.0);
template
Type stringToNum(const string& str)
{
istringstream iss(str);
Type num;
iss >> num;
return num;
}
vector FDDB;
vector OPENCV;
vector Right;
vector False;
float iou(Rect &OPENCV Rect &FDDB)
{
int x1 = OPENCV.x;
int y1 = OPENCV.y;
int w1 = OPENCV.width;
int h1 = OPENCV.height;
int x2 = FDDB.x;
int y2 = FDDB.y;
int w2 = FDDB.width;
int h2 = FDDB.height;
if (x1 + w2 <= x2 || x2 + w2 <= x1||y1+h1<=y2||y2+h2<=y1)
return 0;
int startx = (x2 - x1)>0 ? x2 : x1;
int endx = ((x2+w2) - (x1+w1))>0 ? (x1 + w1) : (x2 + w2);
int starty = (y2 - y1)>0 ? y2 : y1;
int endy = ((y2+h2)-(y1+h1))>0 ? (y1 + h1) : (y2 + h2);
int s1 = (endx - startx)*(endy - starty);
int s2 = w1*h1 + w2*h2 - s1;
float IOU = s1*1.0 / s2*1.0;
return IOU;
}
int main()
{
int g = 2;
String modelConfiguration = “D://face_dectect//deploy_opencv.prototxt“;
String modelBinary = “D://face_dectect//face_opencv.caffemodel“;
dnn::Net net = readNetFromCaffe(modelConfiguration modelBinary);
int a=0p=0;
Rect fddb;
Mat srcdst1grayframe;
string imgNamelist;
ifstream start(“D://face_dectect//FDDB//pos.txt“);
for(int i=0;getline(startlist);i++)
{
ifstream fineNeg(“D://face_dectect//FDDB//“+list);
for (int num = 0; getline(fineNeg imgName); num++)
{
p++;
if (p % 100 == 0)
cout << “possess:“ << p << endl;
string n = imgName;
if (n.length() >= 21 && n.length() <= 26)
{
OPENCV.clear();
g = 1;
string Path = “D://face_dectect//“ + imgName + “.jpg“;
src = imread(Path);
dst1 = imread(Path);
frame = imread(Path);
if (src.empty())
{
cout << “error!“ << endl;
return 0;
}
}
if (n.length() == 1)
{
a = atoi(n.c_str());
}
int q = 0;
if (n.length() >= 51)
{
Mat dst = dst1;
for (int i = 0; i < dst.rows; ++i)
{
for (int j = 0; j < dst.cols; ++j)
{
Vec3b pixel1;
pixel1[0] = 0;
pixel1[1] = 0;
pixel1[2] = 0;
dst.at(i j) = pixel1;
}
}
FDDB.clear();
istringstream strcin(n);
string s;
vector vs;
while (strcin >> s)
vs.push_back(s);
double b = atof(vs[0].c_str());
double h = atof(vs[1].c_str());
double d = atof(vs[2].c_str());
double e = atof(vs[3].c_str());
double f = atof(vs[4].c_str());
ellipse(dst Point(e f) Size(b h) d * 180 / 3.14 0 360 cv::Scalar(255 255 255) 1);
if
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-03-09 08:17 rectangle\
目录 0 2019-02-25 01:28 rectangle\.vs\
目录 0 2019-02-25 01:28 rectangle\.vs\rectangle\
目录 0 2019-02-25 01:28 rectangle\.vs\rectangle\v14\
文件 29696 2019-03-09 08:17 rectangle\.vs\rectangle\v14\.suo
目录 0 2019-02-25 03:26 rectangle\Debug\
文件 61440 2019-02-25 03:26 rectangle\Debug\rectangle.pdb
文件 5681 2019-02-27 06:25 rectangle\main.cpp
目录 0 2019-03-09 08:17 rectangle\rectangle\
目录 0 2019-02-25 03:26 rectangle\rectangle\Debug\
文件 680114 2019-02-25 03:26 rectangle\rectangle\Debug\main.obj
文件 512 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.log
目录 0 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\
文件 626 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\CL.command.1.tlog
文件 26860 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\CL.read.1.tlog
文件 420 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\CL.write.1.tlog
文件 2 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\li
文件 2 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\li
文件 2 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\li
文件 2 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\li
文件 2 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\li
文件 2 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\li
文件 2 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\li
文件 193 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\rectangle.lastbuildstate
文件 0 2019-02-25 03:26 rectangle\rectangle\Debug\rectangle.tlog\unsuccessfulbuild
文件 1100800 2019-02-25 03:26 rectangle\rectangle\Debug\vc140.idb
文件 2183168 2019-02-25 03:26 rectangle\rectangle\Debug\vc140.pdb
文件 5683 2019-03-09 08:17 rectangle\rectangle\main.cpp
文件 3911 2019-03-01 05:02 rectangle\rectangle\main1.cpp
文件 169947 2019-03-01 03:53 rectangle\rectangle\problem.txt
文件 7735 2019-02-27 01:40 rectangle\rectangle\rectangle.vcxproj
............此处省略24个文件信息
- 上一篇:卓健智慧医院解决方案2018
- 下一篇:WebGIS原理与应用开发源代码代码和数据
评论
共有 条评论