Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // label hands
  2.     _hlf->setInput(&ibSegmentedImage);
  3.     _hlf->setOutput(&ibFingerImage);
  4.     _hlf->process(1000,100000);
  5.  
  6.     // identify fingers
  7.     if(_hlf->boxes().size() > 0)
  8.     {
  9.         // get palm location using distance transform
  10.         _dtf->setInput(&ibFingerImage);
  11.         _dtf->setBoxes(&_hlf->boxes());
  12.         _dtf->setOutput(&ibFingerImage);
  13.         _dtf->process();
  14.  
  15.         // trace through fingers and find curvature
  16.         _fid->setInput(&ibFingerImage);
  17.         _fid->setBoxes(&_hlf->boxes());
  18.         _fid->setOutput(&ibFingerImage);
  19.         _fid->process();
  20.  
  21.         // clean up first
  22.         [_detectedFingertips removeAllObjects];
  23.        
  24.         for(int i=0; i<_hlf->boxes().size(); ++i)
  25.         {
  26.             const std::vector<FingerPoint *> & fingerPoints = _hlf->boxes()[i]->fingerPoints();
  27.             for(int j=0; j<fingerPoints.size(); ++j)
  28.             {
  29.                 FingerPoint * p = fingerPoints[j];
  30.                
  31.                 // determine location
  32.                 NSPoint nsCamPoint = NSMakePoint(p->normalizedCamPoint().x, 1-p->normalizedCamPoint().y);
  33.                 NSPoint nsScreenPoint = [_cameraToScreenMapper applyTo: nsCamPoint];
  34.                 //NSLog(@"found finger at (%f,%f)", p->normalizedCamPoint().x, p->normalizedCamPoint().y);
  35.  
  36.                 // determine fingertip id
  37.                 int finger_id = p->fingerNumber();
  38.  
  39.                 // TODO: uncomment lines below once the hand detection works reliably.
  40. //                switch(p->parentBox()->handType())
  41. //                {
  42. //                    case LEFT_HAND: finger_id *= -1; break;
  43. //                    case RIGHT_HAND: finger_id *= +1; break;
  44. //                    case UNDEFINED_HAND: finger_id = 0; break;
  45. //                }
  46.        
  47.                 MtFingertip * fingertip = [[[MtFingertip alloc]
  48.                                             initFromCamPosition: nsCamPoint
  49.                                             AndScreenPosition: nsScreenPoint
  50.                                             AndFingerId: finger_id]
  51.                                            autorelease];
  52.                 [_detectedFingertips addObject: fingertip];
  53.             }
  54.         }
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement