Visual Servoing Platform
version 3.2.0 under development (2019-01-22)
|
ViSP is interfaced with OpenCV third party. In this tutorial we explain how to convert data such as camera parameters or images from ViSP to OpenCV or vice versa.
ViSP camera parameters are implemented in vpCameraParameters class. If you want to calibrate a camera with ViSP tools follow Tutorial: Camera intrinsic calibration.
Let us recall the pinhole camera model implemented in ViSP. In this model, a scene view is formed by projecting 3D points into the image plane using a perspective transformation.
where:
When , the previous equation si equivalent to the following:
Real lenses usually have some radial distortion. So, the above model is extended as:
where is the first order radial distorsion. Higher order distorsion coefficients are not considered in ViSP.
Even if OpenCV notations are different, this model is exactly the same then the one used in OpenCV and described here where higher order OpenCV distorsion parameters are turned to 0.
The following table gives the correspondances between ViSP and OpenCV parameters:
From a coding point of view, let us consider the following code also available in tutorial-bridge-opencv.cpp where we initialize camera parameters using ViSP:
These parameters could be used to initialize OpenCV camera parameters:
ViSP image is implemented in vpImage class, while OpenCV images in cv::Mat class. All the functions that allow image conversion from ViSP to OpenCV or vice versa are implemented in vpImageConvert.
Some examples are available in tutorial-bridge-opencv.cpp.
For example, the following code allow to read an image with ViSP:
and then convert the image in OpenCV using: