logo

想要把多个帧的同一个区域截取出来,拼到一张图上怎么做?

2020-05-06 15:43
B
gtao

1、查到了image构造函数可以生成一个空白的,自定义像素尺寸的图像(这张图当作底版)

img1=image.Image(500,500,sensor.RGB565, copy_to_fb=True)

2、查到了draw_image函数,可以把一幅图画到另一图(底版图)的相应位置,用mask来遮罩只剩下想要的区域

实践了下,出问题了,以下是代码

import sensor, image, time

sensor.reset() # Reset and initialize the sensor.

sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)

sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)

sensor.skip_frames(time = 2000) # Wait for settings take effect.

clock = time.clock() # Create a clock object to track the FPS.

img_bottom=image.Image(500,500,sensor.RGB565, copy_to_fb=True)

imgsensor = sensor.snapshot() # Take a picture and return the image.

img_bottom.draw_image(imgsensor,(2,2))

046df499-aa6b-47d2-b363-a50776e0747b.png

Image is not mutable!

怎么回事?求帮助

2020-05-06 18:52
I
网红小智智 星瞳科技

为什么要这么做。。。?

2020-05-11 10:39
B
gtao

@kidswong999 物体在架子上旋转,需要拍物体旋转一周的图像,拼接成一张图,再进行后续操作

2020-05-11 12:24
I
网红小智智 星瞳科技

draw_image不能超出范围的。所以应该不能这么做。。。。