当前位置: 首页>>代码示例>>C++>>正文


C++ Controller::frame方法代码示例

本文整理汇总了C++中leap::Controller::frame方法的典型用法代码示例。如果您正苦于以下问题:C++ Controller::frame方法的具体用法?C++ Controller::frame怎么用?C++ Controller::frame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在leap::Controller的用法示例。


在下文中一共展示了Controller::frame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onFrame

void Listener::onFrame(const Leap::Controller &controller) {
    Leap::Frame curFrame = controller.frame();
    if (firstFrameLeap == 0 && ++frameCount > 10) {
        gettimeofday(&firstFrameAbs, NULL);
        firstFrameLeap = curFrame.timestamp();
        cout << "First frame clock time: " << tv_to_usec(firstFrameAbs) << endl;
        cout << "First frame leap time: " << firstFrameLeap << endl;
    }
    
    // use current active gesture recognizers to locate gestures
    // and then trigger appropriate note/controls
    // feed frames to recognizers
    vector<GesturePtr> recognizers = gestureRecognizers();
    for (vector<GesturePtr>::iterator it = recognizers.begin(); it != recognizers.end(); ++it) {
        // get controls recognized from gestures
        GesturePtr gesture = *it;
        std::vector<ControlPtr> gestureControls; // controls from this gesture
        gesture->recognizedControls(controller, gestureControls);
        
        if (! gestureControls.size())
            continue;
        
        // call gesture recognized callback
        onGestureRecognized(controller, gesture);
        
        for (vector<ControlPtr>::iterator ctl = gestureControls.begin(); ctl != gestureControls.end(); ++ctl) {
            ControlPtr control = *ctl;
            
            onControlUpdated(controller, gesture, control);
        }
    }
}
开发者ID:SteveClement,项目名称:leapmidi,代码行数:32,代码来源:MIDIListener.cpp

示例2: onFrame

void Quickstart::onFrame(const Leap::Controller &controller) {
    // returns the most recent frame. older frames can be accessed by passing in 
    // a "history" parameter to retrieve an older frame, up to about 60
    // (exact number subject to change)
    const Leap::Frame frame = controller.frame();

    // do nothing unless hands are detected
    if (frame.hands().empty())
        return;
    
    // first detected hand
    const Leap::Hand firstHand = frame.hands()[0];
    // first pointable object (finger or tool)
    const Leap::PointableList pointables = firstHand.pointables();
    if (pointables.empty()) return;
    const Leap::Pointable firstPointable = pointables[0];
    
    // print velocity on the X axis
    cout << "Pointable X velocity: " << firstPointable.tipVelocity()[0] << endl;
    
    const Leap::FingerList fingers = firstHand.fingers();
    if (fingers.empty()) return;
    
    for (int i = 0; i < fingers.count(); i++) {
        const Leap::Finger finger = fingers[i];
        
        std::cout << "Detected finger " << i << " at position (" <<
            finger.tipPosition().x << ", " <<
            finger.tipPosition().y << ", " <<
            finger.tipPosition().z << ")" << std::endl;
    }
}
开发者ID:revmischa,项目名称:leapbook,代码行数:32,代码来源:quickstart.cpp

示例3: onControlUpdated

void Listener::onControlUpdated(const Leap::Controller &controller, GesturePtr gesture, ControlPtr control) {
    midi_control_index ctrlIdx = control->controlIndex();
    midi_control_value ctrlVal = control->mappedValue();
//    
//    cout << "Recognized control index " << ctrlIdx
//         << " (" << control->description() << ")"
//         << ", raw value: "
//         << control->rawValue() << " mapped value: " << ctrlVal << endl;
    
    if (frameCount <= 10) return;
    
    // control latency
    struct timeval tv;
    gettimeofday(&tv, NULL);
    double elapsedTime = (tv.tv_sec - control->timestamp().tv_sec) * 1000.0;      // sec to ms
    elapsedTime += (tv.tv_usec - control->timestamp().tv_usec) / 1000.0;   // us to ms
    
    // frame latency
    double absoluteTimeOffset = tv_to_usec(tv) - tv_to_usec(firstFrameAbs);
//    cout << "absolute time offset: " << absoluteTimeOffset << endl;
    int64_t curFrameTime = controller.frame().timestamp();
    int64_t frameOffset = curFrameTime - firstFrameLeap;
    int64_t frameLatency = absoluteTimeOffset - frameOffset;
//    cout << "frame: " << curFrameTime << ", absolute offset: " << (absoluteTimeOffset / 1000) << ", frameOffset: " << (frameOffset / 1000) << ", diff: " << (frameLatency / 1000) << endl;
    
    if (minLatency == 0 || frameLatency < minLatency)
        minLatency = frameLatency;
    if (frameLatency > maxLatency)
        maxLatency = frameLatency;
    controlCount++;
    totalLatency += frameLatency;
    
    if (elapsedTime > 3)
        cout << "frame latency: " << (frameLatency / 1000) << ", control output latency: " << elapsedTime << endl;
}
开发者ID:SteveClement,项目名称:leapmidi,代码行数:35,代码来源:MIDIListener.cpp

示例4: processGesture

void LeapFishyApp::processGesture()
{
	Leap::Frame frame = m_LeapController.frame();

	if( m_LastFrame == frame )
		return;

	Leap::GestureList gestures =	m_LastFrame.isValid()			?
									frame.gestures( m_LastFrame )	:
									frame.gestures();

	m_LastFrame = frame;

	for( int i = 0; i < gestures.count(); i++ )
	{
		if( gestures[i].type() == Leap::Gesture::TYPE_SWIPE )
		{
			Leap::SwipeGesture swipe = gestures[i];
			Leap::Vector diff = 0.006f*(swipe.position() - swipe.startPosition());
			Vec2f curSwipe(diff.x, -diff.y);
			m_pPlayer->AddVelocity( curSwipe );
		}
		else if(	gestures[i].type() == Leap::Gesture::TYPE_KEY_TAP || 
					gestures[i].type() == Leap::Gesture::TYPE_SCREEN_TAP )
		{
			m_pPlayer->KillVelocity();
		}
	}
}
开发者ID:seanfoo73,项目名称:LeapExperiments,代码行数:29,代码来源:LeapFishyApp.cpp

示例5: onFrame

void MouseController::onFrame(const Leap::Controller &controller) {
    // get list of detected screens
    const Leap::ScreenList screens = controller.calibratedScreens();
    
    // make sure we have a detected screen
    if (screens.empty()) return;
    const Leap::Screen screen = screens[0];
    
    // find the first finger or tool
    const Leap::Frame frame = controller.frame();
    const Leap::HandList hands = frame.hands();
    if (hands.empty()) return;
    const Leap::PointableList pointables = hands[0].pointables();
    if (pointables.empty()) return;
    const Leap::Pointable firstPointable = pointables[0];
    
    // get x, y coordinates on the first screen
    const Leap::Vector intersection = screen.intersect(
                                                       firstPointable,
                                                       true,  // normalize
                                                       1.0f   // clampRatio
                                                       );
    
    // if the user is not pointing at the screen all components of
    // the returned vector will be Not A Number (NaN)
    // isValid() returns true only if all components are finite
    if (! intersection.isValid()) return;
    
    unsigned int x = screen.widthPixels() * intersection.x;
    // flip y coordinate to standard top-left origin
    unsigned int y = screen.heightPixels() * (1.0f - intersection.y);
    
    CGPoint destPoint = CGPointMake(x, y);
    CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, destPoint);
}
开发者ID:revmischa,项目名称:leapmouse,代码行数:35,代码来源:main.cpp

示例6: onFrame

void LeapMotionListener::onFrame( const Leap::Controller& controller )
{
	// get least frame
	frame = controller.frame( 0 );
	

}
开发者ID:hhyuga201515,项目名称:MiraiMotion,代码行数:7,代码来源:LeapMotionListener.cpp

示例7: onFrame

void Listener::onFrame( const Leap::Controller& controller ) 
{
	lock_guard<mutex> lock( *mMutex );
	if ( !mNewFrame ) {
		mFrame		= controller.frame();
		mNewFrame	= true;
	}
}
开发者ID:BanTheRewind,项目名称:Cinder-LeapMotion,代码行数:8,代码来源:Cinder-LeapMotion.cpp

示例8: get_finger_positions

fdata get_finger_positions()
{
    Leap::Frame frame = control.frame();
    Leap::FingerList fingers = frame.fingers();
    Leap::ToolList tools = frame.tools();
    Leap::HandList hands = frame.hands();

    //std::vector<std::pair<cl_float4, int>> positions;

    fdata hand_data;


    int p = 0;

    for(int i=0; i<40; i++)
    {
        hand_data.fingers[i] = 0.0f;
    }

    ///will explode if more than 2
    for(int i=0; i<hands.count(); i++)
    {
        const Leap::Hand hand = hands[i];
        Leap::FingerList h_fingers = hand.fingers();

        float grab_strength = hand.grabStrength();

        hand_data.grab_confidence[i] = grab_strength;

        for(int j=0; j<h_fingers.count(); j++)
        {
            const Leap::Finger finger = h_fingers[j];

            float mfingerposx = finger.tipPosition().x;
            float mfingerposy = finger.tipPosition().y;
            float mfingerposz = finger.tipPosition().z;

            //cl_float4 ps = {mfingerposx, mfingerposy, mfingerposz, 0.0f};
            //cl_float4 ps = {mfingerposx, mfingerposy, mfingerposz, 0.0f};

            int id = finger.id();

            hand_data.fingers[p++] = mfingerposx;
            hand_data.fingers[p++] = mfingerposy;
            hand_data.fingers[p++] = mfingerposz;
            hand_data.fingers[p++] = 0.0f;

            //positions.push_back(std::pair<cl_float4, int>(ps, id));

        }
    }

    return hand_data;
}
开发者ID:Michaelangel007,项目名称:openclamdrenderer,代码行数:54,代码来源:main.cpp

示例9: processFingers

void LeapCinderRainApp::processFingers()
{
	Leap::Frame frame = m_LeapController.frame();
	Leap::FingerList fingers = frame.fingers();

	m_Rain->ClearPointTo();

	for( int i = 0; i < fingers.count(); i++ )
	{
		m_Rain->CheckPointTo( normalizeCoords( fingers[i].tipPosition() ), 40.0f );
	}
}
开发者ID:seanfoo73,项目名称:LeapExperiments,代码行数:12,代码来源:LeapCinderRainApp.cpp

示例10: stepFrame

// This is called every SL viewer frame
void LLLMImpl::stepFrame()
{
	if (mLMController
		&& mFrameAvailable
		&& mLMConnected)
	{
		mFrameAvailable = false;

		// Get the most recent frame and report some basic information
		const Leap::Frame frame = mLMController->frame();
		Leap::HandList hands = frame.hands();
		
		static LLCachedControl<S32> sControllerMode(gSavedSettings, "LeapMotionTestMode", 0);

		if( !mTool || mTool->getId() != sControllerMode )
		{
			delete mTool;
			mTool = nd::leap::constructTool( sControllerMode );
		}

		if( mTool )
			mTool->onRenderFrame( frame );
		else
		{
			switch (sControllerMode)
			{
				case 1:
					modeFlyingControlTest(hands);
					break;
				case 2:
					modeStreamDataToSL(hands);
					break;
				case 3:
					modeGestureDetection1(hands);
					break;
				case 4:
					modeMoveAndCamTest1(hands);
					break;
				// <FS:Zi> Leap Motion flycam
				case 10:
					modeFlycam(hands);
					break;
				// </FS:Zi>
				case 411:
					modeDumpDebugInfo(hands);
					break;
				default:
					// Do nothing
					break;
			}
		}
	}
}
开发者ID:CaseyraeStarfinder,项目名称:Firestorm-Viewer,代码行数:54,代码来源:llleapmotioncontroller.cpp

示例11: memset

void eleap::eleap_t::impl_t::onFrame(const Leap::Controller& controller)
{
    const Leap::Frame frame = controller.frame();
    if (frame.isValid())
    {
        // send the known hands in this frame, this will handle hands coming and going
        const Leap::HandList hands = frame.hands();
        {
            unsigned long long time_encoded = (0&0xffffffff)<<8 | (DATA_KNOWN_HANDS&0xff);

            float *f;
            unsigned char *dp;
            piw::data_nb_t d = ctx_.allocate_host(time_encoded,INT32_MAX,INT32_MIN,0,BCTVTYPE_INT,sizeof(int32_t),&dp,hands.count(),&f);
            memset(f,0,hands.count()*sizeof(int32_t));
            *dp = 0;

            for(int i = 0; i < hands.count(); ++i)
            {
                const Leap::Hand hand = hands[i];
                if(hand.isValid() && hand.fingers().count() > 1)
                {
                    ((int32_t *)f)[i] = hand.id();
                }
            }
            enqueue_fast(d,1);
        }
        
        // handle the actual data for the detected hands
        for(int i = 0; i < hands.count(); ++i)
        {
            const Leap::Hand hand = hands[i];
            if(hand.isValid() && hand.fingers().count() > 1)
            {
                unsigned long long time_encoded = (hand.id()&0xffffffff)<<8 | (DATA_PALM_POSITION&0xff);

                const Leap::Vector palm_pos = hand.palmPosition();

                float *f;
                unsigned char *dp;
                piw::data_nb_t d = ctx_.allocate_host(time_encoded,600,-600,0,BCTVTYPE_FLOAT,sizeof(float),&dp,3,&f);
                memset(f,0,3*sizeof(float));
                *dp = 0;

                f[0] = piw::normalise(600,-600,0,palm_pos.x);
                f[1] = piw::normalise(600,-600,0,palm_pos.y);
                f[2] = piw::normalise(600,-600,0,palm_pos.z);

                enqueue_fast(d,1);
            }
        }
    }
}
开发者ID:Eigenlabs,项目名称:EigenD-Contrib,代码行数:52,代码来源:eleap.cpp

示例12: frame

    virtual void onFrame        (const Leap::Controller&)
    {
        const Leap::Frame frame(m_Controller.frame(0));
        const Leap::Hand hand(frame.hands().rightmost());
        if (!hand.isValid())
        {
            m_LastNormalizedPos.reset();
            return;
        }

        const Leap::Vector pos(hand.palmPosition());
        m_LastNormalizedPos = frame.interactionBox().normalizePoint(pos);
    }
开发者ID:IrmatDen,项目名称:sfge,代码行数:13,代码来源:controller_leap_metalpad.cpp

示例13: if

void LeapSample03App::draw()
{
    gl::clear( Color( .97, .93, .79 ) );
    Leap::PointableList pointables = leap.frame().pointables();
    Leap::InteractionBox iBox = leap.frame().interactionBox();

    for ( int p = 0; p < pointables.count(); p++ ) {
        Leap::Pointable pointable = pointables[p];
#if 1
        // ここから追加
        // 伸びている指、ツール以外は無視する
        if ( !pointable.isExtended() ) {
            continue;
        }
        // ここまで追加
#endif

        Leap::Vector normalizedPosition =
            iBox.normalizePoint( pointable.stabilizedTipPosition() );
        float x = normalizedPosition.x * windowWidth;
        float y = windowHeight - normalizedPosition.y * windowHeight;

        // ホバー状態
        if ( (pointable.touchDistance() > 0) &&
            (pointable.touchZone() != Leap::Pointable::Zone::ZONE_NONE) ) {
            gl::color(0, 1, 0, 1 - pointable.touchDistance());
        }
        // タッチ状態
        else if ( pointable.touchDistance() <= 0 ) {
            gl::color(1, 0, 0, -pointable.touchDistance());
        }
        // タッチ対象外
        else {
            gl::color(0, 0, 1, .05);
        }

        gl::drawSolidCircle( Vec2f( x, y ), 40 );
    }
}
开发者ID:kaorun55,项目名称:LeapMotionIntroduction2,代码行数:39,代码来源:LeapSample03App.cpp

示例14: onFrame

void LeapMotionListener::onFrame( const Leap::Controller& controller )
{
	// get least frame
	frame = controller.frame( 0 );

	// get fingerList
	Leap::FingerList fingerList = frame.hand.fingers();

	// copy
	Leap::Finger *leapFinger = &fingerList[ 0 ];
	Finger *finger = ( Finger * )leapFinger;

}
开发者ID:hhyuga201515,项目名称:MiraiMotion,代码行数:13,代码来源:LeapMotionListener.cpp

示例15: eventShake

int StateKen::eventShake(StateContext& context, const Leap::Controller& controller)
{
    std::cout << "けん\n" << std::endl;
    
    const Leap::Frame frame = controller.frame();
    const Leap::Hand hand = frame.hands()[0];
    
    Leap::Vector position = hand.palmPosition();
    
    JankenApp::getInstance()->setShakeStartPosition(position);
    
    int ret = context.changeState(StatePon::getInstance());
    
    return ret;
}
开发者ID:haraki,项目名称:ConsoleJanken-for-Windows,代码行数:15,代码来源:StateKen.cpp


注:本文中的leap::Controller::frame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。