Esempio n. 1
0
/*"G:\\Picture\\Lighting\\FaceFP_2.txt"*/
void GetFaceFromTxt(const string txtname, vector<Face>& vfaces)
{
	size_t maxSize = 1000;	///vpaths.size()
	string sign;
	int id;
	vector<string> vpaths(maxSize);	//文件路径
	vector<Vec4f> vpoints(maxSize);	//两眼坐标点
	vector<int> vids(maxSize);		//人脸ID号
	vector<string> vsigns(maxSize);	//标记
	vector<Mat> vmfaces(maxSize);		//归一化人脸区域
	ReadTxt(txtname, vpaths, vpoints, ' ');	//读入文件名和两眼坐标
	for (size_t i = 0; i<maxSize; i++)	//分解文件名,得到ID和状态标志
	{
		string path = vpaths[i];
		ReadFilename(path, id, sign);
		vids.push_back(id);
		vsigns.push_back(sign);
	}
	for (size_t j = 0; j<maxSize; j++)
	{
		string long_path = "G:\\Picture\\pose\\" + vpaths[j].substr(0, vpaths[j].size()-1) + ".jpg";	//分割得到的文件名多出一个空格,-1去除
		Mat image = imread(long_path, 0);
		if (!image.empty())
		{
			Point2f pLeft = Point2f(vpoints[j][0],vpoints[j][1]);
			Point2f pRight = Point2f(vpoints[j][2],vpoints[j][3]);
#if 0	//光照时需归一化
			Mat dst = alignFace(image, pRight, pLeft);	//尺寸归一化

#elif 0	//头部姿态标记两眼距离
			Mat dst = image;
			line(dst, pLeft, pRight, Scalar(0, 0, 0), 2, 8);
			circle(dst, pLeft, 2, Scalar(255, 255, 255), 2, 8);
			circle(dst, pRight, 2, Scalar(255, 255, 255), 2, 8);

#else 1	//对称性
			Mat dst = AlignFace(image, pRight, pLeft);	//尺寸归一化

#endif
			vmfaces.push_back(dst);
	/*		imshow("image", dst);
			waitKey(0);*/
		}
	}
	//将人脸各项信息存入Face
	for (size_t m = 0; m<maxSize; m++)
	{
		Face mface;
		mface.filename = vpaths[m];
		mface.id = vids[m];
		mface.sign = vsigns[m];
		mface.eyePoints = vpoints[m];
		mface.face = vmfaces[m];
		mface.value = 0.0;
		vfaces.push_back(mface);
	}
}
Esempio n. 2
0
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    KAboutData aboutData( "simon-touch", "simon-touch",
    			  ki18n("simon-touch"), "0.1",
    			  ki18n("Voice controlled media center and personal communication portal"),
			  KAboutData::License_GPL,
              ki18n("Copyright (c) 2011-2012 Peter Grasch, Mathias Stieger, Claus Zotter") );

    KCmdLineOptions options;
    options.add("images <folder>", ki18n("Path to images"));
    options.add("music <folder>", ki18n("Path to music"));
    options.add("videos <folder>", ki18n("Path to videos"));
    options.add("feeds <description>", ki18n("RSS feeds to use; Feed format: \"<title 1>,<url 1>,<icon 1>,<group>;<title 2>,...\""));
    options.add("groups <description>", ki18n("RSS feed groups (e.g. different newspapers) to use; format: \"<grouphandle 1>,<groupname 1>,<groupicon 1>;<grouphandle 2>,...\""));
    KCmdLineArgs::addCmdLineOptions(options);
    
    KCmdLineArgs::init(argc, argv, &aboutData);
    KApplication app;

    KGlobal::locale()->insertCatalog("libskype");

    Configuration cfg;

    ImagesModel img(cfg.imagePath());
    MusicModel music(cfg.musicPath());
    VideosModel vids(cfg.videosPath());
    QStringList groups = cfg.groups().split(';');
    QStringList feeds = cfg.feeds().split(';');

    QStringList grouphandles, groupnames, groupicons;
    foreach (const QString& group, groups) {
        QStringList groupdetails = group.split(',');
        if (groupdetails.count() != 3) {
            qWarning() << i18n("RSS feed groups format: \"<grouphandle 1>,<groupname 1>,<groupicon 1>;<grouphandle 2>,...\"");
        return -1;
    }
        grouphandles << groupdetails[0];
        groupnames << groupdetails[1];
        groupicons << groupdetails[2];
    }