Hi, there,
I have encountered a similar issue to this post regarding creating an image on the fly from an ulab ndarray and then convert it back to an ndarray. The code I have is pretty lengthy so I will try describing it first. If we need a minimum example to replicate the problem, I can provide that too.
In our case, I did not use sensor.alloc_extra_fb
to host the image on the stack. Instead, the image is created as a local variable from a local ndarray in a function called at each iteration of a loop. After applying .morph() method on the image for the purpose of convolution, the image is converted back to an ndarray and we extract the information from it, leaving the local scope without explicitly calling del
methods.
The problem is, this method seemingly “corrupts” random memory locations, specifically the step of creating the image from the ndarray and converting it back to an ndarray. In more details, we implemented the aforementioned function in a class. The class has some member variables and functions. The behaviors that lead to this suspicion include the followings:
- A member float variable (that serves as a constant in the code) has its sign flipped.
- Accessing a member function throws a NotImplementedError with null opcode
- Accessing an existing member variable throws AttributeError, stating the class does not have “”
draw_rectangle()
does not draw anything on the snapshot() image. # ← This one happens less often so it might be the values I get from the ndarray are not correct.- A board crash which causes reconnection to the computer/everything onboard (LED states, UART communication) to halt forever. After reconnection, the error trace would make no sense as they refer to functions that we had but no longer exist, for example.
These behaviors would happen at random time from starting the program. 2., 3., and 5. would stop the program. 1. and 4. would keep the program running but the results basically become invalid. Only one of these behaviors would happen at one runtime. If I remove the image creation and the conversion to ndarray, none of the behaviors happen any more.
We tested the same program on both NiclaVision (Firmware 4.5.9) and OpenMV RT1062 (Firmware 4.6.0). It happens more often and sooner on NiclaVision which made me lean toward that suspicion more since Nicla has way less RAM than RT1062.