I'm trying to create a mat from an 2d array using the cv.matFromArray(rows, cols, type, array);
method.
It works with really small arrays like this:
let mat = cv.matFromArray(2, 2, cv.CV_8UC1, [255, 255, 128, 128]);
return mat; // works
But when i basically do the same thing with my image array (1024x1024px, values range from 20 to 230) it just fills every Mat value to 0
const mat = cv.matFromArray(img_array.length, img_array[0].length, cv.CV_8UC1, img_array);
return mat; // every value is 0
Why is that?
Okay, I converted the 2d array to 1d like this:
[].concat(...img_array);
and its working now:
img_array; // 1024x1024px 2d array
const mat = cv.matFromArray(img_array.length, img_array[0].length, cv.CV_8UC1, [].concat(...img_array));
return mat;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.