Skip to content

Opencv aruco localisation

Devitt Dmitry edited this page Oct 17, 2018 · 44 revisions

1. Install dependencies

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install python2.7-dev python3.5-dev
sudo apt-get install ros-${ROS_DISTRO}-usb-cam
sudo apt-get install ros-${ROS_DISTRO}-vision-opencv

2. Install Opencv

  1. Downloan the last version Opencv from here (normal work is 3.4.1 ver.)

  2. Unpack opencv*.zip (* means version of opencv)

  3. Compile opencv

cd ~/opencv-*
mkdir build
cd build
cmake ..

compile Opencv with the following parameters:

 WITH_GSTREAMER                   ON
 WITH_GTK                         OFF                                          
 WITH_OPENGL                      ON                                           

You can setup this parameters through > ccmake ..

make
sudo make install

3. Calibrate on opencv

Use this is example: http://wiki.ros.org/camera_calibration

IMAGE ALT TEXT

  1. Run camera:

In usb usb_cam package for usb camera,to change resolution open usb_cam-test.launch.
Adjust:
image_width
image_height
pixel_format (I found for myself that mjpeg fastest format)

roslaunch usb_cam usb_cam-test.launch
  1. Start camera calibrator:
rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.035 image:=/usb_cam/image_raw camera:=/usb_cam

where --square= chessboard square size in meters. --size= chessboard size as NxM, counting interior corners (e.g. a standard chessboard is 7x7)

  1. After calibration, specify the path to .yaml with camera parameters in the file usb_cam/launch/usb_cam-test.launch
    <param name="camera_info_url" value="file:///camera_param.yaml" />

4. Install aruco_ros

Download and install:
aruco_eye

  1. In Aruco_eye_ros you need to change params in launch files:
  • aruco_eye/aruco_eye_ros/launch/aruco_eye_ros_detector.launch
  • aruco_eye/aruco_eye_ros/launch/aruco_eye_ros_display.launch
    <param name="image_topic_name" value="/usb_cam/image_raw" />
    <param name="camera_info_topic_name" value="/usb_cam/camera_info" />
  1. In aruco_eye/aruco_eye_ros/config/arUcoList.xml adjust size of markers in meters.
<arucoMarker>
  <id>2</id>
  <size>0.253</size>
</arucoMarker>

5. Test run

  1. Now open three terminals and launch in this sequence
roslaunch usb_cam usb_cam-test.launch                 # Launches usb_cam topics
roslaunch aruco_eye_ros aruco_eye_ros_detector.launch # Launches aruco_detectors topics and publish pose of makers in topics
roslaunch aruco_eye_ros aruco_eye_ros_display.launch  # Launches graphical visualization for coordinate frames in window