summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_aruco
diff options
context:
space:
mode:
Diffstat (limited to 'ftnoir_tracker_aruco')
-rw-r--r--ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp148
-rw-r--r--ftnoir_tracker_aruco/ftnoir_tracker_aruco.h13
-rw-r--r--ftnoir_tracker_aruco/include/aruco.h29
-rw-r--r--ftnoir_tracker_aruco/include/arucofidmarkers.h15
-rw-r--r--ftnoir_tracker_aruco/include/board.h168
-rw-r--r--ftnoir_tracker_aruco/include/boarddetector.h139
-rw-r--r--ftnoir_tracker_aruco/include/cameraparameters.h6
-rw-r--r--ftnoir_tracker_aruco/include/cvdrawingutils.h19
-rw-r--r--ftnoir_tracker_aruco/include/exports.h6
-rw-r--r--ftnoir_tracker_aruco/include/marker.h16
-rw-r--r--ftnoir_tracker_aruco/include/markerdetector.h56
-rw-r--r--ftnoir_tracker_aruco/trans_calib.h2
12 files changed, 149 insertions, 468 deletions
diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
index e216d319..a1e15721 100644
--- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
+++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
@@ -8,13 +8,13 @@
#include "ftnoir_tracker_aruco.h"
#include "ui_aruco-trackercontrols.h"
#include "facetracknoir/plugin-api.hpp"
-#include <cmath>
#include <QMutexLocker>
-#include <aruco.h>
-#include <opencv2/opencv.hpp>
-#include <opencv/highgui.h>
+#include "include/markerdetector.h"
+#include <opencv2/core/core.hpp>
+#include <opencv2/highgui/highgui.hpp>
#include <vector>
#include <cstdio>
+#include <cmath>
#if defined(_WIN32)
# undef NOMINMAX
@@ -29,51 +29,51 @@
static QList<QString> get_camera_names(void) {
QList<QString> ret;
#if defined(_WIN32)
- // Create the System Device Enumerator.
- HRESULT hr;
- ICreateDevEnum *pSysDevEnum = NULL;
- hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum);
- if (FAILED(hr))
- {
- return ret;
- }
- // Obtain a class enumerator for the video compressor category.
- IEnumMoniker *pEnumCat = NULL;
- hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);
-
- if (hr == S_OK) {
- // Enumerate the monikers.
- IMoniker *pMoniker = NULL;
- ULONG cFetched;
- while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) {
- IPropertyBag *pPropBag;
- hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
- if (SUCCEEDED(hr)) {
- // To retrieve the filter's friendly name, do the following:
- VARIANT varName;
- VariantInit(&varName);
- hr = pPropBag->Read(L"FriendlyName", &varName, 0);
- if (SUCCEEDED(hr))
- {
- // Display the name in your UI somehow.
- QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal));
- ret.append(str);
- }
- VariantClear(&varName);
-
- ////// To create an instance of the filter, do the following:
- ////IBaseFilter *pFilter;
- ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter,
- //// (void**)&pFilter);
- // Now add the filter to the graph.
- //Remember to release pFilter later.
- pPropBag->Release();
- }
- pMoniker->Release();
- }
- pEnumCat->Release();
- }
- pSysDevEnum->Release();
+ // Create the System Device Enumerator.
+ HRESULT hr;
+ ICreateDevEnum *pSysDevEnum = NULL;
+ hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum);
+ if (FAILED(hr))
+ {
+ return ret;
+ }
+ // Obtain a class enumerator for the video compressor category.
+ IEnumMoniker *pEnumCat = NULL;
+ hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);
+
+ if (hr == S_OK) {
+ // Enumerate the monikers.
+ IMoniker *pMoniker = NULL;
+ ULONG cFetched;
+ while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) {
+ IPropertyBag *pPropBag;
+ hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
+ if (SUCCEEDED(hr)) {
+ // To retrieve the filter's friendly name, do the following:
+ VARIANT varName;
+ VariantInit(&varName);
+ hr = pPropBag->Read(L"FriendlyName", &varName, 0);
+ if (SUCCEEDED(hr))
+ {
+ // Display the name in your UI somehow.
+ QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal));
+ ret.append(str);
+ }
+ VariantClear(&varName);
+
+ ////// To create an instance of the filter, do the following:
+ ////IBaseFilter *pFilter;
+ ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter,
+ //// (void**)&pFilter);
+ // Now add the filter to the graph.
+ //Remember to release pFilter later.
+ pPropBag->Release();
+ }
+ pMoniker->Release();
+ }
+ pEnumCat->Release();
+ }
+ pSysDevEnum->Release();
#else
for (int i = 0; i < 16; i++) {
char buf[128];
@@ -89,15 +89,15 @@ static QList<QString> get_camera_names(void) {
}
typedef struct {
- int width;
- int height;
+ int width;
+ int height;
} resolution_tuple;
static resolution_tuple resolution_choices[] = {
- { 640, 480 },
- { 320, 240 },
- { 320, 200 },
- { 0, 0 }
+ { 640, 480 },
+ { 320, 240 },
+ { 320, 200 },
+ { 0, 0 }
};
Tracker::Tracker() : stop(false), layout(nullptr), videoWidget(nullptr)
@@ -108,8 +108,8 @@ Tracker::~Tracker()
{
stop = true;
wait();
- if (videoWidget)
- delete videoWidget;
+ if (videoWidget)
+ delete videoWidget;
if(layout)
delete layout;
qDebug() << "releasing camera, brace for impact";
@@ -178,7 +178,7 @@ void Tracker::run()
}
if (fps)
camera.set(CV_CAP_PROP_FPS, fps);
-
+
aruco::MarkerDetector detector;
detector.setDesiredSpeed(3);
@@ -187,7 +187,7 @@ void Tracker::run()
cv::Mat color, color_, grayscale, rvec, tvec;
const double stateful_coeff = 0.88;
-
+
if (!camera.isOpened())
{
fprintf(stderr, "aruco tracker: can't open camera\n");
@@ -214,7 +214,7 @@ void Tracker::run()
grayscale = channel[2];
} else
cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY);
-
+
gain.tick(camera, grayscale);
const int scale = frame.cols > 480 ? 2 : 1;
@@ -280,11 +280,11 @@ void Tracker::run()
cv::putText(frame, buf, cv::Point(10, 32), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(0, 255, 0), scale);
::sprintf(buf, "Jiffies: %ld", (long) (10000 * (time - tm) / freq));
cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale);
-
+
if (markers.size() == 1 && markers[0].size() == 4) {
const auto& m = markers.at(0);
const float size = 40;
-
+
const double p = s.marker_pitch;
const double sq = sin(p * HT_PI / 180);
const double cq = cos(p * HT_PI / 180);
@@ -380,7 +380,7 @@ void Tracker::run()
void Tracker::GetHeadPoseData(double *data)
{
QMutexLocker lck(&mtx);
-
+
data[Yaw] = pose[Yaw];
data[Pitch] = pose[Pitch];
data[Roll] = pose[Roll];
@@ -391,11 +391,11 @@ void Tracker::GetHeadPoseData(double *data)
class TrackerDll : public Metadata
{
- // ITrackerDll interface
- void getFullName(QString *strToBeFilled);
- void getShortName(QString *strToBeFilled);
- void getDescription(QString *strToBeFilled);
- void getIcon(QIcon *icon);
+ // ITrackerDll interface
+ void getFullName(QString *strToBeFilled);
+ void getShortName(QString *strToBeFilled);
+ void getDescription(QString *strToBeFilled);
+ void getIcon(QIcon *icon);
};
//-----------------------------------------------------------------------------
@@ -406,12 +406,12 @@ void TrackerDll::getFullName(QString *strToBeFilled)
void TrackerDll::getShortName(QString *strToBeFilled)
{
- *strToBeFilled = "aruco";
+ *strToBeFilled = "aruco";
}
void TrackerDll::getDescription(QString *strToBeFilled)
{
- *strToBeFilled = "";
+ *strToBeFilled = "";
}
void TrackerDll::getIcon(QIcon *icon)
@@ -425,7 +425,7 @@ void TrackerDll::getIcon(QIcon *icon)
extern "C" OPENTRACK_EXPORT Metadata* GetMetadata()
{
- return new TrackerDll;
+ return new TrackerDll;
}
//#pragma comment(linker, "/export:GetTracker=_GetTracker@0")
@@ -444,11 +444,11 @@ TrackerControls::TrackerControls()
{
tracker = nullptr;
calib_timer.setInterval(200);
- ui.setupUi(this);
+ ui.setupUi(this);
setAttribute(Qt::WA_NativeWindow, true);
ui.cameraName->addItems(get_camera_names());
tie_setting(s.camera_index, ui.cameraName);
- tie_setting(s.resolution, ui.resolution);
+ tie_setting(s.resolution, ui.resolution);
tie_setting(s.force_fps, ui.cameraFPS);
tie_setting(s.fov, ui.cameraFOV);
tie_setting(s.headpos_x, ui.cx);
@@ -500,7 +500,7 @@ void TrackerControls::doOK()
s.b->save();
if (tracker)
tracker->reload();
- this->close();
+ this->close();
}
void TrackerControls::doCancel()
diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h
index 5416bb52..9ac57417 100644
--- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h
+++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h
@@ -16,12 +16,9 @@
#include <QHBoxLayout>
#include <QDialog>
#include <QTimer>
-#include <opencv2/opencv.hpp>
-#include <opencv/highgui.h>
#include "facetracknoir/options.h"
#include "ftnoir_tracker_aruco/trans_calib.h"
#include "facetracknoir/plugin-api.hpp"
-
#include "facetracknoir/gain-control.hpp"
using namespace options;
@@ -50,7 +47,7 @@ class Tracker : protected QThread, public ITracker
{
Q_OBJECT
public:
- Tracker();
+ Tracker();
~Tracker() override;
void StartTracker(QFrame* frame);
void GetHeadPoseData(double *data);
@@ -61,7 +58,7 @@ private:
QMutex mtx;
volatile bool stop;
QHBoxLayout* layout;
- ArucoVideoWidget* videoWidget;
+ ArucoVideoWidget* videoWidget;
settings s;
double pose[6];
cv::Mat frame;
@@ -83,14 +80,14 @@ public:
tracker = nullptr;
}
private:
- Ui::Form ui;
+ Ui::Form ui;
Tracker* tracker;
settings s;
TranslationCalibrator calibrator;
QTimer calib_timer;
private slots:
- void doOK();
- void doCancel();
+ void doOK();
+ void doCancel();
void toggleCalibrate();
void cleanupCalib();
void update_tracker_calibration();
diff --git a/ftnoir_tracker_aruco/include/aruco.h b/ftnoir_tracker_aruco/include/aruco.h
index 569b95fb..8ea583a8 100644
--- a/ftnoir_tracker_aruco/include/aruco.h
+++ b/ftnoir_tracker_aruco/include/aruco.h
@@ -26,12 +26,12 @@ The views and conclusions contained in the software and documentation are those
authors and should not be interpreted as representing official policies, either expressed
or implied, of Rafael Muñoz Salinas.
-
-
+
+
\mainpage ArUco: Augmented Reality library from the University of Cordoba
-ArUco is a minimal C++ library for detection of Augmented Reality markers based on OpenCv exclusively.
+ArUco is a minimal C++ library for detection of Augmented Reality markers based on OpenCv exclusively.
It is an educational project to show student how to detect augmented reality markers and it is provided under BSD license.
@@ -54,11 +54,11 @@ Aruco allows the possibility to employ board. Boards are markers composed by an
The library comes with five applications that will help you to learn how to use the library:
- aruco_create_marker: which creates marker and saves it in a jpg file you can print.
- - aruco_simple : simple test aplication that detects the markers in a image
+ - aruco_simple : simple test aplication that detects the markers in a image
- aruco_test: this is the main application for detection. It reads images either from the camera of from a video and detect markers. Additionally, if you provide the intrinsics of the camera(obtained by OpenCv calibration) and the size of the marker in meters, the library calculates the marker intrinsics so that you can easily create your AR applications.
- aruco_test_gl: shows how to use the library AR applications using OpenGL for rendering
- aruco_create_board: application that helps you to create a board
- - aruco_simple_board: simple test aplication that detects a board of markers in a image
+ - aruco_simple_board: simple test aplication that detects a board of markers in a image
- aruco_test_board: application that detects boards
- aruco_test_board_gl: application that detects boards and uses OpenGL to draw
@@ -66,7 +66,7 @@ The library comes with five applications that will help you to learn how to use
The ArUco library contents are divided in two main directories. The src directory, which contains the library itself. And the utils directory which contains the applications.
-The library main classes are:
+The library main classes are:
- aruco::CameraParameters: represent the information of the camera that captures the images. Here you must set the calibration info.
- aruco::Marker: which represent a marker detected in the image
- aruco::MarkerDetector: that is in charge of deteting the markers in a image Detection is done by simple calling the member funcion ArMarkerDetector::detect(). Additionally, the classes contain members to create the required matrices for rendering using OpenGL. See aruco_test_gl for details
@@ -101,34 +101,33 @@ The library has been compiled using MinGW and codeblocks. Below I describe the b
-# Download the source code and compile it using cmake and codeblocks. Note: install the library in C:\ if you want it to be easily detected by cmake afterwards
- step 4) aruco
-# Download and decompress.
- -# Open cmake gui application and set the path to the main library directory and also set a path where the project is going to be built.
+ -# Open cmake gui application and set the path to the main library directory and also set a path where the project is going to be built.
-# Generate the codeblock project.
-# Open the project with codeblock and compile then, install. The programs will be probably generated into the bin directory
OpenGL: by default, the mingw version installed has not the glut library. So, the opengl programs are not compiled. If you want to compile with OpenGL support, you must install glut, or prefereably freeglut.
-Thus,
- - Download the library (http://www.martinpayne.me.uk/software/development/GLUT/freeglut-MinGW.zip) for mingw.
- - Decompress in a directory X.
+Thus,
+ - Download the library (http://www.martinpayne.me.uk/software/development/GLUT/freeglut-MinGW.zip) for mingw.
+ - Decompress in a directory X.
- Then, rerun cmake setting the variable GLU_PATH to that directory (>cmake .. -DGLUT_PATH="C:\X")
- Finally, recompile and test. Indeed, you should move the freeglut.dll to the directory with the binaries or to any other place in the PATH.
CONCLUSION: Move to Linux, things are simpler :P
-
-\section Testing
+
+\section Testing
For testing the applications, the library provides videos and the corresponding camera parameters of these videos. Into the directories you will find information on how to run the examples.
-
+
\section Final Notes
- REQUIREMENTS: OpenCv >= 2.1.0. and OpenGL for (aruco_test_gl and aruco_test_board_gl)
- CONTACT: Rafael Munoz-Salinas: rmsalinas@uco.es
- This libary is free software and come with no guaratee!
-
+
*/
#include "markerdetector.h"
-#include "boarddetector.h"
#include "cvdrawingutils.h"
diff --git a/ftnoir_tracker_aruco/include/arucofidmarkers.h b/ftnoir_tracker_aruco/include/arucofidmarkers.h
index 7dad4672..15eb8e4c 100644
--- a/ftnoir_tracker_aruco/include/arucofidmarkers.h
+++ b/ftnoir_tracker_aruco/include/arucofidmarkers.h
@@ -31,7 +31,6 @@ or implied, of Rafael Muñoz Salinas.
#include <opencv2/core/core.hpp>
#include "exports.h"
#include "marker.h"
-#include "board.h"
namespace aruco {
class ARUCO_EXPORTS FiducidalMarkers {
@@ -80,7 +79,7 @@ public:
* @param gridSize grid layout (numer of sqaures in x and Y)
* @param MarkerSize size of markers sides in pixels
* @param MarkerDistance distance between the markers
- * @param TInfo output
+ * @param TInfo output
* @param excludedIds set of ids excluded from the board
*/
static cv::Mat createBoardImage( cv::Size gridSize,int MarkerSize,int MarkerDistance, BoardConfiguration& TInfo ,vector<int> *excludedIds=NULL ) throw (cv::Exception);
@@ -89,24 +88,24 @@ public:
/**Creates a printable image of a board in chessboard_like manner
* @param gridSize grid layout (numer of sqaures in x and Y)
* @param MarkerSize size of markers sides in pixels
- * @param TInfo output
+ * @param TInfo output
* @param setDataCentered indicates if the center is set at the center of the board. Otherwise it is the left-upper corner
- *
+ *
*/
static cv::Mat createBoardImage_ChessBoard( cv::Size gridSize,int MarkerSize, BoardConfiguration& TInfo ,bool setDataCentered=true ,vector<int> *excludedIds=NULL) throw (cv::Exception);
- /**Creates a printable image of a board in a frame fashion
+ /**Creates a printable image of a board in a frame fashion
* @param gridSize grid layout (numer of sqaures in x and Y)
* @param MarkerSize size of markers sides in pixels
* @param MarkerDistance distance between the markers
- * @param TInfo output
+ * @param TInfo output
* @param setDataCentered indicates if the center is set at the center of the board. Otherwise it is the left-upper corner
- *
+ *
*/
static cv::Mat createBoardImage_Frame( cv::Size gridSize,int MarkerSize,int MarkerDistance, BoardConfiguration& TInfo ,bool setDataCentered=true,vector<int> *excludedIds=NULL ) throw (cv::Exception);
private:
-
+
static vector<int> getListOfValidMarkersIds_random(int nMarkers,vector<int> *excluded) throw (cv::Exception);
static cv::Mat rotate(const cv::Mat & in);
static int hammDistMarker(cv::Mat bits);
diff --git a/ftnoir_tracker_aruco/include/board.h b/ftnoir_tracker_aruco/include/board.h
deleted file mode 100644
index c1d79292..00000000
--- a/ftnoir_tracker_aruco/include/board.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*****************************
-Copyright 2011 Rafael Muñoz Salinas. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are
-permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice, this list of
- conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice, this list
- of conditions and the following disclaimer in the documentation and/or other materials
- provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY Rafael Muñoz Salinas ''AS IS'' AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Rafael Muñoz Salinas OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-The views and conclusions contained in the software and documentation are those of the
-authors and should not be interpreted as representing official policies, either expressed
-or implied, of Rafael Muñoz Salinas.
-********************************/
-#ifndef _Aruco_board_h
-#define _Aruco_board_h
-#include <opencv2/opencv.hpp>
-#include <string>
-#include <vector>
-#include "exports.h"
-#include "marker.h"
-using namespace std;
-namespace aruco {
-/**
- * 3d representation of a marker
- */
-struct ARUCO_EXPORTS MarkerInfo:public vector<cv::Point3f> {
- MarkerInfo() {}
- MarkerInfo(int _id) {id=_id; }
- MarkerInfo(const MarkerInfo&MI): vector<cv::Point3f>(MI){id=MI.id; }
- MarkerInfo & operator=(const MarkerInfo&MI){
- vector<cv::Point3f> ::operator=(MI);
- id=MI.id;
- return *this;
- }
- int id;//maker id
-};
-
-/**\brief This class defines a board with several markers.
- * A Board contains several markers so that they are more robustly detected.
- *
- * In general, a board is a set of markers. So BoardConfiguration is only a list
- * of the id of the markers along with the position of their corners.
- *
- * The position of the corners can be specified either in pixels (in a non-specific size) or in meters.
- * The first is the typical case in which you generate the image of board and the print it. Since you do not know in advance the real
- * size of the markers, their corners are specified in pixels, and then, the translation to meters can be made once you know the real size.
- *
- * On the other hand, you may want to have the information of your boards in meters. The BoardConfiguration allows you to do so.
- *
- * The point is in the mInfoType variable. It can be either PIX or METERS according to your needs.
- *
-*/
-
-
-class ARUCO_EXPORTS BoardConfiguration: public vector<MarkerInfo>
-{
- friend class Board;
-public:
- enum MarkerInfoType {NONE=-1,PIX=0,METERS=1};//indicates if the data in MakersInfo is expressed in meters or in pixels so as to do conversion internally
- //variable indicates if the data in MakersInfo is expressed in meters or in pixels so as to do conversion internally
- int mInfoType;
- /**
- */
- BoardConfiguration();
-
- /**
- */
- BoardConfiguration(const BoardConfiguration &T);
-
- /**
- */
- BoardConfiguration & operator=(const BoardConfiguration &T);
- /**Saves the board info to a file
- */
- void saveToFile(string sfile)throw (cv::Exception);
- /**Reads board info from a file
- */
- void readFromFile(string sfile)throw (cv::Exception);
- /**Indicates if the corners are expressed in meters
- */
- bool isExpressedInMeters()const {
- return mInfoType==METERS;
- }
- /**Indicates if the corners are expressed in meters
- */
- bool isExpressedInPixels()const {
- return mInfoType==PIX;
- }
- /**Returns the index of the marker with id indicated, if is in the list
- */
- int getIndexOfMarkerId(int id)const;
- /**Returns the Info of the marker with id specified. If not in the set, throws exception
- */
- const MarkerInfo& getMarkerInfo(int id)const throw (cv::Exception);
- /**Set in the list passed the set of the ids
- */
- void getIdList(vector<int> &ids,bool append=true)const;
-private:
- /**Saves the board info to a file
- */
- void saveToFile(cv::FileStorage &fs)throw (cv::Exception);
- /**Reads board info from a file
- */
- void readFromFile(cv::FileStorage &fs)throw (cv::Exception);
-};
-
-/**
-*/
-class ARUCO_EXPORTS Board:public vector<Marker>
-{
-
-public:
- BoardConfiguration conf;
- //matrices of rotation and translation respect to the camera
- cv::Mat Rvec,Tvec;
- /**
- */
- Board()
- {
- Rvec.create(3,1,CV_32FC1);
- Tvec.create(3,1,CV_32FC1);
- for (int i=0;i<3;i++)
- Tvec.at<float>(i,0)=Rvec.at<float>(i,0)=-999999;
- }
-
- /**Given the extrinsic camera parameters returns the GL_MODELVIEW matrix for opengl.
- * Setting this matrix, the reference corrdinate system will be set in this board
- */
- void glGetModelViewMatrix(double modelview_matrix[16])throw(cv::Exception);
-
- /**
- * Returns position vector and orientation quaternion for an Ogre scene node or entity.
- * Use:
- * ...
- * Ogre::Vector3 ogrePos (position[0], position[1], position[2]);
- * Ogre::Quaternion ogreOrient (orientation[0], orientation[1], orientation[2], orientation[3]);
- * mySceneNode->setPosition( ogrePos );
- * mySceneNode->setOrientation( ogreOrient );
- * ...
- */
- void OgreGetPoseParameters( double position[3], double orientation[4] )throw(cv::Exception);
-
-
- /**Save this from a file
- */
- void saveToFile(string filePath)throw(cv::Exception);
- /**Read this from a file
- */
- void readFromFile(string filePath)throw(cv::Exception);
-
-};
-}
-
-#endif
diff --git a/ftnoir_tracker_aruco/include/boarddetector.h b/ftnoir_tracker_aruco/include/boarddetector.h
deleted file mode 100644
index 4770b5c9..00000000
--- a/ftnoir_tracker_aruco/include/boarddetector.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/*****************************
-Copyright 2011 Rafael Muñoz Salinas. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are
-permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice, this list of
- conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice, this list
- of conditions and the following disclaimer in the documentation and/or other materials
- provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY Rafael Muñoz Salinas ''AS IS'' AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Rafael Muñoz Salinas OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-The views and conclusions contained in the software and documentation are those of the
-authors and should not be interpreted as representing official policies, either expressed
-or implied, of Rafael Muñoz Salinas.
-********************************/
-#ifndef _Aruco_BoardDetector_H
-#define _Aruco_BoardDetector_H
-#include <opencv2/opencv.hpp>
-#include "exports.h"
-#include "board.h"
-#include "cameraparameters.h"
-#include "markerdetector.h"
-using namespace std;
-
-namespace aruco
-{
-
-/**\brief This class detects AR boards
- * Version 1.2
- * There are two modes for board detection.
- * First, the old way. (You first detect markers with MarkerDetector and then call to detect in this class.
- *
- * Second: New mode, marker detection is included in the class
- * \code
-
- CameraParameters CP;
- CP.readFromFile(path_cp)
- BoardConfiguration BC;
- BC.readFromFile(path_bc);
- BoardDetector BD;
- BD.setParams(BC,CP); //or only BD.setParams(BC)
- //capture image
- cv::Mat im;
- capture_image(im);
-
- float prob=BD.detect(im);
- if (prob>0.3)
- CvDrawingUtils::draw3DAxis(im,BD.getDetectedBoard(),CP);
-
- \endcode
- *
-*/
-class ARUCO_EXPORTS BoardDetector
-{
-public:
- /** See discussion in @see enableRotateXAxis.
- * Do not change unless you know what you are doing
- */
- BoardDetector(bool setYPerperdicular=true);
-
-
- /**
- * Use if you plan to let this class to perform marker detection too
- */
- void setParams(const BoardConfiguration &bc,const CameraParameters &cp, float markerSizeMeters=-1);
- void setParams(const BoardConfiguration &bc);
- /**
- * Detect markers, and then, look for the board indicated in setParams()
- * @return value indicating the likelihood of having found the marker
- */
- float detect(const cv::Mat &im)throw (cv::Exception);
- /**Returns a reference to the board detected
- */
- Board & getDetectedBoard(){return _boardDetected;}
- /**Returns a reference to the internal marker detector
- */
- MarkerDetector &getMarkerDetector(){return _mdetector;}
- /**Returns the vector of markers detected
- */
- vector<Marker> &getDetectedMarkers(){return _vmarkers;}
-
-
- //ALTERNATIVE DETECTION METHOD, BASED ON MARKERS PREVIOUSLY DETECTED
-
- /** Given the markers detected, determines if there is the board passed
- * @param detectedMarkers result provided by aruco::ArMarkerDetector
- * @param BConf the board you want to see if is present
- * @param Bdetected output information of the detected board
- * @param camMatrix camera matrix with intrinsics
- * @param distCoeff camera distorsion coeff
- * @param camMatrix intrinsic camera information.
- * @param distCoeff camera distorsion coefficient. If set Mat() if is assumed no camera distorion
- * @param markerSizeMeters size of the marker sides expressed in meters
- * @return value indicating the likelihood of having found the marker
- */
- float detect(const vector<Marker> &detectedMarkers,const BoardConfiguration &BConf, Board &Bdetected, cv::Mat camMatrix=cv::Mat(),cv::Mat distCoeff=cv::Mat(), float markerSizeMeters=-1 )throw (cv::Exception);
- float detect(const vector<Marker> &detectedMarkers,const BoardConfiguration &BConf, Board &Bdetected,const CameraParameters &cp, float markerSizeMeters=-1 )throw (cv::Exception);
-
-
- /**
- * By default, the Y axis is set to point up. However this is not the default
- * operation mode of opencv, which produces the Z axis pointing up instead.
- * So, to achieve this change, we have to rotate the X axis.
- */
- void setYPerperdicular(bool enable){_setYPerperdicular=enable;}
-
-
-
-
-private:
- void rotateXAxis(cv::Mat &rotation);
- bool _setYPerperdicular;
-
- //-- Functionality to detect markers inside
- bool _areParamsSet;
- BoardConfiguration _bconf;
- Board _boardDetected;
- float _markerSize;
- CameraParameters _camParams;
- MarkerDetector _mdetector;//internal markerdetector
- vector<Marker> _vmarkers;//markers detected in the call to : float detect(const cv::Mat &im);
-
-};
-
-}
-#endif
-
diff --git a/ftnoir_tracker_aruco/include/cameraparameters.h b/ftnoir_tracker_aruco/include/cameraparameters.h
index c3381a74..a419afbe 100644
--- a/ftnoir_tracker_aruco/include/cameraparameters.h
+++ b/ftnoir_tracker_aruco/include/cameraparameters.h
@@ -28,7 +28,7 @@ or implied, of Rafael Muñoz Salinas.
#ifndef _Aruco_CameraParameters_H
#define _Aruco_CameraParameters_H
#include "exports.h"
-#include <opencv2/opencv.hpp>
+#include <opencv2/core/core.hpp>
#include <string>
using namespace std;
namespace aruco
@@ -105,7 +105,7 @@ public:
* @param invert: indicates if the output projection matrix has to yield a horizontally inverted image because image data has not been stored in the order of glDrawPixels: bottom-to-top.
*/
void glGetProjectionMatrix( cv::Size orgImgSize, cv::Size size,double proj_matrix[16],double gnear,double gfar,bool invert=false )throw(cv::Exception);
-
+
/**
* setup camera for an Ogre project.
* Use:
@@ -117,7 +117,7 @@ public:
* As in OpenGL, it assumes no camera distorsion
*/
void OgreGetProjectionMatrix( cv::Size orgImgSize, cv::Size size,double proj_matrix[16],double gnear,double gfar,bool invert=false )throw(cv::Exception);
-
+
private:
//GL routines
diff --git a/ftnoir_tracker_aruco/include/cvdrawingutils.h b/ftnoir_tracker_aruco/include/cvdrawingutils.h
index 38e9986e..24bfe630 100644
--- a/ftnoir_tracker_aruco/include/cvdrawingutils.h
+++ b/ftnoir_tracker_aruco/include/cvdrawingutils.h
@@ -33,19 +33,12 @@ namespace aruco
{
/**\brief A set of functions to draw in opencv images
*/
- class ARUCO_EXPORTS CvDrawingUtils
- {
- public:
-
- static void draw3dAxis(cv::Mat &Image,Marker &m,const CameraParameters &CP);
-
- static void draw3dCube(cv::Mat &Image,Marker &m,const CameraParameters &CP);
-
- static void draw3dAxis(cv::Mat &Image,Board &m,const CameraParameters &CP);
-
- static void draw3dCube(cv::Mat &Image,Board &m,const CameraParameters &CP);
-
- };
+ class ARUCO_EXPORTS CvDrawingUtils
+ {
+ public:
+ static void draw3dAxis(cv::Mat &Image,Marker &m,const CameraParameters &CP);
+ static void draw3dCube(cv::Mat &Image,Marker &m,const CameraParameters &CP);
+ };
}
#endif
diff --git a/ftnoir_tracker_aruco/include/exports.h b/ftnoir_tracker_aruco/include/exports.h
index 154605ec..044a1367 100644
--- a/ftnoir_tracker_aruco/include/exports.h
+++ b/ftnoir_tracker_aruco/include/exports.h
@@ -25,7 +25,7 @@ The views and conclusions contained in the software and documentation are those
authors and should not be interpreted as representing official policies, either expressed
or implied, of Rafael Muñoz Salinas.
********************************/
-
+
#ifndef __OPENARUCO_CORE_TYPES_H__
@@ -37,9 +37,9 @@ or implied, of Rafael Muñoz Salinas.
#if (defined WIN32 || defined _WIN32 || defined WINCE) && defined DSO_EXPORTS
- #define ARUCO_EXPORTS __declspec(dllexport)
+ #define ARUCO_EXPORTS __declspec(dllexport) __attribute__((visibility ("default")))
#else
- #define ARUCO_EXPORTS
+ #define ARUCO_EXPORTS __attribute__((visibility ("default")))
#endif
diff --git a/ftnoir_tracker_aruco/include/marker.h b/ftnoir_tracker_aruco/include/marker.h
index dc6bb28c..89961002 100644
--- a/ftnoir_tracker_aruco/include/marker.h
+++ b/ftnoir_tracker_aruco/include/marker.h
@@ -29,7 +29,7 @@ or implied, of Rafael Muñoz Salinas.
#define _Aruco_Marker_H
#include <vector>
#include <iostream>
-#include <opencv2/opencv.hpp>
+#include <opencv2/core/core.hpp>
#include "exports.h"
#include "cameraparameters.h"
using namespace std;
@@ -81,12 +81,12 @@ public:
* @param setYPerperdicular If set the Y axis will be perpendicular to the surface. Otherwise, it will be the Z axis
*/
void calculateExtrinsics(float markerSize,cv::Mat CameraMatrix,cv::Mat Distorsion=cv::Mat(),bool setYPerperdicular=true)throw(cv::Exception);
-
+
/**Given the extrinsic camera parameters returns the GL_MODELVIEW matrix for opengl.
* Setting this matrix, the reference coordinate system will be set in this marker
*/
void glGetModelViewMatrix( double modelview_matrix[16])throw(cv::Exception);
-
+
/**
* Returns position vector and orientation quaternion for an Ogre scene node or entity.
* Use:
@@ -97,8 +97,8 @@ public:
* mySceneNode->setOrientation( ogreOrient );
* ...
*/
- void OgreGetPoseParameters( double position[3], double orientation[4] )throw(cv::Exception);
-
+ void OgreGetPoseParameters( double position[3], double orientation[4] )throw(cv::Exception);
+
/**Returns the centroid of the marker
*/
cv::Point2f getCenter()const;
@@ -132,11 +132,11 @@ public:
return str;
}
-
-
+
+
private:
void rotateXAxis(cv::Mat &rotation);
-
+
};
}
diff --git a/ftnoir_tracker_aruco/include/markerdetector.h b/ftnoir_tracker_aruco/include/markerdetector.h
index 4d6e7b90..a4656527 100644
--- a/ftnoir_tracker_aruco/include/markerdetector.h
+++ b/ftnoir_tracker_aruco/include/markerdetector.h
@@ -27,7 +27,7 @@ or implied, of Rafael Muñoz Salinas.
********************************/
#ifndef _ARUCO_MarkerDetector_H
#define _ARUCO_MarkerDetector_H
-#include <opencv2/opencv.hpp>
+#include <opencv2/core/core.hpp>
#include <cstdio>
#include <iostream>
#include "cameraparameters.h"
@@ -47,7 +47,7 @@ class ARUCO_EXPORTS MarkerDetector
class MarkerCandidate: public Marker{
public:
MarkerCandidate(){}
- MarkerCandidate(const Marker &M): Marker(M){}
+ MarkerCandidate(const Marker &M): Marker(M){}
MarkerCandidate(const MarkerCandidate &M): Marker(M){
contour=M.contour;
idx=M.idx;
@@ -60,20 +60,20 @@ class ARUCO_EXPORTS MarkerDetector
idx=M.idx;
return M;
}
-
+
vector<cv::Point> contour;//all the points of its contour
int idx;//index position in the global contour list
};
public:
/**
- * See
+ * See
*/
- MarkerDetector();
+ MarkerDetector() {}
/**
*/
- ~MarkerDetector();
+ ~MarkerDetector() {}
/**Detects the markers in the image passed
*
@@ -161,17 +161,17 @@ public:
* of cols and rows.
* @param min size of the contour to consider a possible marker as valid (0,1]
* @param max size of the contour to consider a possible marker as valid [0,1)
- *
+ *
*/
void setMinMaxSize(float min=0.03,float max=0.5)throw(cv::Exception);
-
+
/**reads the min and max sizes employed
* @param min output size of the contour to consider a possible marker as valid (0,1]
* @param max output size of the contour to consider a possible marker as valid [0,1)
- *
+ *
*/
void getMinMaxSize(float &min,float &max){min=_minSize;max=_maxSize;}
-
+
/**Enables/Disables erosion process that is REQUIRED for chessboard like boards.
* By default, this property is enabled
*/
@@ -210,10 +210,10 @@ public:
markerIdDetector_ptrfunc=markerdetector_func;
}
- /** Use an smaller version of the input image for marker detection.
+ /** Use an smaller version of the input image for marker detection.
* If your marker is small enough, you can employ an smaller image to perform the detection without noticeable reduction in the precision.
* Internally, we are performing a pyrdown operation
- *
+ *
* @param level number of times the image size is divided by 2. Internally, we are performing a pyrdown.
*/
void pyrDown(unsigned int level){pyrdown_level=level;}
@@ -247,17 +247,17 @@ public:
* @return true if the operation succeed
*/
bool warp(cv::Mat &in,cv::Mat &out,cv::Size size, std::vector<cv::Point2f> points)throw (cv::Exception);
-
-
-
+
+
+
/** Refine MarkerCandidate Corner using LINES method
* @param candidate candidate to refine corners
*/
- void refineCandidateLines(MarkerCandidate &candidate);
-
-
+ void refineCandidateLines(MarkerCandidate &candidate);
+
+
/**DEPRECATED!!! Use the member function in CameraParameters
- *
+ *
* Given the intrinsic camera parameters returns the GL_PROJECTION matrix for opengl.
* PLease NOTE that when using OpenGL, it is assumed no camera distorsion! So, if it is not true, you should have
* undistor image
@@ -308,26 +308,26 @@ private:
*/
int perimeter(std::vector<cv::Point2f> &a);
-
+
// //GL routines
-//
+//
// static void argConvGLcpara2( double cparam[3][4], int width, int height, double gnear, double gfar, double m[16], bool invert )throw(cv::Exception);
// static int arParamDecompMat( double source[3][4], double cpara[3][4], double trans[3][4] )throw(cv::Exception);
// static double norm( double a, double b, double c );
// static double dot( double a1, double a2, double a3,
// double b1, double b2, double b3 );
-//
+//
//detection of the
void findBestCornerInRegion_harris(const cv::Mat & grey,vector<cv::Point2f> & Corners,int blockSize);
-
-
+
+
// auxiliar functions to perform LINES refinement
void interpolate2Dline( const vector< cv::Point > &inPoints, cv::Point3f &outLine);
- cv::Point2f getCrossPoint(const cv::Point3f& line1, const cv::Point3f& line2);
-
-
- /**Given a vector vinout with elements and a boolean vector indicating the lements from it to remove,
+ cv::Point2f getCrossPoint(const cv::Point3f& line1, const cv::Point3f& line2);
+
+
+ /**Given a vector vinout with elements and a boolean vector indicating the lements from it to remove,
* this function remove the elements
* @param vinout
* @param toRemove
diff --git a/ftnoir_tracker_aruco/trans_calib.h b/ftnoir_tracker_aruco/trans_calib.h
index 5c321b2c..c2c02b38 100644
--- a/ftnoir_tracker_aruco/trans_calib.h
+++ b/ftnoir_tracker_aruco/trans_calib.h
@@ -8,7 +8,7 @@
#ifndef TRANSCALIB_H
#define TRANSCALIB_H
-#include <opencv2/opencv.hpp>
+#include <opencv2/core/core.hpp>
//-----------------------------------------------------------------------------
// Calibrates the translation from head to model = t_MH