Drawing

Visual system often provide users with some feedback information which display directly in the image. You only need to find the color lump and mark it with a rectangular frame, which is as direct as the program inQuickstart in 10 minutes

Note:

  • The color ranges from grayscale(0-255) to the tuple of the color (r, g, b).

  • The keyword of color should be marked as color=. For example:

image.draw_line((10,10,20,30), color=(255,0,0))
image.draw_rectangle(rect_tuple, color=(255,0,0))

Drawing a line

  • image.draw_line(line_tuple, color=White) Draw a line in the image.
    • The format of the line_tuple is (x0, y0, x1, y1), which means a line going from (x0, y0) to (x1, y1).
    • The color ranges from grayscale(0-255) to the tuple of the color (r, g, b). And the default color is white.

Drawing a rectangular

  • image.draw_rectangle(rect_tuple, color=White) Draw a rectangular in the image.
    • rect_The format of the tupple is (x, y, w, h).

Drawing a circle

  • image.draw_circle(x, y, radius, color=White) Draw a circle in the image.
    • x,y is the coordinate of the center of the circle.
    • Radius is the radius of the circle.

Drawing a cross

  • image.draw_cross(x, y, size=5, color=White) Draw a cross in the image.
    • x,y is its coordinate.
    • Size means the bilateral size

Writing

  • image.draw_string(x, y, text, color=White) Write in the image in 8x10 pixel.
    • x,y is the coordinate. Use \n, \r, and \r\n can make the cursor move down to the next line.
    • Text is the character string to write.

Examples

# Hello World Example
#
# Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!

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):
    img = sensor.snapshot()         # Take a picture and return the image.
    img.draw_line((20, 30, 40, 50))
    img.draw_line((80, 50, 100, 100), color=(255,0,0))
    img.draw_rectangle((20, 30, 41, 51), color=(255,0,0))
    img.draw_circle(50, 50, 30)
    img.draw_cross(90,60,size=10)
    img.draw_string(10,10, "hello world!")

results matching ""

    No results matching ""