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


C++ Frame::pointables方法代码示例

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


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

示例1: copyFromFrame

void LeapMotionFrame::copyFromFrame(const Leap::Frame& frame, const F32& maxHandAxisRadius)
{
   // This also resets all counters
   clear();

   // Retrieve frame information
   mFrameValid = frame.isValid();
   mFrameId = frame.id();
   mFrameTimeStamp = frame.timestamp();

   mFrameInternalId = smNextInternalFrameId;
   ++smNextInternalFrameId;
   mFrameSimTime = Sim::getCurrentTime();
   mFrameRealTime = Platform::getRealMilliseconds();

   if(!mFrameValid)
   {
      return;
   }

   // Retrieve hand information
   mHandCount = frame.hands().count();
   if(mHandCount > 0)
   {
      copyFromFrameHands(frame.hands(), maxHandAxisRadius);
   }

   // Retrieve pointable information
   mPointableCount = frame.pointables().count();
   if(mPointableCount > 0)
   {
      copyFromFramePointables(frame.pointables());
   }
}
开发者ID:campadrenalin,项目名称:terminal-overload,代码行数:34,代码来源:leapMotionFrame.cpp

示例2: main

int main()
{
	//Leap Motion Vairables
	Leap::Controller controller;
	Leap::Frame frame;
	Leap::HandList hands;
	Leap::Hand h1;
	Leap::FingerList fingers;
	Leap::Finger index;
	Leap::Finger thumb;
	Leap::PointableList pointables;
	float indexX = 0, indexY = 0, indexZ = 0, thumbX = 0, thumbY = 0, thumbZ = 0, sum = 0;
	unsigned long cycles = 0;

	// TCP Variables
	WSADATA wsaData;
	SOCKET connectSocket = INVALID_SOCKET;

	struct addrinfo* result = NULL;
	struct addrinfo* ptr = NULL;
	struct addrinfo  hints;

	char cSendBuf[512][512];
	char sSendBuf[512];

	int iResult;
	int recvBufLen = DEFAULT_BUFLEN;

	int i = 0;

	iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
	if (iResult != 0) {
		printf("WSAStartup failed with error: %d\n", iResult);
		return 1;
	}

	// Initialize all address info to 0 to start.
	SecureZeroMemory(&hints, sizeof(hints));
	hints.ai_family = AF_UNSPEC;     // Doesn't matter if we use IPV4 or IPV6
	hints.ai_socktype = SOCK_STREAM; // TCP Stream sockets
	hints.ai_protocol = IPPROTO_TCP;

	// Resolve the server address and port
	iResult = getaddrinfo("127.0.0.1", DEFAULT_PORT, &hints, &result);
	if (iResult != 0) {
		printf("getaddrinfo failed with error: %d\n", iResult);
		WSACleanup();
		return 1;
	}

	// Attempt to connect to an address until one succeeds
	for (ptr = result; ptr != NULL; ptr = ptr->ai_next) {

		// create a socket for connecting to the server
		connectSocket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);

		if (connectSocket == INVALID_SOCKET) {
			printf("socket failed with error: %ld\n", WSAGetLastError());
			WSACleanup();
			return 1;
		}

		// Connect to the server
		iResult = connect(connectSocket, ptr->ai_addr, (int)ptr->ai_addrlen);
		if (iResult == SOCKET_ERROR) {
			closesocket(connectSocket);
			connectSocket = INVALID_SOCKET;
			continue;
		}

		break;
	}

	// Deallocate the address info
	freeaddrinfo(result);

	if (connectSocket == INVALID_SOCKET) {
		printf("Unable to connect to server!\n");
		WSACleanup();
		return 1;
	}

	// Setup serial port connection and needed variables.
	SerialPort.Open(PORT_NUM, BAUD);

	Controller[20].value = 9;	//Verification Byte sent to make sure everything else ends up in the right location
	FillByteSize();

	while (true)
	{
		cycles++;
		UpdateControllerState();	//Updates all values on the controller
		WORD wButtons = g_Controllers[CONTROLLER1].state.Gamepad.wButtons;

		//Stores all of the values from the controller into the controller structure
		Controller[0].value = g_Controllers[CONTROLLER1].state.Gamepad.sThumbRX;
		Controller[1].value = g_Controllers[CONTROLLER1].state.Gamepad.sThumbRY;
		Controller[2].value = g_Controllers[CONTROLLER1].state.Gamepad.sThumbLX;
		Controller[3].value = g_Controllers[CONTROLLER1].state.Gamepad.sThumbLY;
		Controller[4].value = (g_Controllers[CONTROLLER1].state.Gamepad.bRightTrigger);
//.........这里部分代码省略.........
开发者ID:Sarasa1,项目名称:ROV,代码行数:101,代码来源:ROV_Drive.cpp

示例3: onFrame

void ZirkLeap::onFrame(const Leap::Controller& controller) {
    if(controller.hasFocus()) {
        Leap::Frame frame = controller.frame();
        if (mPointableId >= 0) {
            ourProcessor->setSelectedSource(mEditor->getCBSelectedSource()-1);
            Leap::Pointable p = frame.pointable(mPointableId);
            if (!p.isValid() || !p.isExtended()) {
                mPointableId = -1;
                mLastPositionValid = false;
            } else {
                Leap::Vector pos = p.tipPosition();
                const float zPlane1 = 50;	// 5 cm
                const float zPlane2 = 100;	// 10 cm
                
                if (pos.z < zPlane2) {
                    if (mLastPositionValid) {
                        //Leap Motion mouvement are calculated from the last position in order to have something dynamic and ergonomic
                        Leap::Vector delta = pos- mLastPosition;
                        
                        float scale = 3;
                        if (pos.z > zPlane1) {
                            float s = 1 - (pos.z - zPlane1) / (zPlane2 - zPlane1);
                            scale *= s;
                            
                        }
                        
                        int src = ourProcessor->getSelectedSource();
                        float fX, fY;
                        ourProcessor->getSources()[src].getXY(fX, fY);
                        fX += delta.x * scale;
                        fY -= delta.y * scale;
                        
                        //clamp coordinates to circle
                        float fCurR = hypotf(fX, fY);
                        if ( fCurR > ZirkOscAudioProcessor::s_iDomeRadius){
                            float fExtraRatio = ZirkOscAudioProcessor::s_iDomeRadius / fCurR;
                            fX *= fExtraRatio;
                            fY *= fExtraRatio;
                        }
                        
                        mEditor->move(src, fX, fY);
                    } else {
                        //std::cout << "pointable last pos not valid" << std::endl;
                    }
                    mLastPosition = pos;
                    mLastPositionValid = true;
                } else {
                    //std::cout << "pointable not touching plane" << std::endl;
                    mLastPositionValid = false;
                }
            }
        }
        if (mPointableId < 0) {
            Leap::PointableList pl = frame.pointables().extended();
            if (pl.count() > 0) {
                mPointableId = pl[0].id();
                //std::cout << "got new pointable: " << mPointableId << std::endl;
            }
        }
    }
}
开发者ID:flair2005,项目名称:ZirkOSC,代码行数:61,代码来源:ZirkLeap.cpp

示例4: main

int main()
{
	Leap::Controller controller;
	Leap::Frame frame;
	Leap::HandList hands;
	Leap::Hand h1;
	Leap::FingerList fingers;
	Leap::Finger index;
	Leap::Finger thumb;
	Leap::PointableList pointables;
	float indexX = 0, indexY = 0, indexZ = 0, thumbX = 0, thumbY = 0, thumbZ = 0, sum = 0, supersample[20];

	int i = 0;

	// Setup serial port connection and needed variables.
	HANDLE hSerial = CreateFile(L"COM6", GENERIC_WRITE | GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);

	if (hSerial != INVALID_HANDLE_VALUE)
	{
		printf("Port opened! \n");

		DCB dcbSerialParams;
		GetCommState(hSerial, &dcbSerialParams);

		dcbSerialParams.BaudRate = CBR_14400;
		dcbSerialParams.ByteSize = 8;
		dcbSerialParams.Parity = NOPARITY;
		dcbSerialParams.StopBits = ONESTOPBIT;

		SetCommState(hSerial, &dcbSerialParams);

		Sleep(1000);
	}

	else
	{
		if (GetLastError() == ERROR_FILE_NOT_FOUND)
		{
			printf("Serial port doesn't exist! \n");
		}

		printf("Error while setting up serial port! \n");
	}

	Controller[20].value = 9;	//Verification Byte sent to make sure everything else ends up in the right location
	FillByteSize();

	while (true)
	{
		UpdateControllerState();	//Updates all values on the controller
		WORD wButtons = g_Controllers[CONTROLLER1].state.Gamepad.wButtons;

		//Stores all of the values from the controller into the controller structure
		Controller[0].value = g_Controllers[CONTROLLER1].state.Gamepad.sThumbRX;
		Controller[1].value = g_Controllers[CONTROLLER1].state.Gamepad.sThumbRY;
		Controller[2].value = g_Controllers[CONTROLLER1].state.Gamepad.sThumbLX;
		Controller[3].value = g_Controllers[CONTROLLER1].state.Gamepad.sThumbLY;
		Controller[4].value = (g_Controllers[CONTROLLER1].state.Gamepad.bRightTrigger);
		Controller[5].value = (g_Controllers[CONTROLLER1].state.Gamepad.bLeftTrigger);
		Controller[6].value = (wButtons & XINPUT_GAMEPAD_RIGHT_THUMB);
		Controller[7].value = (wButtons & XINPUT_GAMEPAD_LEFT_THUMB);
		Controller[8].value = (wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER);
		Controller[9].value = (wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER);
		Controller[10].value = (wButtons & XINPUT_GAMEPAD_DPAD_UP);
		Controller[11].value = (wButtons & XINPUT_GAMEPAD_DPAD_DOWN);
		Controller[12].value = (wButtons & XINPUT_GAMEPAD_DPAD_LEFT);
		Controller[13].value = (wButtons & XINPUT_GAMEPAD_DPAD_RIGHT);
		Controller[14].value = (wButtons & XINPUT_GAMEPAD_A);
		Controller[15].value = (wButtons & XINPUT_GAMEPAD_B);
		Controller[16].value = (wButtons & XINPUT_GAMEPAD_Y);
		Controller[17].value = (wButtons & XINPUT_GAMEPAD_X);
		Controller[18].value = (wButtons & XINPUT_GAMEPAD_START);
		Controller[19].value = (wButtons & XINPUT_GAMEPAD_BACK);

		CheckDeadZone();

		if (controller.isConnected() == true)
		{
			sum = 0;
			frame = controller.frame();
			hands = frame.hands();
			h1 = hands[0];
			fingers = frame.fingers();
			thumb = fingers[0];
			index = fingers[1];
			pointables = frame.pointables();

			Leapvalues[0].value = h1.palmVelocity().x;
			Leapvalues[1].value = h1.palmVelocity().y;
			Leapvalues[2].value = h1.palmVelocity().z;
			Leapvalues[3].value = h1.direction().pitch()*Leap::RAD_TO_DEG;
			Leapvalues[4].value = h1.direction().yaw()*Leap::RAD_TO_DEG;

			indexX = index.tipPosition().x;
			indexY = index.tipPosition().y;
			indexZ = index.tipPosition().z;

			thumbX = thumb.tipPosition().x;
			thumbY = thumb.tipPosition().y;
			thumbZ = thumb.tipPosition().z;
//.........这里部分代码省略.........
开发者ID:Sarasa1,项目名称:ROV,代码行数:101,代码来源:ROV_Drive.cpp

示例5: main


//.........这里部分代码省略.........
				//
				IplImage wimage = captureFrameMat;
				//static IplImage wimage = grayscaleFrame;
				//cvCopy( image, wimage);
				image = &wimage;
			}

		}catch(char *e)
		{
			printf("%s\n",e);
		}
#endif
		}

        //2014.03.09 add
		if((mLeapnot != true)&&(pLeapData.mLeapMode == true)&&(leapController.isConnected()))
		{
			frame = leapController.frame(); // controller is a Leap::Controller object
			hands = frame.hands();
			firstHand = hands[0];

			pitch_pre = pitch;
			pitch = firstHand.direction().pitch();//前p:-0.5 後p: 0.9
			pitch = pitch_pre*Para_pre + pitch*Para_cur;	//Para_pre:0.80 Para_cur:0.20

			yaw_pre = yaw;    //左y:-1.0 右y: 0.7
			yaw = firstHand.direction().yaw();    //左y:-1.0 右y: 0.7
			yaw = yaw_pre*Para_pre + yaw*Para_cur;

			roll_pre = roll; //左R: 0.8 右R:-1.0
			roll = firstHand.palmNormal().roll(); //左R: 0.8 右R:-1.0
			roll = roll_pre*Para_pre + roll*Para_cur;

			PosX = frame.pointables().leftmost().tipPosition().x;       //左右   左-150 〜 右 150
			PosY = frame.pointables().leftmost().tipPosition().y;       //上下昇降 下  50 〜 上 300
			PosZ = frame.pointables().leftmost().tipPosition().z * (1); //前後   手前-100 〜 奥 100

			if(pLeapData.mLeapDebugPrint == true){
				printf("%03d XYZ:%03.02f:%03.02f:%03.02f p:%03.02f y:%03.02f r:%03.02f TF:%01i: %i\n",mSoundCommandcounter, PosX,PosY,PosZ,pitch,yaw,roll,(int)mTakOffFlag,mSendCommandcounter);
			}

			//LeapMotion Value set
			//LeapMotionに近づけると TakeOFF
			if((PosY > 50) && (PosY < 75) && (mTakOffFlag == true))
			{
				if(mNonDronDebug == false)
				{
					if (ardrone.onGround())
					{
						mTakOffFlag = false;
					}else
					{
						if(mSoundCommandcounter>mSoundCommandOKcounter){
							sndPlaySound("..\\..\\src\\resource\\HackathonUser1orimasu.wav", SND_ASYNC);//orimasu
							mSoundCommandcounter = 0;
						}
						
						if(!mNonDronRDebug) {
							ardrone.landing();
						}

						mTakOffFlag = false;
						mSendCommandflag = true;

						if(!mNonDronRDebug) 
							if((pLeapData.mLeapMode == true)&&(mArDroneCommandFlag == false))
开发者ID:nakajimakou1,项目名称:cvdrone-master_leap_FaceDetect,代码行数:67,代码来源:main.cpp

示例6: oleap_bang


//.........这里部分代码省略.........
        sprintf(buff,"/hand/%d/palm/velocity/z",i+1);
        oleap_bundleMessage(bundle,buff,velocity.z);
        
        sprintf(buff,"/hand/%d/palm/normal/x",i+1);
        oleap_bundleMessage(bundle,buff,normal.x);
        
        sprintf(buff,"/hand/%d/palm/normal/y",i+1);
        oleap_bundleMessage(bundle,buff,normal.y);
        
        sprintf(buff,"/hand/%d/palm/normal/z",i+1);
        oleap_bundleMessage(bundle,buff,normal.z);
        
        
        sprintf(buff,"/hand/%d/sphere/id",i);
        oleap_bundleMessage(bundle,buff,hand_id);
        
        sprintf(buff,"/hand/%d/sphere/frame_id",i);
        oleap_bundleMessage(bundle,buff,frame_id);
        
        sprintf(buff,"/hand/%d/sphere/center/x",i+1);
        oleap_bundleMessage(bundle,buff,sphereCenter.x);
        
        sprintf(buff,"/hand/%d/sphere/center/y",i+1);
        oleap_bundleMessage(bundle,buff,sphereCenter.y);
        
        sprintf(buff,"/hand/%d/sphere/center/z",i+1);
        oleap_bundleMessage(bundle,buff,sphereCenter.z);
        
        sprintf(buff,"/hand/%d/sphere/radius",i+1);
        oleap_bundleMessage(bundle,buff,sphereRadius);
    
        
        
        const Leap::PointableList pointables = frame.pointables();
        const int count = pointables.count();

        for(size_t j = 0; j < count; j++){

            sprintf(buff,"/hand/%d/pointable/%d/id",i+1,j+1);
            oleap_bundleMessage(bundle,buff,pointables.operator[](j).id());
            
            sprintf(buff,"/hand/%d/pointable/%d/length",i+1,j+1);
            oleap_bundleMessage(bundle,buff,pointables.operator[](j).length());
            
            sprintf(buff,"/hand/%d/pointable/%d/width",i+1,j+1);
            oleap_bundleMessage(bundle,buff,pointables.operator[](j).width());
        
            sprintf(buff,"/hand/%d/pointable/%d/direction/x",i+1,j+1);
            oleap_bundleMessage(bundle,buff,pointables.operator[](j).direction().x);
        
            sprintf(buff,"/hand/%d/pointable/%d/direction/y",i+1,j+1);
            oleap_bundleMessage(bundle,buff,pointables.operator[](j).direction().y);
        
            sprintf(buff,"/hand/%d/pointable/%d/direction/z",i+1,j+1);
            oleap_bundleMessage(bundle,buff,pointables.operator[](j).direction().z);
        
            sprintf(buff,"/hand/%d/pointable/%d/isFinger",i+1,j+1);
            oleap_bundleMessage(bundle,buff,pointables.operator[](j).isFinger());
            
            sprintf(buff,"/hand/%d/pointable/%d/isTool",i+1,j+1);
            oleap_bundleMessage(bundle,buff,pointables.operator[](j).isTool());
        
            sprintf(buff,"/hand/%d/pointable/%d/position/tip/x",i+1,j+1);
            oleap_bundleMessage(bundle,buff,pointables.operator[](j).tipPosition().x);
            
            sprintf(buff,"/hand/%d/pointable/%d/position/tip/y",i+1,j+1);
开发者ID:KevinGutowski,项目名称:o.io.leap,代码行数:67,代码来源:o.io.leap.cpp

示例7: onFrame

void DefaultQtLeapMouseHandler::onFrame(const Leap::Frame &frame)
{
    /////// MOUSE EVENTS /////////
    // MOUSE BUTTON PRESSED
    // MOUSE BUTTON RELEASED
    // MOUSE MOVE

    if (this->listeners.empty())
        return ;

    Leap::Pointable pointer = frame.pointable(this->savedMousePointableId);
    if (!pointer.isValid())
    {
        pointer = frame.pointables().frontmost();
        this->savedMousePointableId = pointer.id();
    }

    bool forceRelease = (frame.pointables().count() == 0 && this->mousePressed);
    QMouseEvent::Type frameMouseEvent = QMouseEvent::None;
    QPointF globalPointerPos = QtLeapUtils::convertPointablePosToScreenPos(frame.interactionBox(), pointer);
    Qt::MouseButton button = Qt::NoButton;
    Qt::MouseButtons buttons = Qt::NoButton;

    // FINGER TOUCHING AND NO PREVIOUS PRESS -> SETTING BUTTON PRESS
    if (pointer.touchDistance() <= 0 &&
            pointer.touchZone() == Leap::Pointable::ZONE_TOUCHING &&
            !this->mousePressed)
    {
        this->mousePressed = true;
        frameMouseEvent = QMouseEvent::MouseButtonPress;
        button = Qt::LeftButton;
    }
    else if (this->mousePressed && (pointer.touchDistance() > 0 ||
                                    pointer.touchZone() == Leap::Pointable::ZONE_NONE ||
                                    forceRelease))         // FINGER NOT TOUCHING AND PREVIOUS PRESS -> RELEASING BUTTON PRESS
    {
        frameMouseEvent = QMouseEvent::MouseButtonRelease;
        this->mousePressed = false;
        button = Qt::LeftButton;
    }
    else if (frameMouseEvent == QMouseEvent::None &&     // FINGER IN TOUCHING OR HOVERING ZONE AND NO BUTTON PRESS / RELEASE CHANGE -> MouseMove
             pointer.touchZone() != Leap::Pointable::ZONE_NONE
             && globalPointerPos.toPoint() != this->previousPos)
    {
        frameMouseEvent = QMouseEvent::MouseMove;
        this->previousPos = globalPointerPos.toPoint();
        QCursor::setPos(this->previousPos);
    }

    if (this->mousePressed)
        buttons |= Qt::LeftButton;

    if (frameMouseEvent != QMouseEvent::None)
        foreach (QObject *listener, this->listeners)
            QCoreApplication::postEvent(listener, new QMouseEvent(frameMouseEvent,
                                                                  QtLeapUtils::convertGlobalPosToLocalPos(listener, globalPointerPos),
                                                                  globalPointerPos,
                                                                  button,
                                                                  buttons,
                                                                  Qt::NoModifier));
}
开发者ID:PhuongSL,项目名称:QtLeapMotionLibrary,代码行数:61,代码来源:DefaultQtLeapMouseHandler.cpp


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