资源简介

该资源是基于VS2015和opencv2413写的人脸识别程序,可以识别视频流中的人脸,有较高的识别率

资源截图

代码片段和文件信息

#include “Accuracy.h“

Accuracy::Accuracy(void)
{
}

Accuracy::~Accuracy(void)
{
}

void Accuracy::readPositionData()
{
ifstream inFile(“p.txt“);
string line;
size_t frameNum(0) objectCount(0);
cv::Rect tempRect;
if (!inFile)
{
cout << “file not exist“ << endl;
return;
}
while (getline(inFile line))
{
stringstream ss;
ss << line;
ss >> frameNum >> objectCount;
m_frameNumAndCount.push_back(make_pair(frameNum objectCount));
for (size_t i = 0; i < objectCount; ++i)
{
getline(inFile line);
ss.clear();
ss << line;
ss >> tempRect.x >> tempRect.y >> 
tempRect.width >> tempRect.height;
m_realPosition.push_back(tempRect);
}
}
inFile.close();
}

void Accuracy::compare()
{
readData();
size_t right(0) wrong(0);
size_t error(0) miss(0) than2(0);

list::const_iterator itreal;
list::const_iterator itdetect;
for (itreal = m_realCount.begin() itdetect = m_detectCount.begin(); 
itreal != m_realCount.end() && itdetect != m_detectCount.end(); 
++itreal ++itdetect)
{
if (*itreal == *itdetect)
{
if (*itreal == 0)
{
continue;
}
++right;
}
else
{
if (abs(*itreal - *itdetect) >= 2)
{
++than2;
continue;
}
*itreal > *itdetect ? ++miss : ++error;
++wrong;
}
}
outputResult(right wrong error miss than2);
}

void Accuracy::readData()
{
int ival(0);
ifstream infile;
infile.open(“real_count.txt“);
while (!infile.eof())
{
infile >> ival;
m_realCount.push_back(ival);
}
infile.close();

infile.open(“detect_count.txt“);
while (!infile.eof())
{
infile >> ival;
m_detectCount.push_back(ival);
}
infile.close();
}

void Accuracy::outputResult(size_t& right size_t& wrong 
size_t& error size_t& miss size_t& than2)
{
double allRate(0.0) errorRate(0.0) missRate(0.0) than2Rate(0.0);
allRate = static_cast(right) / (right+wrong);
errorRate = static_cast(error) / (right+wrong);
missRate = static_cast(miss) / (right+wrong);
than2Rate = static_cast(than2) / (right+wrong);

cout << “正确检测:“ << “\t“ << allRate << endl;
cout << “错误检测:“ << “\t“ << 1 - allRate << endl;
cout << “\t“ << “误    检:“ << “\t“ << errorRate << endl;
cout << “\t“ << “漏    检:“ << “\t“ << missRate << endl;
cout << “\t“ << “误差超过1:“ << “\t“ << than2Rate << endl;
}

double Accuracy::intersection(cv::Rect rect1 cv::Rect rect2)
{
if (rect1.x > rect2.x + rect2.width)
{ return 0.0; }
if (rect1.y > rect2.y + rect2.height)
{ return 0.0; }
if (rect1.x + rect1.width < rect2.x)
{ return 0.0; }
if (rect1.y + rect1.height < rect2.y)
{ return 0.0; }
double rightupx leftdowny;
double leftx upy;
double areaInter area1 area2;
if (rect1.x + rect1.width > rect2.x + rect2.width)
{ rightupx = rect2.x + rect2.width; }
else
{ rightupx = rect1.x + rect1.width; }
if (rect1.y + rect1.height > rect2.y + rect2.he

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-06-28 11:03  Face_recongnaize\.vs\
     目录           0  2018-06-28 11:03  Face_recongnaize\.vs\FacaDetection\
     目录           0  2018-06-28 11:03  Face_recongnaize\.vs\FacaDetection\v14\
     文件       57856  2018-08-28 16:22  Face_recongnaize\.vs\FacaDetection\v14\.suo
     目录           0  2018-06-28 11:05  Face_recongnaize\Debug\
     文件      228864  2018-06-28 11:05  Face_recongnaize\Debug\FacaDetection.exe
     文件     1054460  2018-06-28 11:05  Face_recongnaize\Debug\FacaDetection.ilk
     文件     2691072  2018-06-28 11:05  Face_recongnaize\Debug\FacaDetection.pdb
     文件    13520896  2016-06-02 20:18  Face_recongnaize\FacaDetection.sdf
     文件         906  2016-04-12 10:28  Face_recongnaize\FacaDetection.sln
     文件       28160  2016-06-02 20:18  Face_recongnaize\FacaDetection.suo
     文件      245760  2018-08-28 16:22  Face_recongnaize\FacaDetection.VC.db
     目录           0  2018-06-28 11:05  Face_recongnaize\FacaDetection\
     文件        3472  2016-04-12 10:28  Face_recongnaize\FacaDetection\Accuracy.cpp
     文件         875  2018-06-28 11:02  Face_recongnaize\FacaDetection\Accuracy.h
     文件        2627  2016-04-12 10:28  Face_recongnaize\FacaDetection\callback.cpp
     目录           0  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\
     文件      656576  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\Accuracy.obj
     文件        5034  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\FacaDetection.Build.CppClean.log
     文件         121  2016-04-12 10:28  Face_recongnaize\FacaDetection\Debug\FacaDetection.lastbuildstate
     文件        3251  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\FacaDetection.log
     文件      627432  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\FacaDetection.obj
     目录           0  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\FacaDetection.tlog\
     文件        1992  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\FacaDetection.tlog\CL.command.1.tlog
     文件       74368  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\FacaDetection.tlog\CL.read.1.tlog
     文件        1730  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\FacaDetection.tlog\CL.write.1.tlog
     文件         197  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\FacaDetection.tlog\FacaDetection.lastbuildstate
     文件        1502  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\FacaDetection.tlog\link.command.1.tlog
     文件        6244  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\FacaDetection.tlog\link.read.1.tlog
     文件         728  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\FacaDetection.tlog\link.write.1.tlog
     文件      338078  2018-06-28 11:05  Face_recongnaize\FacaDetection\Debug\main.obj
............此处省略27个文件信息

评论

共有 条评论