Acces Matrix value without knowing the type opencv

后端 未结 2 624
野的像风
野的像风 2020-12-21 03:06

I am writing a function in which I need to access to a element of a Mat, but this function can receive Mat of differents types. So, if I have:

2条回答
  •  温柔的废话
    2020-12-21 03:29

    If it is a possibility, make the function receiving the openCV Mat a template function:

    void f(const Mat& m)
    {
        (void) m.at(0, 0);
    }
    

    use it like that:

    Mat m1/* ... */;
    m1.at(0, 0) = 0;
    f(m);
    

提交回复
热议问题