Saturday, July 20, 2013

Installing ArUco (Augmented Reality library) on Ubuntu







What I need?

- Ubuntu
     + Tested: Ubuntu 12.04

- OpenCV
     + Tested: OpenCV 2.4.2, 2.4.3 and 2.4.5

- ArUco
     + Tested: ArUco 1.2.4





Introduction

 ArUco, such as said in the ArUco website, is a "minimal library for Augmented Reality applications based on OpenCV" (See ArUco website).

The main features of ArUco are:
  • Detect markers with a single line of C++ code
  • Detection of AR boards (markers composed by several markers)
  • Requires only OpenCv (>=2.1)
  • Up to to 1024 different markers
  • Trivial integration with OpenGL and OGRE
  • Fast, reliable and cross-platform because relies on OpenCv
  • Examples that will help you to get running your AR application in less than 5 minutes
  • BSD licence

In Youtube there are some videos where you can see ArUco in action.

Procedure

1. First, install OpenCV.

2. Open a terminal.

3. Next, we have to install some packages I have found necessary in a fresh Ubuntu 12.04 installation:
$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt-get libicu-dev freeglut3 freeglut3-dev libgstreamer0.10-dev 
libgstreamer-plugins-base0.10-dev libxine-dev
3. Download the ArUco library:
$ wget http://sourceforge.net/projects/aruco/files/1.2.4/aruco-1.2.4.tgz
4. Extract the package and create a new folder that will help us to compile and install:
$ tar zxvf aruco-1.2.4.tgz
$ cd aruco-1.2.4
$ mkdir build
$ cd build
5. Compile and install ArUco:
$ cmake ..
$ make
$ sudo make install
Finally, if you want to test ArUco do like follows:
$ cd aruco-1.2.4/
$ cd build/utils
$ ./aruco_create_board 5:2 board.png board.yml 
Next, if you have a USB camera (I tested with USB camera but you can use USB, Firewire, etc.) in /dev/video0 (you can use the command "ls /dev/video*") you can test the Augmented Reality. First, you will need to calibrate your camera with OpenCV. This process will generate a 'camera.yml' file in "OpenCV-directory/build/bin" that you have to copy and paste in "aruco-1.2.4/build/utils". Next, you have to print the board that is in "aruco-1.2.4/build/utils/board.png" and execute the following commands to detect a single marker:
$ cd aruco-1.2.4/
$ cd build/utils
$ ./aruco_test live camera.yml 0.025
Or these one to detect the complete board:
$ cd aruco-1.2.4/
$ cd build/utils
$ ./aruco_test_board live board.yml camera.yml 0.025

The following screen is the output of single marker:

And this one is for the complete board:

Sources:
http://www.uco.es/investiga/grupos/ava/node/26
http://miloq.blogspot.com.es/2012/12/install-aruco-ubuntu-linux.html

24 comments:

  1. Hello, thanks for the tutorial. For the last step, how do I make sure to use the USB camera instead of the integrated one on the laptop? There doesn't seem to be a parameter/argument for it. Thanks!

    ReplyDelete
  2. Hi Hui Hui,
    if you see the command there is a 'live' parameter:

    $ ./aruco_test live camera.yml 0.025

    Now, in the arUCO code, if you pass the live parameter means that images are obtained from the video first video device recognized. Then, I think if you have a integrated one you will obtain the images from this one, and not from a second USB camera.

    ReplyDelete
  3. Hello!

    I'm using the openCV 2.4.9 and I calibrated my camera using the code provided here: http://docs.opencv.org/doc/tutorials/calib3d/camera_calibration/camera_calibration.

    When I ran the "./aruco_test live camera.yml 0.025", I received the following message:

    "File :camera.yml does not contains valid camera matrix in function CameraParameters::readFromXML"

    Took a little time until I notice that the .xml/.yml generated as output of camera_calibration uses capital letter to define the image size and the calibrations coefficients. So, they use Image_Width, Image_Height, Distortion_Coefficients, Camera_Matrix. To fix it you need to access your xml/yml file and change each word to: image_width, image_height, distortion_coefficients, camera_matrix.

    After changes, it's just run again and it should be work.

    Regards.

    ReplyDelete
    Replies
    1. I modified the above 4 parameters mentioned by you (Image_Width, Image_Height, Distortion_Coefficients, Camera_Matrix.) but still getting the same error. Did you try something else too ??

      Delete
  4. Hello,

    Can you help me make the ARUco library using CMake on Windows. I am using Win 7 64 bit with VS 2010 express and OpenCV is already running on it. I have also downloaded and installed the CMake binary. However I have been unable to make the library so that I can use it as a VS project.

    Can you kindly guide me regarding how to use CMake in Windows to install ARUco? All help is appreciated.

    Regards.

    ReplyDelete
    Replies
    1. Hello Mr. Zaidi,
      I never worked with ARUco with Windows, so I think I can not be helpful in this time. However, you can look into the official website (http://www.uco.es/investiga/grupos/ava/node/26) where, I hope, you can receive more info and help that I can be useful for you.

      Delete
  5. Hi,

    Can you please make an updated tutorial this time for hrm-board and also showing the occlusion option...

    ReplyDelete
  6. I'm so sorry Mr. Shawwa, but I am not working with aruco anymore. However, you can look into the official website (http://www.uco.es/investiga/grupos/ava/node/26) where, I hope, you can receive more info and help by the professionals that built this tool.

    ReplyDelete
  7. Replies
    1. That is length of marker (per side) in meter (2.5cm)

      Delete
  8. Hello
    I get all last picture you gave and now I am looking where is saving my printed image position.WOuld you let me know.

    ReplyDelete
  9. Where my Id vales a re saving?Could anybody inform me.I got ID pose values but I can not save or see any new files in utils as xml oe txt.....



    Best
    Taher

    ReplyDelete
  10. I see an error while running "./aruco_test live camera.yml 0.025"

    "CameraParameters::glGetProjectionMatrix :: The camera has distortion coefficients /home/abhisek/AR/aruco-1.3.0/src/cameraparameters.cpp 239
    "
    Any idea, the reprojection error reported while calibrating the camera is 1.64605

    ReplyDelete
  11. I used OpenCV 3.1 and Aruco make fails because it's using deprecated methods from OpenCV 2.2. Could you please comment on this. I don't want to go back to OpenCV 2.2.

    ReplyDelete
  12. ¿Para cuando una instalación en windows?

    ReplyDelete
    Replies
    1. Descarga Aruco de https://sourceforge.net/projects/aruco/files/
      EN el archivo README en la sección COMPLILING te explican cómo instalarlo en Windows

      Delete
  13. Hello everyone...
    Could someone help me please?
    I am trying to detect the single market and the complete board like the tutorial but after writing:

    ~/catkin_ws/src/ArUco/aruco-1.2.4/build/utils$ ./aruco_test live camera.yml 0.025

    I always get : Could not open video

    Could someone help me please? I really don't have any idea!

    ReplyDelete
  14. Hi,

    What the max distance to detect the marker?

    For me it is about 0.5m, is it possible to detect in long distance?

    ReplyDelete
  15. that a really amazing explaination so easy and good . men thanks .
    العاب فلاش برق

    ReplyDelete
  16. Thank you so much guys for sharing such a great ideas about this topic for sure the idea you share is more useful for me.


    Virtual Reality Booth

    ReplyDelete
  17. Hi,

    Thanks for the tutorial. I had downloaded aruco-3.0.11 on Ubuntu 16.04. When I give the command "make" I get following error.

    error: invalid preprocessing directive #endifxx
    #endifxx
    ^
    In file included from /home/nitish/aruco-3.0.11/utils_calibration/aruco_calibration_fromimages.cpp:40:0:
    /home/nitish/aruco-3.0.11/utils_calibration/dirreader.h:1:0: error: unterminated #ifndef
    #ifndef _DIR_READER_H
    ^
    utils_calibration/CMakeFiles/aruco_calibration_fromimages.dir/build.make:62: recipe for target 'utils_calibration/CMakeFiles/aruco_calibration_fromimages.dir/aruco_calibration_fromimages.cpp.o' failed
    make[2]: *** [utils_calibration/CMakeFiles/aruco_calibration_fromimages.dir/aruco_calibration_fromimages.cpp.o] Error 1
    CMakeFiles/Makefile2:596: recipe for target 'utils_calibration/CMakeFiles/aruco_calibration_fromimages.dir/all' failed
    make[1]: *** [utils_calibration/CMakeFiles/aruco_calibration_fromimages.dir/all] Error 2
    Makefile:127: recipe for target 'all' failed
    make: *** [all] Error 2


    Kindly advice.



    ReplyDelete
  18. Hi,

    Thanks for the tutorial. I had downloaded aruco-3.0.11 on Ubuntu 16.04. When I give the command "make" I get following error.

    error: invalid preprocessing directive #endifxx
    #endifxx
    ^
    In file included from /home/nitish/aruco-3.0.11/utils_calibration/aruco_calibration_fromimages.cpp:40:0:
    /home/nitish/aruco-3.0.11/utils_calibration/dirreader.h:1:0: error: unterminated #ifndef
    #ifndef _DIR_READER_H
    ^
    utils_calibration/CMakeFiles/aruco_calibration_fromimages.dir/build.make:62: recipe for target 'utils_calibration/CMakeFiles/aruco_calibration_fromimages.dir/aruco_calibration_fromimages.cpp.o' failed
    make[2]: *** [utils_calibration/CMakeFiles/aruco_calibration_fromimages.dir/aruco_calibration_fromimages.cpp.o] Error 1
    CMakeFiles/Makefile2:596: recipe for target 'utils_calibration/CMakeFiles/aruco_calibration_fromimages.dir/all' failed
    make[1]: *** [utils_calibration/CMakeFiles/aruco_calibration_fromimages.dir/all] Error 2
    Makefile:127: recipe for target 'all' failed
    make: *** [all] Error 2


    Kindly advice.

    ReplyDelete
  19. Hi, I had to remove the xx on the end of endifxx to make it compile...

    ReplyDelete