How to detect Fingersize with iOS?

Is it possible to detect a finger in an iOS app? I read in the documentation:

Notes. The finger on the screen gives a completely different level than the mouse pointer. When the user touches the screen, the contact area is actually elliptical and tends to shift below the point at which the user thinks he or she has touched. This “contact patch” also varies in size and shape, on the basis of which the finger touches the screen, finger size, finger pressure on the screen, finger orientation and other factors. The basic Multi-Touch system analyzes all this information for you and calculates one touch point .

Source: http://developer.apple.com/library/ios/#DOCUMENTATION/EventHandling/Conceptual/EventHandlingiPhoneOS/MultitouchEvents/MultitouchEvents.html

So, does this mean that there is no way to detect physical fingerprinting with the SDK? What I want to accomplish: I need virtual “buttons” in my OpenGL ES application. And if someone holds the iPhone like a gamepad, he will try to use one finger for two buttons (sliding from the thumb). I hope this is clear, what I mean ...

Any ideas?

+7
source share
3 answers

@fichek is right, there is no ordinary way to get the size of your fingertips.

However, I used the “weird” method in my previous project to do this, and it just works; -)

1. Tell our user that the two fingers on the screen together, the closer the better (for example, with a two-finger scroll gesture on a Mac): enter image description here

2. Install two CGPoints from UITouches in the touchhesBegan method : withEvent:;

3. Now we have CGPoint fingertip1center and fingertip2center , therefore:

float fingertip_Diameter=fabsf(fingertip1center.x-fingertip2center.x); 

4. The fingers are very close, and we can ignore the tiny difference in width, so dX == the actual width of a single finger.

5. Width (dX) and fingertip are proportional, we can just use

float fingertip_Size=M_PI*(dX/2)*(dX/2);

or find the best algorithm to meet your needs; -)

6. When we get the size (in fact, we only care about the diameter), it is easy to implement a touch optimization method by testing various surrounded points, for example:

 #define kTestLevelOne 5 //Testing 5 points:origin,left,right,up,down #define kTestLevelTwo 9 //And the other 4 corners -(BOOL)testSurroundingPoints:(CGPoint *)pt { float prob_x[kTestLevelTwo]={0,-dX/2,dX/2,0,0,-dX/2,-dX/2,dX/2,dX/2}; float prob_y[kTestLevelTwo]={0,0,0,dX/2,-dX/2,dX/2,-dX/2,dX/2,-dX/2}; for(int i=0;i<kTestLevelTwo;i++) { if([self gotItAtX:pt.x+prob_x[i] andY:pt.y+prob_y[i]]==YES) { NSLog(@"Got It!"); Return YES; //Or break; We don't need to try more points! } } return NO; } 

Hope this helps!

Yichao Peak Ji

+11
source

Actually, there is a way to get the radius of contact:

 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGFloat touchSize = [[touch valueForKey:@"pathMajorRadius"] floatValue]; NSLog(@"touch size is %.2f", touchSize); } 

Source: http://easyplace.wordpress.com/2013/04/09/how-to-detect-touch-size-in-ios/

+5
source

iOS does all sorts of measurements of finger size / angle / location behind the scenes, so there is no way to detect anything other than a calculated touch location. However, this is more than enough information for you to find out how much of the gamepad is on your finger.

As @marcus mentioned, you must implement the touchesMoved: withEvent: method and check the location of the touch to determine if it is above the left / right / top / bottom / center or any “buttons” you want to have.

+2
source

All Articles