>>> 星瞳科技|OpenMV中国官方网站 <<<
>>> 星瞳科技店铺地址|OpenMV中国官方代理,全球九大代理商之一 <<<
>>> OpenMV3 Cam M7 官方高配版上市啦~戳我戳我戳我~ <<<
>>> 星瞳科技-OpenMV中文教程网 <<<
# Hello World Example # # Welcome to the OpenMV IDE! Click on the start button below to run the script! #用usb线与电脑连接后,打开 文件——examples——01Basic——helloworld.py例程,点击左下角 #绿色箭头按钮运行。 import sensor, image, time #引入此例程依赖的模块,sensor是与摄像头参数设置相关的模块,image是图像处理相关的模块, #time时钟控制相关的模块。import相当于c语言的#include <>,模块相当于c语言的库。 sensor.reset() # Initialize the camera sensor. #初始化摄像头,reset()是sensor模块里面的函数 sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE #设置图像色彩格式,有RGB565色彩图和GRAYSCALE灰度图两种 sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others) #设置图像像素大小,sensor.QQVGA: 160x120,sensor.QQVGA2: 128x160 (一般用于LCD #扩展板),sensor.QVGA: 320x240,sensor.QQCIF: 88x72,sensor.QCIF: 176x144,sensor.CIF: 352x288 sensor.skip_frames(10) # Let new settings take affect. clock = time.clock() # Tracks FPS. #初始化时钟 #注意:python中没有大括号{},以缩进代替{},而且缩进的tab和空格不能混用,一个程序只能用一种缩进(一个tab或者四个空格) while(True): #python while循环,一定不要忘记加冒号“:” clock.tick() # Track elapsed milliseconds between snapshots(). img = sensor.snapshot() # Take a picture and return the image. #截取当前图像,存放于变量img中。注意python中的变量是动态类型,不需要声明定义,直接用即可。 print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while #打印当前的帧率。 # connected to your computer. The FPS should increase once disconnected.
至此,点击左下角绿色箭头运行就可以看到摄像头图像啦!