BitmapToolkit Scol plugin
ArTkMarker.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
25/*
26 Toolkit based on OpenCV library
27 First version : dec 2010
28 Author : Bastien BOURINEAU
29*/
30
31#ifndef __BTK_ARTKMARKER_H__
32#define __BTK_ARTKMARKER_H__
33
34#include <vector>
35#include <iostream>
36#include "cameraparameters.h"
37#include "ArMarker.h"
38#include "Prerequisites.h"
39#include <boost/thread.hpp>
40#include <iostream>
41
42#include <KPM/kpm.h>
43#include <AR2/tracking.h>
44#include <AR/arFilterTransMat.h>
45
50class ArTkMarker : public ArMarker
51{
52protected:
53 cv::Mat m_image;
56public:
57 std::vector<cv::Point2f> m_lastCorner;
58
61 ArTkMarker(std::string filePath, unsigned int nid, float size, unsigned int maxFeatures = 600);
62
65 ArTkMarker(cv::Mat tpl, unsigned int mid, float size, unsigned int maxFeatures = 600);
66
70
73 void SetTrackedImage(cv::Mat tpl);
74
77 void RegisterNextFrame(cv::Point point, cv::Size size);
78
81 bool GetWarpedMarker(cv::Mat &image);
82
85 bool RegisterCurrentFrame(const cv::Mat &frame, cv::Size camsize, float tscale = 1.0f);
86 bool TrackFrame(AR2HandleT* ar2handle, const cv::Mat &color, const cv::Mat &frame, ArCameraParam &camParams, const bool &reverse);
87 void StartTracking(cv::Mat color, const float camPose[3][4], ArCameraParam &camParams, const bool &reverse);
88
89 int GetPageNum();
90 void SetPageNum(int page);
91 KpmRefDataSet* GetDataSet();
92
93 bool SaveData(std::string path);
94 bool IsTracked();
95 bool IsTrained();
96private:
97 boost::recursive_mutex m_mutex;
98 boost::recursive_mutex m_dataMutex;
99 boost::recursive_mutex m_trainningMutex;
100 boost::thread m_trainingThread;
101 float mCamPose[3][4];
102 ARdouble mTackingPos[3][4];
103 int mNumGoodTracking;
104 int m_pageNum;
105 unsigned int m_maxFeatures;
106 std::string m_file;
107 cv::Mat m_warped;
108
109 KpmRefDataSet* m_refDataSet;
110 AR2SurfaceSetT* m_surfaceSet;
111 AR2FeatureSetT* m_featureSet;
112 ARFilterTransMatInfo* m_ftmi;
113 bool m_cancelTrainning;
114 std::vector<cv::Point2f> m_pcorners;
115 cv::Size m_lastFrameSize;
116
117 bool m_registerNextFrame;
118 cv::Point m_cropPos;
119 cv::Size m_cropSize;
120 cv::Size m_imageSize;
121 FilterDoubleExponentialDouble m_CornerSmoothers;
122
125 bool initTrackingPicture();
126
129 void CommonConstructor();
130
131 void SetTracked(bool state);
132
133 void SetTrainned(bool state);
134
135 void ComputeMatrix(ArCameraParam &camParams, bool reverse);
136
137 void WarpMarkerImage(cv::Mat color);
138
139 bool LoadData(std::string filename);
140};
141
143{
144public:
147
148 bool LoadData(boost::filesystem::path path, KpmRefDataSet** refDataSetPtr, AR2SurfaceSetT** surfaceSetPtr);
149private:
150 bool LoadRefDataSet(boost::filesystem::path path, KpmRefDataSet** refDataSetPtr);
151 bool LoadFeatureSet(boost::filesystem::path path, AR2SurfaceSetT** surfaceSetPtr);
152 AR2FeatureSetT* ReadFeatureSet(boost::filesystem::path path);
153 AR2ImageT* GetImageLayer(AR2ImageT* src, float dpi);
154 AR2ImageSetT* GetImageSet(boost::filesystem::path path);
155 AR2ImageSetT* LoadRawImageSet(FILE* fp);
156};
157
158#endif
This class represents a marker. It is a vector of the fours corners ot the marker.
Definition ArTkMarker.h:51
void SetPageNum(int page)
bool m_isTrained
Definition ArTkMarker.h:55
bool GetWarpedMarker(cv::Mat &image)
bool TrackFrame(AR2HandleT *ar2handle, const cv::Mat &color, const cv::Mat &frame, ArCameraParam &camParams, const bool &reverse)
bool IsTracked()
bool m_isTracked
Definition ArTkMarker.h:54
bool SaveData(std::string path)
cv::Mat m_image
Definition ArTkMarker.h:53
bool RegisterCurrentFrame(const cv::Mat &frame, cv::Size camsize, float tscale=1.0f)
void RegisterNextFrame(cv::Point point, cv::Size size)
int GetPageNum()
std::vector< cv::Point2f > m_lastCorner
Definition ArTkMarker.h:57
void StartTracking(cv::Mat color, const float camPose[3][4], ArCameraParam &camParams, const bool &reverse)
bool IsTrained()
KpmRefDataSet * GetDataSet()
void SetTrackedImage(cv::Mat tpl)
bool LoadData(boost::filesystem::path path, KpmRefDataSet **refDataSetPtr, AR2SurfaceSetT **surfaceSetPtr)