Advertisement
Guest User

FOVE C++ example

a guest
Mar 7th, 2017
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.14 KB | None | 0 0
  1. #include "IFVRHeadset.h"
  2. #include "FoveTypes.h"
  3. #include <thread>
  4. #include <iostream>
  5.  
  6. int main(int argc, char* argv)
  7. {
  8.     Fove::IFVRHeadset* headsetReference = Fove::GetFVRHeadset();
  9.     headsetReference->Initialise(Fove::EFVR_ClientCapabilities::Gaze);
  10.  
  11.     if (headsetReference->CheckSoftwareVersions() != Fove::EFVR_ErrorCode::None)
  12.     {
  13.         // version mismatch
  14.         std::cout << "Wrong version of software" << std::endl;
  15.     }
  16.  
  17.     while (!headsetReference->IsHardwareReady()) // wait for hardware to be ready
  18.     {
  19.         std::cout << "Please connect your FOVE" << std::endl;
  20.         std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  21.     }
  22.  
  23.     std::cout << "Please wait for eye tracking to become available..." << std::endl;
  24.     while (!headsetReference->IsEyeTrackingReady()) // wait for eye tracking to be ready
  25.     {
  26.         std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  27.     }
  28.  
  29.     if (!headsetReference->IsEyeTrackingCalibrated())
  30.     {
  31.         std::cout << "Not calibrated" << std::endl;
  32.         if (headsetReference->EnsureEyeTrackingCalibration() == Fove::EFVR_ErrorCode::None)
  33.         {
  34.             std::this_thread::sleep_for(std::chrono::milliseconds(500));
  35.             while (!headsetReference->IsEyeTrackingCalibrated())
  36.             {
  37.                 // waiting for calibration to complete
  38.                 std::this_thread::sleep_for(std::chrono::milliseconds(500));
  39.             }
  40.         }
  41.     }
  42.  
  43.     int i = 0;
  44.     while (i < 100) // arbitrary end condition
  45.     {
  46.         // Get gaze data
  47.         Fove::SFVR_GazeVector gv = headsetReference->GetGazeVector(Fove::EFVR_Eye::Left);
  48.         if (gv.error == Fove::EFVR_ErrorCode::None)
  49.         {
  50.             std::cout << gv.timestamp << " - Left Eye X: " << gv.vector.x << ", Y: " << gv.vector.y << std::endl;
  51.             std::this_thread::sleep_for(std::chrono::milliseconds(8));
  52.             i++;
  53.         }
  54.         else
  55.         {
  56.             std::cout << "Error getting gaze vector: " << (int)gv.error << std::endl;
  57.             std::this_thread::sleep_for(std::chrono::milliseconds(500));
  58.         }
  59.     }
  60.  
  61.     getchar();
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement