基于OpenMV平台进行开发:
特别注意:
起始时间为上电时间,时间只能显示分和秒
程序运行结果:
程序代码:
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.
while(True):
clock.tick() # Update the FPS clock.
img = sensor.snapshot() # Take a picture and return the image.
time_data = time.ticks()
time_data = time_data//1000
minute = time_data//60
second = time_data%60
time_show = "minute:%d second:%d" % (minute,second)
img.draw_string(0, 0, time_show, color=255)
print(time_show)