-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9af7fb5
Showing
30 changed files
with
6,392 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# This file currently only serves to mark the location of a catkin workspace for tool integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
ArUco Catkin Package | ||
==================== | ||
|
||
The ArUco package is a minimal library for Augmented Reality applications based on OpenCV | ||
|
||
Build Library: | ||
------------- | ||
|
||
```bash | ||
git clone http://github.com/rosmod/lib-aruco | ||
cd lib-aruco | ||
catkin_make | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/opt/ros/indigo/share/catkin/cmake/toplevel.cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
project(aruco) | ||
|
||
## Start Global Marker | ||
|
||
## End Global Marker | ||
|
||
## Check C++11 / C++0x | ||
include(CheckCXXCompilerFlag) | ||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) | ||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) | ||
if(COMPILER_SUPPORTS_CXX11) | ||
set(CMAKE_CXX_FLAGS "-std=c++11") | ||
elseif(COMPILER_SUPPORTS_CXX0X) | ||
set(CMAKE_CXX_FLAGS "-std=c++0x") | ||
else() | ||
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") | ||
endif() | ||
|
||
include_directories( | ||
/usr/include/opencv2 | ||
${OpenCV_INCLUDE_DIRS} | ||
) | ||
|
||
include_directories(include) | ||
|
||
add_library(aruco | ||
src/aruco/ar_omp.cpp | ||
src/aruco/arucofidmarkers.cpp | ||
src/aruco/board.cpp | ||
src/aruco/boarddetector.cpp | ||
src/aruco/cameraparameters.cpp | ||
src/aruco/chromaticmask.cpp | ||
src/aruco/cvdrawingutils.cpp | ||
src/aruco/highlyreliablemarkers.cpp | ||
src/aruco/marker.cpp | ||
src/aruco/markerdetector.cpp | ||
src/aruco/subpixelcorner.cpp | ||
) | ||
target_link_libraries(aruco | ||
opencv_core | ||
opencv_imgproc | ||
opencv_highgui | ||
opencv_contrib | ||
opencv_legacy | ||
opencv_photo | ||
opencv_video | ||
opencv_videostab | ||
opencv_calib3d | ||
opencv_ml | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
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. | ||
*/ | ||
|
||
#ifdef USE_OMP | ||
#include <omp.h> | ||
#else | ||
int omp_get_max_threads(); | ||
int omp_get_thread_num(); | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/** | ||
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. | ||
\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. | ||
It is an educational project to show student how to detect augmented reality markers and it is provided under BSD license. | ||
\section INTRODUCTION INTRODUCTION | ||
The library relies on the use of coded markers. Each marker has an unique code indicated by the black and white colors in it. The libary detect borders, and analyzes into the rectangular regions which of them are likely to be markers. Then, a decoding is performed and if the code is valid, it is considered that the rectangle is a marker. | ||
The codification included into the marker is a slighly modified version of the Hamming Code. It has a total a 25 bits didived in 5 rows of 5 bits each. So, we have 5 words of 5 bits. Each word, contains only 2 bits of real information, the rest is for and error detection/correction (error correction is yet to be done). As a conclusion, a marker contains 10 bits of real information wich allows 1024 different markers. | ||
\section BOARDS BOARDS | ||
Aruco allows the possibility to employ board. Boards are markers composed by an array of markers arranged in a known order. The advantages of using boards instead of simple markers are: | ||
- More robusteness. The misdetection of several markers of the board is not a problem as long as a minimum set of them are detected. | ||
- More precision. Since there are a larger number of corners, camera pose estimation becomes more precise. | ||
\section APPLICATIONS APPLICATIONS | ||
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_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_test_board: application that detects boards | ||
- aruco_test_board_gl: application that detects boards and uses OpenGL to draw | ||
\section LIBRARY LIBRARY DESCRIPTION: | ||
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: | ||
- 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 | ||
- aruco::BoardConfiguration: A board is an array of markers in a known order. BoardConfiguracion is the class that defines a board by indicating the id of its markers. In addition, it has informacion about the distance between the markers so that extrinsica camera computations can be done. | ||
- aruco::Board: This class defines a board detected in a image. The board has the extrinsic camera parameters as public atributes. In addition, it has a method that allows obtain the matrix for getting its position in OpenGL (see aruco_test_board_gl for details). | ||
- aruco::BoardDetector : This is the class in charge of detecting a board in a image. You must pass to it the set of markers detected by ArMarkerDetector and the BoardConfiguracion of the board you want to detect. This class will do the rest for you, even calculating the camera extrinsics. | ||
\section COMPILING COMPILING THE LIBRARY: | ||
\subsection Linux | ||
Go to the aruco library and do | ||
\verbatim | ||
>mkdir build | ||
>cd build | ||
>cmake .. | ||
>make | ||
>make install (optional) | ||
\endverbatim | ||
NOTE ON OPENGL: The library supports eaily the integration with OpenGL. In order to compile with support for OpenGL, you just have installed in your system the develop packages for GL and glut (or freeglut). | ||
\subsection WINDOWS | ||
The library has been compiled using MinGW and codeblocks. Below I describe the best way to compile it that I know. If you know better, please let me know. | ||
- step 1) codeblocks | ||
-# Download codeblocks. I recommend to download the version 10.5 with mingw included (codeblocks-10.05mingw-setup.exe) | ||
-# Install and set the PATH variable so that the codeblock/mingw/bin directory is included. In my case c:/codeblocks/mingw/bin. This will allow cmake to find the compiler. | ||
-# The codeblock program will not find the mingw path by deafult. So, run codeblocks and go to setting->Compuiler debugger and set the correct path to the MinGW dir. | ||
- step 2) cmake | ||
-# Download and install the last version of cmake. | ||
- step 3) OpenCv | ||
-# 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. | ||
-# 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. | ||
- 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 | ||
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 "aruco/markerdetector.h" | ||
#include "aruco/boarddetector.h" | ||
#include "aruco/cvdrawingutils.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/***************************** | ||
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 ArucoFiducicalMarkerDetector_H | ||
#define ArucoFiducicalMarkerDetector_H | ||
#include <opencv2/core/core.hpp> | ||
#include "aruco/exports.h" | ||
#include "aruco/marker.h" | ||
#include "aruco/board.h" | ||
namespace aruco { | ||
|
||
class ARUCO_EXPORTS FiducidalMarkers { | ||
public: | ||
/** | ||
* \brief Creates an ar marker with the id specified using a modified version of the hamming code. | ||
* There are two type of markers: a) These of 10 bits b) these of 3 bits. The latter are employed for applications | ||
* that need few marker but they must be small. The two type of markers are distinguished by their ids. While the first type | ||
* of markers have ids in the interval [0-1023], the second type ids in the interval [2000-2006]. | ||
* | ||
* | ||
* 10 bits markers | ||
* ----------------------- | ||
* There are a total of 5 rows of 5 cols. Each row encodes a total of 2 bits, so there are 2^10 bits:(0-1023). | ||
* | ||
* The least significative bytes are first (from left-up to to right-bottom) | ||
* | ||
* Example: the id = 110 (decimal) is be represented in binary as : 00 01 10 11 10. | ||
* | ||
* Then, it will generate the following marker: | ||
* | ||
* -# 1st row encodes 00: 1 0 0 0 0 : hex 0x10 | ||
* -# 2nd row encodes 01: 1 0 1 1 1 : hex 0x17 | ||
* -# 3nd row encodes 10: 0 1 0 0 1 : hex 0x09 | ||
* -# 4th row encodes 11: 0 1 1 1 0 : hex 0x0e | ||
* -# 5th row encodes 10: 0 1 0 0 1 : hex 0x09 | ||
* | ||
* Note that : The first bit, is the inverse of the hamming parity. This avoids the 0 0 0 0 0 to be valid | ||
* These marker are detected by the function getFiduciadlMarker_Aruco_Type1 | ||
* @param writeIdWaterMark if true, writes a watermark with the marker id | ||
*/ | ||
static cv::Mat createMarkerImage(int id,int size,bool writeIdWaterMark=true) throw (cv::Exception); | ||
|
||
/** Detection of fiducidal aruco markers (10 bits) | ||
* @param in input image with the patch that contains the possible marker | ||
* @param nRotations number of 90deg rotations in clockwise direction needed to set the marker in correct position | ||
* @return -1 if the image passed is a not a valid marker, and its id in case it really is a marker | ||
*/ | ||
static int detect(const cv::Mat &in,int &nRotations); | ||
|
||
/**Similar to createMarkerImage. Instead of returning a visible image, returns a 8UC1 matrix of 0s and 1s with the marker info | ||
*/ | ||
static cv::Mat getMarkerMat(int id) throw (cv::Exception); | ||
|
||
|
||
/**Creates a printable image of a board | ||
* @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 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); | ||
|
||
|
||
/**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 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 | ||
* @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 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); | ||
static int analyzeMarkerImage(cv::Mat &grey,int &nRotations); | ||
static bool correctHammMarker(cv::Mat &bits); | ||
}; | ||
|
||
} | ||
|
||
#endif |
Oops, something went wrong.