I am getting frames from the N6 camera in GRAYSCALE mode at a rate of ~120 frames per second (1280x800 pixels per frame). I need to perform a very, very fast pixel-by-pixel conversion of the frame using threshold. If the pixel value is between 0 and 126, set the pixel value to 0, and if the pixel value is between 127 and 255, set the pixel value to 1. However, when using the img.binary command, the frame rate drops from 120 frames per second to 29 frames per second! If you iterate over all pixels in a loop using the command img.get_pixel(x, y), the speed is less than 1 frame per second. What are some ways to convert a frame very quickly?
Hi Frank, if I give you a custom firmware with binary() accelerated with ARM Helium for the grayscale thresholding loop this can probably hit 120 FPS. However, that juts gives you an image where pixels are 0 or 255 with 1 byte per pixel. What do you plan to do with that output? I assume you have other steps you want to do.
Hi kwagyeman!
I will have a line several pixels thick in the frame. That is, there will be a
lot of pixels with a value of 0 and very few pixels with a value of 255.
I need to compress this frame as much as possible so that the data packet
occupies a very small volume and transfer this data packet to the computer via
Ethernet shield
A PNG image will be the best for this. I just added binary support for PNG images. So, this can be done very quickly. However, you will not get 120 FPS with PNG compression.
You kinda need to write C code if you really want to do what you are looking to do as fast as possible.
C++ is the main programming language that I know very well, and it would be great if I could insert C code into MicroPython.I would try to do compression using the RLE algorithm. Is this possible?
Yes, also, use Claude code, it can help. Please see our programming guide. There’s a new make sdk command that makes installing the tools easy.
I just added binary support for PNG images
Can you tell me where to see it and how to apply it?
You just do .to_png() which will png compress the image.
Thank you very much !
HI kwagyeman !
After you helped me with the firmware build through WSL for Windows, I want to try to make the first steps of writing C++ code without using MicroPython. I need this for very fast processing of a frame from the camera. I have experience of writing code on STM32 on Arduino through the stm32duino library. To start, I want to just blink the LED (Hello Word) on the N6. Do I understand correctly that I need to write C++ code in the openmv\ports\stm32\main.c file in int main(void) {} after initializing all procedures? For example, after the lines // Initialize OpenMV protocol
omv_protocol_init_default(); I will add while(1){} and write my own code inside. Please tell me how to do it correctly without using MicroPython.
Hi Frank, we do not provide help or support for directly modifying the C code. I suggest you get set up with an AI coder like Claude and ask it for help on this. Using these tools, you will become very effective at making the changes you want. The AI can see the entire codebase and solve most of what you’d like to do.
I understand you.
I’ll try.
Thank you!