openmv基础

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.
    print(clock.fps())              # Note: OpenMV Cam runs about half as fast when connected
                                    # to the IDE. The FPS should increase once disconnected.
  • image.get_pixel(x, y)
    • 对于灰度图: 返回(x,y)坐标的灰度值.
    • 对于彩色图: 返回(x,y)坐标的(r,g,b)的tuple.

同样,我们可以通过image.set_pixel(x, y, pixel)方法,来设置一个像素点的值。

  • image.set_pixel(x, y, pixel)
    • 对于灰度图: 设置(x,y)坐标的灰度值。
    • 对于彩色图: 设置(x,y)坐标的(r,g,b)的值。

roi的格式是(x, y, w, h)的tupple.

  • x:ROI区域中左上角的x坐标
  • y:ROI区域中左上角的y坐标
  • w:ROI的宽度
  • h:ROI的高度
  • image.width()
    返回图像的宽度(像素)

  • image.height()
    返回图像的高度(像素)

  • image.format()
    灰度图会返回 sensor.GRAYSCALE,彩色图会返回 sensor.RGB565。

  • image.size()
    返回图像的大小(byte)

  • 画线

  • image.draw_line(line_tuple, color=White) 在图像中画一条直线。
    • line_tuple的格式是(x0, y0, x1, y1),意思是(x0, y0)到(x1, y1)的直线。
    • 颜色可以是灰度值(0-255),或者是彩色值(r, g, b)的tupple。默认是白色
  • 画框

  • image.draw_rectangle(rect_tuple, color=White) 在图像中画一个矩形框。
    • rect_tuple 的格式是 (x, y, w, h)。
  • 画圆

  • image.draw_circle(x, y, radius, color=White) 在图像中画一个圆。
    • x,y是圆心坐标
    • radius是圆的半径
  • 画十字

  • image.draw_cross(x, y, size=5, color=White) 在图像中画一个十字
    • x,y是坐标
    • size是两侧的尺寸
  • image.draw_string(x, y, text, color=White) 在图像中写字 8x10的像素
    • x,y是坐标。使用\n, \r, and \r\n会使光标移动到下一行。
    • text是要写的字符串。

你可能感兴趣的:(大数据)