人脸识别的时候,如何将帧缓冲区里的图像实时传输到LCD屏中
-
-
-
@kidswong999 我就这样做的,但是LCD上面显示的图像是最后拍照时候的图像,并不是一直和缓冲区里面的一样
import sensor, image, pyb, lcd RED_LED_PIN = 1 BLUE_LED_PIN = 3 sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.GRAYSCALE sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others) sensor.set_windowing((92,112)) sensor.skip_frames(10) # Let new settings take affect. sensor.skip_frames(time = 2000) lcd.init() num = 1 #设置被拍摄者序号,第一个人的图片保存到s1文件夹,第二个人的图片保存到s2文件夹,以此类推。每次更换拍摄者时,修改num值。 n = 10 #设置每个人拍摄图片数量。 img=sensor.snapshot() #连续拍摄n张照片,每间隔3s拍摄一次。 while(n): lcd.display(img) #红灯亮 pyb.LED(RED_LED_PIN).on() sensor.skip_frames(time = 3000) # Give the user time to get ready.等待3s,准备一下表情。 #红灯灭,蓝灯亮 pyb.LED(RED_LED_PIN).off() pyb.LED(BLUE_LED_PIN).on() #保存截取到的图片到SD卡 print(n) sensor.snapshot().save("face/s%s/%s.pgm" % (num, n) ) # or "example.bmp" (or others) n -= 1 pyb.LED(BLUE_LED_PIN).off() print("Done! Reset the camera to see the saved image.")
-
代码不对,根本不是按照视频做的,你的img变量后面没有更新。
更改后的代码:
import sensor, image, pyb, lcd RED_LED_PIN = 1 BLUE_LED_PIN = 3 sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.GRAYSCALE sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others) sensor.set_windowing((92,112)) sensor.skip_frames(10) # Let new settings take affect. sensor.skip_frames(time = 2000) lcd.init() num = 1 #设置被拍摄者序号,第一个人的图片保存到s1文件夹,第二个人的图片保存到s2文件夹,以此类推。每次更换拍摄者时,修改num值。 n = 10 #设置每个人拍摄图片数量。 #连续拍摄n张照片,每间隔3s拍摄一次。 while(n): #红灯亮 pyb.LED(RED_LED_PIN).on() sensor.skip_frames(time = 3000) # Give the user time to get ready.等待3s,准备一下表情。 #红灯灭,蓝灯亮 pyb.LED(RED_LED_PIN).off() pyb.LED(BLUE_LED_PIN).on() #保存截取到的图片到SD卡 print(n) img = sensor.snapshot() lcd.display(img) img.save("face/s%s/%s.pgm" % (num, n) ) # or "example.bmp" (or others) n -= 1 pyb.LED(BLUE_LED_PIN).off() print("Done! Reset the camera to see the saved image.")