Visual Servoing Platform
version 3.4.0
|
This tutorial shows how to use Tutorial: Bar code detection and Tutorial: Pose estimation from points in order to estimate the pose of a QRcode. After a first step that enables QRcode detection, the pose estimation process is achieved from the location of the four QRcode corners. The 3D coordinates of the corners are set knowing the size of the QRcode while their 2D coordinates are extracted from the image and transformed in the image plane thanks to camera intrinsic parameters.
Note that all the material (source code and image) described in this tutorial is part of ViSP source code and could be downloaded using the following command:
Note also that ViSP has to be built with zbar 3rd party library that enables barcode detection. See zbar quick installation guide.
In this section we consider the case of an image that may contain a 12 by 12 cm square QRcode. The camera should be calibrated (see Tutorial: Camera intrinsic calibration). For each QRcode that is detected thanks to vpDetectorQRCode class, we update the coordinates of the four corners as a vpPoint object and compute the pose from the four points thanks to vpPose class. This process is replicated in a while loop. The end of the loop is reached when the user click in the image that is displayed.
The corresponding source code also provided in tutorial-pose-from-qrcode-image.cpp is the following.
Here is a screen shot of the resulting program:
More source code explanations could be found in Tutorial: Bar code detection and Tutorial: Pose estimation from points.
Note that adapting this tutorial to process images coming from a camera live stream consists in replacing the lines
by
where g
is nothing more than a grabber instantiated as a vp1394TwoGrabber, vpFlyCaptureGrabber, vpV4l2Grabber or vpRealSense. How to implement framegrabbing is explained in Tutorial: Image frame grabbing.
You are now ready to see the next Tutorial: Homography estimation from points that shows how to estimate an homography from points.