NXP

openmv学习之旅①

2019-07-12 13:49发布

最近入手了个OpenMv,还要感谢二姨家的平台啊。感谢
装IDE这种小事就不说了。说说真正入门的操作吧。对蟒也没啥要求。我也是这样子马上上手的,当然在过程我是学习了蟒蛇的。

1:绘制矩形函数说明image.draw_rectangle(rect_tuple,颜 {MOD}=白 {MOD})参数rect_tuple格式(x,y,w,h)矩阵的起始坐标,(x,y),即矩形的左上角坐标w:矩形的宽度h:矩形的高度x,y,w,h 均为整数颜 {MOD}颜 {MOD},填入灰度值(0-255),或者 RGB (r,g,b)下面简单画个矩形
样例代码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(30) # Wait for settings take effect. clock = time.clock() # Create a clock object to track the FPS. x = 100 y = 100 width = 100 height = 100 rect_tuple = (x, y, width, height) rgb_white = (255, 255, 255) # (r=255, g=255, b=255) -> white color while(True): clock.tick() # Update the FPS clock. img = sensor.snapshot() # Take a picture and return the image. img.draw_string(x, y, "(%d, %d)"%(x, y), color=rgb_white) img.draw_rectangle(rect_tuple, color=rgb_white) print(clock.fps()) # Note: OpenMV Cam runs about half as fast when connected这就是简单画矩形的图像,想要改变矩形位置就改变的x,y(图像左上角起点)想要改变矩形面积就改变宽度高度(图像宽高)改变线条颜 {MOD}就改变 rgb_white
2:绘制十字函数说明image.draw_cross(x,y,size = 5,color = White)参数X十字中心的 X 坐标Y十字中心的 ÿ 坐标尺寸十字的长度颜 {MOD}颜 {MOD},填入灰度值(0-255),或者 RGB (r,g,b)样例代码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(30) # Wait for settings take effect. clock = time.clock() # Create a clock object to track the FPS. x = 150 y = 150 size = 20 rgb_white = (255, 255, 255) # (r=255, g=255, b=255) -> white color while(True): clock.tick() # Update the FPS clock. img = sensor.snapshotA() # Take a picture and return the image. img.draw_string(x, y, "(%d, %d)"%(x, y), color=rgb_white) img.draw_cross(x, y, size=size, color=rgb_white) print(clock.fps()) # Note: OpenMV Cam runs about half as fast when connected学会简单画图,就可以使用 openmv 来做 {MOD}彩追踪了。未完待续......下篇用openmv来做 {MOD}彩追踪