-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Using a 640x480 image (source: Wikipedia), I attempted to downsample it for display with cv2.imshow(display, img[::2, ::2]). In standard Python, the following was displayed:
In MicroPython, the following was displayed:
Poking around with a debugger right here:
micropython-opencv/src/convert.cpp
Line 113 in da558f4
| Mat mat = Mat(ndims, size, type, (void*) ndarray->array, step); |
The constructed Mat object's step array does not match the provided step array:
(gdb) p step
$8 = {3840, 6, 0 <repeats 31 times>}
(gdb) p mat.step.buf
$9 = {3840, 3}
I suspect the problem is here:
@param steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always set to the element size)...
Not sure why there's a discrepancy between standard Python and MicroPython, because ndarray_to_mat() is basically the same as pyopencv_to() (at least, as far as how step is constructed). I suspect when standard NumPy does the array slicing, it makes a copy instead of reusing the same array like ulab NumPy does, so forcing the last element of steps to be the element size isn't a problem. Maybe. Regardless, might just be able to force the Mat object's step array to match.

