35#define GetCurrentDir _getcwd
38#define GetCurrentDir getcwd
43 char buff[FILENAME_MAX];
45 std::string current_working_dir(buff);
47 for (
unsigned int i = 0; i < current_working_dir.length(); i++)
49 if (current_working_dir.substr(i, 1) ==
"\\")
50 current_working_dir.replace(i, 1,
"/");
52 return current_working_dir;
84 mParams.aruco_Dictionary =
"ARUCO";
85 mParams.aruco_DetectionMode =
"DM_NORMAL";
86 mParams.aruco_CornerRefimentMethod =
"CORNER_LINES";
87 mParams.aruco_minMarkerSize = 0;
90 mVocFile = CopyFileFromAssetToSD(
"btdata/orb_vocab.fbow",
"orb_vocab.fbow",
"btdata");
95 mSlam =
new ucoslam::UcoSlam();
96 mMap = std::make_shared<ucoslam::Map>();
100 mSlam->setParams(mMap, mParams, mVocFile);
105 catch (std::runtime_error)
116 mSlam->waitForFinished();
125void Sslam::BuildCameraParam(
const aruco::CameraParameters &camparam)
134 mCamParams.CamSize = camparam.CamSize;
135 mCamParams.CameraMatrix = camparam.CameraMatrix;
136 mCamParams.Distorsion = camparam.Distorsion;
140void Sslam::InitDetector()
142 boost::unique_lock<boost::recursive_mutex> ld(mUpdateMutex);
147 mSlam->waitForFinished();
149 mSlam->setParams(mMap, mParams, mVocFile);
151 catch (std::exception &)
171 if (mSlam && !image.empty())
193 nsize.width = (int)((
float)mLastData.
gray.cols * mScale);
194 nsize.height = (int)((
float)mLastData.
gray.rows * mScale);
198 if (!mSlam || (((
int)((
float)mLastData.camParam.CamSize.width * mScale)) != mCamParams.CamSize.width || ((int)((
float)mLastData.camParam.CamSize.height * mScale)) != mCamParams.CamSize.height))
205 BuildCameraParam(mLastData.camParam);
210 cv::resize(mLastData.
gray, mLastData.
gray, mCamParams.CamSize, 0, 0, cv::INTER_LINEAR);
213 if (!mLastData.
image.empty() && mSlam)
215 cv::Mat mat = mSlam->process(mLastData.
gray, mCamParams, mFrameIdx);
220 cv::Mat Rwc(3, 3, CV_32F);
221 cv::Mat twc(3, 1, CV_32F);
223 Rwc = mat.rowRange(0, 3).colRange(0, 3).t();
224 twc = -Rwc * mat.rowRange(0, 3).col(3);
227 double modelview_matrix[16];
228 modelview_matrix[0 + 0 * 4] = Rwc.at<
float>(0, 0);
229 modelview_matrix[0 + 1 * 4] = Rwc.at<
float>(1, 0);
230 modelview_matrix[0 + 2 * 4] = Rwc.at<
float>(2, 0);
231 modelview_matrix[0 + 3 * 4] = 0.0;
233 modelview_matrix[1 + 0 * 4] = Rwc.at<
float>(0, 1);
234 modelview_matrix[1 + 1 * 4] = Rwc.at<
float>(1, 1);
235 modelview_matrix[1 + 2 * 4] = Rwc.at<
float>(2, 1);
236 modelview_matrix[1 + 3 * 4] = 0.0;
238 modelview_matrix[2 + 0 * 4] = Rwc.at<
float>(0, 2);
239 modelview_matrix[2 + 1 * 4] = Rwc.at<
float>(1, 2);
240 modelview_matrix[2 + 2 * 4] = Rwc.at<
float>(2, 2);
241 modelview_matrix[2 + 3 * 4] = 0.0;
243 modelview_matrix[3 + 0 * 4] = twc.at<
float>(0);
244 modelview_matrix[3 + 1 * 4] = twc.at<
float>(1);
245 modelview_matrix[3 + 2 * 4] = twc.at<
float>(2);
246 modelview_matrix[3 + 3 * 4] = 1.0;
248 mLastCamPos =
Vector3(twc.at<
float>(0), twc.at<
float>(1), twc.at<
float>(2));
250 mLastCamQuat = Quaternion::FromRotationMatrix(modelview_matrix, mLastData.
reversedBitmap);
257 boost::this_thread::sleep_for(boost::chrono::milliseconds(1));
void GetLastData(LASTDATA &data)
static ArManager * GetInstance()
Vector3 GetCameraPosition()
BtQuaternion GetCameraOrientation()
void DrawLandmarks(cv::Mat image)
std::string GetCurrentWorkingDir(void)