用户在进行人脸识别项目时遇到了图像翻转功能的问题。
img=sensor.snapshot()
img.flip(vertical=True)用户尝试使用img.flip(vertical=True)方法进行图像垂直翻转,但提示该属性不存在。
测试了下使用VFLIP还是无法翻转图像
# This work is licensed under the MIT license.
# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Vertical Flip - Horizontal Mirror - Transpose
#
# This example shows off how to vertically flip, horizontally mirror, or
# transpose an image. Note that:
#
# vflip=False, hmirror=False, transpose=False -> 0 degree rotation
# vflip=True, hmirror=False, transpose=True -> 90 degree rotation
# vflip=True, hmirror=True, transpose=False -> 180 degree rotation
# vflip=False, hmirror=True, transpose=True -> 270 degree rotation
import sensor
import time
import image
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time=2000)
clock = time.clock()
ticks = time.ticks_ms()
counter = 0
while True:
clock.tick()
# You can also use image.ROTATE_180, image.ROTATE_90, image.ROTATE_270, etc.
vflip = image.VFLIP if (counter // 2) % 2 else 0
hmirror = image.HMIRROR if (counter // 4) % 2 else 0
transpose = image.TRANSPOSE if (counter // 8) % 2 else 0
img = sensor.snapshot().scale(hint=(vflip | hmirror | transpose))
if time.ticks_diff(time.ticks_ms(), ticks) > 1000:
ticks = time.ticks_ms()
counter += 1
print(clock.fps())