assign Image from constant

I am a beginner in Python but perhaps someone could help

instead reading the template from the SD-Card

template = image.Image("/template.pgm")

i would prefer something like to generate a low resolution image:

templateLowRes = image.Image(grayscale (5,3) raw = [0, 255, 255, 255, 255, 0 , 255, 0, 255, 0, 0, 255, 255, 255, 255]

and then zoom it by a factor of 3

template = templateLowRes.resize(3.0, 3.0)

If the “zoom” is not possible I am also happy with the initialization of a grayscale image in a size (w =15, h = 9) and the assigment with const

Mmm…

So, keep in mind we didn’t really want to implement arbitrary image resizing on the OpenMV Cam because you really don’t have a lot of RAM. It’s not a desktop PC where you can easily malloc large memory buffers.

Anyway, if you’d like to do this use the sensor.alloc_extra_fb() method (see the docs under sensor) and alloc all the extra frame buffers you need. The buffers are allocated via a stack like structure so they don’t use up memory in the main heap space.

Once you do that you can draw on the frame buffers via set_pixel().

For an example of using these extra buffers see the frame differencing scripts.