$1Recognizer 手势识别的那些事儿

写在前面:

    前段时间,这边临时出了个任务,手绘图形识别,当然,最终采取的方法是:记录用户手绘的点集,再做判断!

采用的是一个开源的库$1Recognizer这是一个基于模拟契合的算法。网页上有案例。

针对该算法,做了工作:

1.自绘需要识别的图形作为Sample模板。

Circle
 	float fRadius       = 200;                              
 	const int nCount    = 500;                          
 	const float coef    = 2.0f * (float)M_PI/nCount;               
 	for(unsigned int i = 0;i 

上述为添加的一个圆。总共500个点。并做了正反向的点集录入

RecognitionResult GeometricRecognizer::recognize(Path2D points)
	{
		//--- Make sure we have some templates to compare this to
		//---  or else recognition will be impossible
		if (templates.empty())
		{
			std::cout << "No templates loaded so no symbols to match." << std::endl;
			return RecognitionResult("Unknown", NULL);
		}

		points = normalizePath(points);
		DollarRecognizer::PathWriter::writeToFile(points,"Circle");...............

将点集写到模板。

最后测试

        DollarRecognizer::RecognitionResult result = g_rGemertricRecognizer->recognize(p_2dPath);
	DollarRecognizer::RecognitionResult result_cankao = g_rGemertricRecognizer->recognize(p2d);
	p_2dPath.clear();

	if (result_cankao.score>result.score)
	{
		result = result_cankao;
	}
	if ( result.score>0.89)
	{
		if (!strcmp(result.name.c_str(),"Circle"))
		{  
		}...............

收工


你可能感兴趣的:(cocos2dx)