OpenCV How to initialize Mat with 2D array in JAVA

mat, multidimensional-array, opencv

Solution

Sorry don't know about Java but can suggest the general logic. In C++ openCV we do it by 2 `for loops` as following:

matObject.create( array.rows, array.cols, CV_8UC1 ); // 8-bit single channel image

for (int i=0; i<array.rows; i++)
{
    for(int j=0; j<array.cols; j++)
    {
         matObject.at<uchar>(i,j) = array[i][j];
    }
}

Let me know if it was your query..

Problem

Suppose, I have a 2D array initialized with values, how do I put this value in a Mat object in OpenCV?

Original source