Aruco期望什么图像编码?

时间:2018-05-23 09:16:36

标签: opencv encoding rgb aruco

我的应用程序会收到可能具有bayer_rggb8编码的相机图像。我是否需要将这些图片转换为bgr8 / rgb8 / mono8?或者Aruco可以检测拜耳编码的cv::Mat s?

中的标记

我正在使用Aruco 3.0.10。以下是我正在使用的功能。

    /**Detects the markers in the image passed
        *
        * If you provide information about the camera parameters and the size of the marker, then, the extrinsics of
     * the markers are detected
        *
        * @param input input color image
        * @param detectedMarkers output vector with the markers detected
        * @param camParams Camera parameters
        * @param markerSizeMeters size of the marker sides expressed in meters
        * @param setYPerperdicular If set the Y axis will be perpendicular to the surface. Otherwise, it will be the
     * Z axis
        */
    void detect(const cv::Mat& input, std::vector<Marker>& detectedMarkers, CameraParameters camParams,
                float markerSizeMeters = -1, bool setYPerperdicular = false);

我试着给它bayer_rggb8编码的图像,这似乎有效(它检测标记)。但我想知道这是否应该有用,或者我是否幸运,我的测试图像。

左:原始图像,错误显示为brg8。右:图像转换/颜色插值到BGR8并用标记注释。 (在左图上检测到标记。) enter image description here

1 个答案:

答案 0 :(得分:1)

它接受CV_8UC1灰度图像(mono8)或CV_8UC3彩色图像(bgr8)。它不适用于拜耳编码的垫子。

如有疑问,请检查源代码。

您可以看到aruco.cpp第一个操作是将图像转换为灰度:

_convertToGrey(_image.getMat(), grey);

函数_convertToGray接受CV_8UC1(已经确定)或CV_8UC3(转换为灰度):

static void _convertToGrey(InputArray _in, OutputArray _out) {

    CV_Assert(_in.getMat().channels() == 1 || _in.getMat().channels() == 3);

    _out.create(_in.getMat().size(), CV_8UC1);
    if(_in.getMat().type() == CV_8UC3)
        cvtColor(_in.getMat(), _out.getMat(), COLOR_BGR2GRAY);
    else
        _in.getMat().copyTo(_out);
}