void FacialFeatureRecognizerTest::compareSmileFrownSimilarFacesTest()
{
	Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
    FacialFeatureRecognizer recognizer(model, 0, NULL, NULL, NULL);
	QString trainingFile("/home/zane/Documents/COS301/training.xml");
	recognizer.loadTrainingFromXML(trainingFile);

	Mat face1 = imread("../../testFiles/FaceRec/barack_smile.jpg", CV_LOAD_IMAGE_UNCHANGED);
	Mat face2 = imread("../../testFiles/FaceRec/barack_frown.jpg", CV_LOAD_IMAGE_UNCHANGED);

	string faceCascade = "/home/zane/Documents/COS301/MainProject/testFiles/haarcascade_frontalface_alt2.xml";
	Filter* faceDetect = new FaceDetectFilter(faceCascade);
	Filter* preProc = new PreProcessingFilter(140, 150);

	ImageData* data1 = new ImageData(face1, 0);
	data1 = faceDetect->filter(data1);
	data1 = preProc->filter(data1);

	ImageData* data2 = new ImageData(face2, 0);
	data2 = faceDetect->filter(data2);
	data2 = preProc->filter(data2);

	double expected = 5800;
	double actual = recognizer.compareFaces(data1->faces[0], data2->faces[0]);

	QVERIFY(actual <= expected);
}
Ejemplo n.º 2
0
void RecognitionDatabase::Private::applyParameters()
{
    if (recognizerConst())
    {
        for (QVariantMap::const_iterator it = parameters.constBegin(); it != parameters.constEnd(); ++it)
        {
            if (it.key() == QString::fromLatin1("threshold") || it.key() == QString::fromLatin1("accuracy"))
            {
                recognizer()->setThreshold(it.value().toFloat());
            }
        }
    }
}
Ejemplo n.º 3
0
int CALLBACK wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
{
	RoInitializeWrapper roInit;

	KeywordRecognizer recognizer(ABI::Windows::Media::SpeechRecognition::SpeechRecognitionConfidence_Low,
	{
		L"Hello, world!",
		L"F**k you",
		L"DAMN SON",
		L"Allahu akbar",
		L"Google",
		L"Gmail",
		L"Why won't you f**k off"
	});

	AudioManager::Initialize();

	Sound allahu(L"ALLAHU_AKBAR", false, false);

	auto quitEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr);
	Assert(quitEvent != nullptr);

	recognizer.AddCallback([&allahu, &quitEvent](const std::wstring& word)
	{
		OutputDebugStringW(word.c_str());
		OutputDebugStringW(L"\r\n");

		if (word.compare(L"Allahu akbar") == 0)
		{
			allahu.Play();
		}
		else if (word.compare(L"Google") == 0)
		{
			ShellExecute(NULL, L"open", L"http://www.google.com", NULL, NULL, SW_SHOWDEFAULT);
		}
		else if (word.compare(L"Gmail") == 0)
		{
			ShellExecute(NULL, L"open", L"http://www.gmail.com", NULL, NULL, SW_SHOWDEFAULT);
		}
		else if (word.compare(L"Why won't you f**k off") == 0)
		{
			SetEvent(quitEvent);
		}
	});

	recognizer.StartAsync();

	WaitForSingleObject(quitEvent, INFINITE);
	return 0;
};
Ejemplo n.º 4
0
void savePoint(int a,int b, int c, int d,Player player[],int *stage,int reset)
{
	static Player savepoint;
	static int savestage;
	Box reco={a*BOXSIZE-PLAYERSIZE,b*BOXSIZE-PLAYERSIZE,c*BOXSIZE+PLAYERSIZE,d*BOXSIZE+PLAYERSIZE};
	if(recognizer(reco,player[0]) && player[0].life==1)
	{
		savepoint=player[0];
		savestage=stage[0];
	}
	if(reset==RESET)
	{
		player[0]=player[1]=savepoint;
		for(int i=0; i<2; i++){
			player[i].life = 1;
		}
		stage[0]=savestage;
	}

}
Ejemplo n.º 5
0
int main(int argc, char** argv)
{
	if (argc != 2) {
		std::cerr << "usage : " << argv[0] << " flagImg\n";
		return 1;
	}

	try {
		cv::Mat flag = cv::imread(argv[1]);
		FlagRecognizer recognizer("flag.data");

		recognizer.recognize(flag);
	}
	catch (const std::exception& e) {
		std::cerr << e.what() << '\n';
		return 2;
	}
	catch (...) {
		return 3;
	}

	return 0;
}
Ejemplo n.º 6
0
void CDKnownProcesses::OnButtonAddnew() 
{
	// TODO: Add your control notification handler code here
	CString title = _T("Select executable file");
	CString strpath;
	if (BrowseForFolder(this->m_hWnd, title, strpath, TRUE, NULL))
	{
		PWCHAR pwch = strpath.GetBuffer(strpath.GetLength() + sizeof(TCHAR));
		if (pwch != NULL)
		{
			CProcessRecognizer recognizer(pwch);
			m_pKnownList->RegisterNewProcess(pwch, &recognizer);
		
			strpath.ReleaseBuffer();
		}
		else
		{
			//! error during add new process
		}
	}
	
	ReloadList();
}