SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
WAIInterface.cpp File Reference
#include <WAI.h>
#include <WAIMath.h>
Include dependency graph for WAIInterface.cpp:

Go to the source code of this file.

Classes

struct  WAIMapPointCoordinate
 

Functions

static WAI::WAI wai ("")
 
WAI_API void wai_setDataRoot (const char *dataRoot)
 
WAI_API void wai_setMode (WAI::ModeType modeType)
 
WAI_API void wai_getMapPoints (WAIMapPointCoordinate **mapPointCoordinatePtr, int *mapPointCount)
 
WAI_API void wai_releaseMapPoints (WAIMapPointCoordinate **mapPointCoordinatePtr)
 
WAI_API void wai_activateSensor (WAI::SensorType sensorType, void *sensorInfo)
 
WAI_API void wai_updateCamera (WAI::CameraFrame *frameRGB, WAI::CameraFrame *frameGray)
 
WAI_API bool wai_whereAmI (WAI::M4x4 *pose)
 
WAI_API int wai_getState (char *buffer, int size)
 
WAI_API void wai_registerDebugCallback (DebugLogCallback callback)
 

Variables

static WAI::ModeOrbSlam2mode = nullptr
 

Function Documentation

◆ wai()

static WAI::WAI wai ( ""  )
static

◆ wai_activateSensor()

WAI_API void wai_activateSensor ( WAI::SensorType  sensorType,
void sensorInfo 
)

Definition at line 63 of file WAIInterface.cpp.

64 {
65  WAI_LOG("activateSensor called");
66  wai.activateSensor(sensorType, sensorInfo);
67 }
static WAI::WAI wai("")

◆ wai_getMapPoints()

WAI_API void wai_getMapPoints ( WAIMapPointCoordinate **  mapPointCoordinatePtr,
int *  mapPointCount 
)

Definition at line 25 of file WAIInterface.cpp.

27 {
28  if (!mode)
29  {
30  WAI_LOG("mode not set. Call wai_setMode first.");
31  return;
32  }
33 
34  std::vector<WAIMapPoint*> mapPoints = mode->getMapPoints();
35  *mapPointCoordinatePtr = (WAIMapPointCoordinate*)malloc(mapPoints.size() * sizeof(WAIMapPointCoordinate));
36  WAIMapPointCoordinate* mapPointCoordinate = *mapPointCoordinatePtr;
37 
38  int count = 0;
39 
40  for (WAIMapPoint* mapPoint : mapPoints)
41  {
42  if (!mapPoint->isBad())
43  {
44  *mapPointCoordinate = {
45  mapPoint->worldPosVec().x,
46  mapPoint->worldPosVec().y,
47  mapPoint->worldPosVec().z,
48  };
49 
50  mapPointCoordinate++;
51  count++;
52  }
53  }
54 
55  *mapPointCount = count;
56 }
static WAI::ModeOrbSlam2 * mode
Definition: WAIInterface.cpp:5
std::vector< WAIMapPoint * > getMapPoints()

◆ wai_getState()

WAI_API int wai_getState ( char *  buffer,
int  size 
)

Definition at line 111 of file WAIInterface.cpp.

112 {
113  WAI_LOG("getState called");
114  int result = 0;
115 
116  if (mode)
117  {
118  std::string state = mode->getPrintableState();
119 
120  if ((state.size() + 1) < size)
121  {
122  size = state.size() + 1;
123  }
124 
125  result = size;
126  char* c = buffer;
127  const char* s = state.c_str();
128 
129  strncpy(c, s, size);
130  }
131 
132  return result;
133 }
The SLScene class represents the top level instance holding the scene structure.
Definition: SLScene.h:47
std::string getPrintableState()

◆ wai_registerDebugCallback()

WAI_API void wai_registerDebugCallback ( DebugLogCallback  callback)

Definition at line 135 of file WAIInterface.cpp.

136 {
137  registerDebugCallback(callback);
138 }

◆ wai_releaseMapPoints()

WAI_API void wai_releaseMapPoints ( WAIMapPointCoordinate **  mapPointCoordinatePtr)

Definition at line 58 of file WAIInterface.cpp.

59 {
60  delete *mapPointCoordinatePtr;
61 }

◆ wai_setDataRoot()

WAI_API void wai_setDataRoot ( const char *  dataRoot)

Definition at line 13 of file WAIInterface.cpp.

14 {
15  WAI_LOG("dataroot set to %s", dataRoot);
16  wai.setDataRoot(dataRoot);
17 }

◆ wai_setMode()

WAI_API void wai_setMode ( WAI::ModeType  modeType)

Definition at line 19 of file WAIInterface.cpp.

20 {
21  WAI_LOG("setMode called");
22  mode = (WAI::ModeOrbSlam2*)wai.setMode(modeType);
23 }

◆ wai_updateCamera()

WAI_API void wai_updateCamera ( WAI::CameraFrame *  frameRGB,
WAI::CameraFrame *  frameGray 
)

Definition at line 69 of file WAIInterface.cpp.

70 {
71  WAI_LOG("updateCamera called");
72  cv::Mat cvFrameRGB = cv::Mat(frameRGB->height,
73  frameRGB->width,
74  CV_8UC3,
75  frameRGB->memory,
76  frameRGB->pitch);
77  cv::Mat cvFrameGray = cv::Mat(frameGray->height,
78  frameGray->width,
79  CV_8UC1,
80  frameGray->memory,
81  frameGray->pitch);
82 
83  WAI::CameraData sensorData = {&cvFrameGray, &cvFrameRGB};
84 
85  wai.updateSensor(WAI::SensorType_Camera, &sensorData);
86 }

◆ wai_whereAmI()

WAI_API bool wai_whereAmI ( WAI::M4x4 pose)

Definition at line 88 of file WAIInterface.cpp.

89 {
90  WAI_LOG("whereAmI called");
91  bool result = 0;
92 
93  cv::Mat cvPose = cv::Mat(4, 4, CV_32F);
94  result = wai.whereAmI(&cvPose);
95 
96  if (result)
97  {
98  WAI_LOG("WAI knows where I am");
99  for (int y = 0; y < 4; y++)
100  {
101  for (int x = 0; x < 4; x++)
102  {
103  pose->e[x][y] = cvPose.at<float>(x, y);
104  }
105  }
106  }
107 
108  return result;
109 }
float e[4][4]
Definition: WAIMath.h:136

Variable Documentation

◆ mode

WAI::ModeOrbSlam2* mode = nullptr
static

Definition at line 5 of file WAIInterface.cpp.