SLAMflex SE  0.1.0
SLAMflex provides detection and tracking of dominant planes for smartphone devices. This plane can then be used to show AR content relative to the plane orientation. The detection of plane is performed in the field of view of the smartphone camera. In subsequent frames it is tracked. The interface returns the plane position and orientation.
System.cpp
Go to the documentation of this file.
1 // Copyright 2008 Isis Innovation Limited
2 #include "System.h"
3 #include <stdlib.h>
4 #include <vector>
5 
6 
7 #include "ATANCamera.h"
8 #include "MapMaker.h"
9 #include "Tracker.h"
10 
11 using namespace CVD;
12 using namespace std;
13 
14 vector<float> System::getCurrentPose()
15 {
16  SE3<> se3pose=mpTracker->GetCurrentPose();
17  vector<float> pose(7);
18  Vector<3> translation,rotation;
19 
20  translation=se3pose.get_translation();
21  rotation=se3pose.get_rotation().ln();
22  pose[0]=translation[0];
23  pose[1]=translation[1];
24  pose[2]=translation[2];
25  pose[3]=norm(rotation)/3.14159*360.0;
26  pose[4]=rotation[0]/pose[3];
27  pose[5]=rotation[1]/pose[3];
28  pose[6]=rotation[2]/pose[3];
29  return pose;
30 }
31 
33 {
34  mpCamera = new ATANCamera("Camera");
35  mpMap = new Map;
36  mpMapMaker = new MapMaker(*mpMap, *mpCamera);
37  mpTracker = new Tracker(ImageRef(640,480), *mpCamera, *mpMap, *mpMapMaker);
38  mimFrameBW.resize(ImageRef(640,480));
39  mbDone = false;
40 };
41 
43 {
44  mpTracker->SetSendMessageToUnity(sm);
45  mpMapMaker->SetSendMessageToUnity(sm);
46 }
47 
49 {
50  mpTracker->StartTracking();
51 }
52 
54 {
55  mpTracker->StopTracking();
56 }
57 
59 {
60  mpTracker->GetCurrentDetectionState();
61 }
62 
63 void System::RunOneFrame(unsigned char *bwImage,uint hnd)
64 {
65  // Grab video frame in black and white
66  mimFrameBW.copy_from(BasicImage<byte>(bwImage,ImageRef(640,480)));
67 
68  mpTracker->TrackFrame(mimFrameBW, hnd,0);
69 
70  string s=mpTracker->GetMessageForUser();
71 
72 }
73 
74 void System::GUICommandCallBack(void *ptr, string sCommand, string sParams)
75 {
76  if(sCommand=="quit" || sCommand == "exit")
77  static_cast<System*>(ptr)->mbDone = true;
78 }
79 
80 std::string System::getVCorners()
81 {
82  return mpTracker->getVCorners();
83 }
84 
85 
86 
87 
88 
89 
90 
91 
SO3< Precision > & get_rotation()
Returns the rotation part of the transformation as a SO3.
Definition: se3.h:64
void SendTrackerStartSig()
Definition: System.cpp:48
static void GUICommandCallBack(void *ptr, std::string sCommand, std::string sParams)
Definition: System.cpp:74
void RunOneFrame(unsigned char *bwImage, uint hnd)
Definition: System.cpp:63
Definition: abs.h:24
Precision norm(const Vector< Size, Precision, Base > &v)
Definition: helpers.h:70
Definition: se3.h:50
std::string getVCorners()
Definition: System.cpp:80
unsigned char * bwImage
Black and white image.
Definition: SLAMflex.cpp:22
Definition: Map.h:24
Vector< 3, Precision > & get_translation()
Returns the translation part of the transformation as a Vector.
Definition: se3.h:69
void SendTrackerKillSig()
Definition: System.cpp:53
void SetSendMessageToUnity(SendMessage sm)
Definition: System.cpp:42
System()
Definition: System.cpp:32
std::vector< float > getCurrentPose()
Definition: System.cpp:14
DetectionState GetCurrentDetectionState()
Definition: System.cpp:58
DetectionState
Enum for state of SLAM detection process.
Definition: SLAMflex.h:11