c++ OpenCV Turn a Mat into a 1 Dimensional Array

前端 未结 1 1327
南旧
南旧 2021-01-28 23:17

I have this Mat:

Mat testDataMat(386, 2, CV_32FC1, testDataFloat);

Which takes in from:

float testDataFloat[386][2         


        
1条回答
  •  囚心锁ツ
    2021-01-28 23:32

    sample includes:

    1. direct method to convert from float 2d array to float 1d array.
    2. way to create a cv::Mat from 2D float array
    3. way to create 1D float array from a 2D cv::Mat that has no padding (e.g. stepsize = size of a single row)

    This one works for me:

    int main()
    {
        const int width = 2;
        const int height = 386;
        float testDataFloat[height][width];
    
        // create/initialize testdata
        for(unsigned int j=0; j

    0 讨论(0)
提交回复
热议问题