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

本文介绍了一种基于模拟契合算法的手绘图形识别方法,并详细展示了如何使用$1Recognizer库实现圆形的识别过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

写在前面:

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

采用的是一个开源的库$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 <nCount; i++) {  
 		float rads = i*coef;       
 		DollarRecognizer::Point2D p_Point2DTemp;
 		p_Point2DTemp.x=fRadius * cosf(rads);
 		p_Point2DTemp.y=fRadius * sinf(rads);  
 		p_2dPath.push_back(p_Point2DTemp);//正向点集
 		p2d.insert(p2d.begin(),p_Point2DTemp);//反向点集
 	} 

上述为添加的一个圆。总共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"))
		{  
		}...............

收工


Fingers is your one stop choice for all gesture handling in Unity (and other C# platforms as Fingers has no Unity specific code). Fingers has been tested and runs great on MAC, Windows, iOS and Android. Full C# source code and shader code is provided! No other asset matches Fingers Gestures on price and feature set. Fingers - Touch Gesture for Unity has been featured in multiple Unity promotions and tutorial videos, showing the high quality and full feature set and value proposition. With Fingers, you get all the common touch gestures you are used to built in. This includes: tap, double tap, long tap, pan, rotate, scale and swipe gestures. In addition, creating your own custom gestures is simple and easy. I've recently began adding on-screen controls. Right now a joystick and dpad are included with more controls planned for the future. Adding gestures in the inspector has never been easier. Simply add from the component menu and configure your gesture. Set the callback to your script and you are done! Pan/rotate/scale and drag and drop is simple. Built in scripts for these scenarios, with demo scenes are provided. I've also added image recognition gestures. With a few minutes of tweaking, you can recognize shapes like circles, lightning bolts, check marks and the letter X. Previewing gestures in the player is easy, even without a touch screen. Just use the shift and control key plus mouse wheel to simulate pinch and rotate gestures, along with each button to simulate a different finger. Fingers has a similar architecture to UIGestureRecognizer from iOS, but is built using all C# code and will easily run on any platform that has a mouse or touch screen. Gestures are restricted to most UI elements by default, but this is easily configured if you want the gestures to pass through additional UI elements. This asset works great with the default Unity UI and Event System. Gestures can be executed simultaneously or exclusively (the default). In addition
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值