assign Image from constant

Discussion related to "under the hood" OpenMV topics.
noeldi
Posts: 3
Joined: Mon Nov 05, 2018 4:58 am

assign Image from constant

Postby noeldi » Wed Nov 07, 2018 10:21 am

I am a beginner in Python but perhaps someone could help

instead reading the template from the SD-Card

Code: Select all

template = image.Image("/template.pgm")
i would prefer something like to generate a low resolution image:

Code: Select all

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

Code: Select all

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
User avatar
kwagyeman
Posts: 2462
Joined: Sun May 24, 2015 2:10 pm

Re: assign Image from constant

Postby kwagyeman » Wed Nov 07, 2018 12:20 pm

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.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 9 guests