0
votes

I'm trying to duplicate an example for line detection from java to native code.

My Java code is as follows

int[] linesArray = new int[lines.cols() * lines.rows() * lines.channels()];
lines.get(0,0,linesArray); //the function in question. Reads Mat data into the lines array

for (int i=0; i < linesArray.length; i = i + 4)
{
    //loop through the data and do stuff       
}

but in C++ native code, there is no Mat::get() function. How can I read the data from my lines Mat into my linesArray

so far I have this for C++, mostly the same

int linesArray[lines.cols * lines.rows * lines.channels()];
lines.get(0,0,linesArray); //get is not a member of cv::Mat
unless lines.cols, lines.rows, and lines.channels() are all constexpr (which I suspect is not the case), you cannot use them for stack allocated arrays. You will need to heap allocate with either new or something like std::vectorEvan Teran
cv::Mat::data if you really need to get at the underlying array. For iteration there are iterators.Dan Mašek
And just out of curiosity, what's in the body of that loop?Dan Mašek
tldr: just a line drawing function, but we resize our image to increase performance, so we need to also scale the points as wellPremier Bromanov