How to Resize Image?

I’m using the Cam H7 to identify objects that fill the field of view of the sensor. When training an ML algorithm, the training images are resized. I have not seen a method in OpenMV for resizing images (for example resize from QVGA 320x240 to 64x64).

A work-around I came up with is to use an extra_fb and combine the zoom of img.rotation_corr with a crop in img.copy.

extra_fb = sensor.alloc_extra_fb(64,64,sensor.GRAYSCALE)
img = sensor.snapshot()

resize to (88x66) = (320x240) * 0.275, resized image starts at x=116, y = 87


crop middle 64x64

roi_copy = (128,88,64,64)
extra_fb = img.copy(roi=roi_copy)

Is there a better way to do a resize in OpenMV?


There’s an x/y scale.

Also, if you are using the latest firmware not yet released we have a new bicubic and bilinear scaling pipeline integrated into draw_image. copy/crop/etc will be updated to use it.

You can also crop the images captured by the sensor by using set_windowing: