diff --git a/docs/library/network.WINC.rst b/docs/library/network.WINC.rst index 1f94a9f606f7..06008dff8134 100644 --- a/docs/library/network.WINC.rst +++ b/docs/library/network.WINC.rst @@ -63,10 +63,10 @@ Constructors argument is passed. Otherwise, query current state if no argument is provided. Most other methods require active interface. - .. method:: connect(ssid, [key=None, [security=WPA_PSK]]) + .. method:: connect(ssid, [key=None, [security=WPA_PSK, [channel=1]]]) Connect to a wifi network with ssid ``ssid`` using key ``key`` with - security ``security``. + security ``security`` and channel ``channel``. After connecting to the network use the :mod:`usocket` module to open TCP/UDP ports to send and receive data. @@ -141,11 +141,12 @@ Constructors Returns a list containing: - * [0]: Channel Number (int) - * [1]: RSSI - received signal strength indicator (int) - * [2]: Authorization Type (see constants) - * [3]: MAC Address String (XX:XX:XX:XX:XX:XX) (BSSID) - * [4]: Set Service Identifier String (SSID) + * [0]: Set Service Identifier String (SSID) + * [1]: MAC Address String (XX:XX:XX:XX:XX:XX) (BSSID) + * [2]: Channel Number (int) + * [3]: RSSI - received signal strength indicator (int) + * [4]: Authorization Type (see constants) + * [5]: 1 (int) You don't need to be connected to call this. @@ -183,14 +184,14 @@ Constructors For connecting to an open wifi network. - .. data:: WEP - - For connecting to a WEP based password protected network. - .. data:: WPA_PSK For connecting to a WPA/PSK based password protected network. + .. data:: 802_1X + + Network is secured with WPA/WPA2 Enterprise. + .. data:: MODE_STA Start in station mode (i.e. connect to a network). @@ -199,6 +200,14 @@ Constructors Start in access point mode (i.e. become the network). + .. data:: MODE_P2P + + Start in wifi-direct mode. + + .. data:: MODE_BSP + + Init BSP. + .. data:: MODE_FIRMWARE Setup in firmware update mode. diff --git a/docs/library/omv.display.DACBacklight.rst b/docs/library/omv.display.DACBacklight.rst new file mode 100644 index 000000000000..07c9a5e9d71b --- /dev/null +++ b/docs/library/omv.display.DACBacklight.rst @@ -0,0 +1,33 @@ +.. currentmodule:: display +.. _display.DACBacklight: + +class DACBacklight -- DAC Backlight +=================================== + +The `DACBacklight` class is used to control a screen backlight. + +Constructors +------------ + +.. class:: display.DACBacklight(channel, [bits=8]) + + Creates a backlight object to initialize the display backlight. This class should be passed as + the ``backlight`` argument to any display object constructor which can use a backlight controller. + + ``channel`` specifies the DAC channel to use. This can be the GPIO pin also. For STM32 based + OpenMV Cams this is ``P5``. + + ``bits`` specifies the resolution of the DAC. The default value of 8-bits should be good enough. + +Methods +------- + +.. method:: DACBacklight.deinit() + + Deinitializes the backlight controller. + +.. method:: DACBacklight.backlight([value]) + + Sets the backlight strength from 0-100. Note that a linear voltage on the backlight output + will not necessary result in a linear brightness change on the screen. Typically there's + a small region where the screen brightness will change drastically. diff --git a/docs/library/omv.display.PWMBacklight.rst b/docs/library/omv.display.PWMBacklight.rst new file mode 100644 index 000000000000..f352062ca423 --- /dev/null +++ b/docs/library/omv.display.PWMBacklight.rst @@ -0,0 +1,36 @@ +.. currentmodule:: display +.. _display.PWMBacklight: + +class PWMBacklight -- PWM Backlight +=================================== + +The `PWMBacklight` class is used to control a screen backlight. + +Constructors +------------ + +.. class:: display.PWMBacklight(pin, [timer=3, [channel=3, [frequency=200]]]) + + Creates a backlight object to initialize the display backlight. This class should be passed as + the ``backlight`` argument to any display object constructor which can use a backlight controller. + + ``pin`` specifies the Pin to use. + + ``timer`` specifies the Timer number to use. + + ``channel`` specifies the Timer channel to use. + + ``frequency`` specifies the PWM frequency. + +Methods +------- + +.. method:: PWMBacklight.deinit() + + Deinitializes the backlight controller. + +.. method:: PWMBacklight.backlight([value]) + + Sets the backlight strength from 0-100. Note that a linear pwm duty cycle on the backlight output + will not necessary result in a linear brightness change on the screen. Typically there's + a small region where the screen brightness will change drastically. diff --git a/docs/library/omv.display.dsidisplay.rst b/docs/library/omv.display.dsidisplay.rst index 727ef07fb4ac..2a0d6972eaa7 100644 --- a/docs/library/omv.display.dsidisplay.rst +++ b/docs/library/omv.display.dsidisplay.rst @@ -24,11 +24,11 @@ Example usage for driving the 800x480 MIPI LCD:: Constructors ------------ -.. class:: display.DSIDisplay([framesize=display.FWVGA, [refresh=60, [portrait=False, [channel=0, [controller]]]]]) +.. class:: display.DSIDisplay([framesize=display.FWVGA, [refresh=60, [portrait=False, [channel=0, [controller, [backlight]]]]]]) ``framesize`` One of the standard supported resolutions. - ``refresh`` Sets the LCD refresh rate in hertz. This controls the SPI LCD shield clock. + ``refresh`` Sets the screen refresh rate in hertz. This controls the DSI LCD clock. ``portrait`` Swap the framesize width and height. @@ -37,6 +37,9 @@ Constructors ``controller`` Pass the controller chip class here to initialize it along with the display. E.g. `display.ST7701()` which is a standard display controller for MIPI DSI displays. + ``backlight`` specify a backlight controller module to use. By default the backlight will be + controlled via a GPIO pin. + Methods ------- @@ -56,16 +59,20 @@ Methods Returns the refresh rate. -.. method:: DSIDisplay.write(image, [x=0, [y=0, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None]]]]]]]]]]]]) +.. method:: DSIDisplay.write(image, [x=0, [y=0, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None]]]]]]]]]]) + + Displays an ``image`` whose top-left corner starts at location x, y. - Displays an ``image`` whose top-left corner starts at location x, y. You may either pass x, y - separately, as a tuple (x, y), or neither. + You may also pass a path instead of an image object for this method to automatically load the image + from disk and draw it in one step. E.g. ``write("test.jpg")``. ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the image to display. This allows you to extract just the pixels in the ROI to scale. @@ -77,7 +84,7 @@ Methods ``alpha`` controls how opaque the image is. A value of 256 displays an opaque image while a value lower than 256 produces a black transparent image. 0 results in a perfectly black image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the input image is. This is applied after ``rgb_channel`` extraction if used. @@ -92,19 +99,18 @@ Methods * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being displayed on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to display - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to display - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). .. method:: DSIDisplay.clear([display_off=False]) @@ -116,9 +122,10 @@ Methods .. method:: DSIDisplay.backlight([value]) - Sets the lcd backlight dimming value. 0 (off) to 255 (on). + Sets the lcd backlight dimming value. 0 (off) to 100 (on). - This controls a PWM signal to a standard backlight dimming circuit. + Note that unless you pass `DACBacklight` or `PWMBacklight` the backlight will be controlled + as a GPIO pin and will only go from 0 (off) to !0 (on). Pass no arguments to get the state of the backlight value. diff --git a/docs/library/omv.display.rgbdisplay.rst b/docs/library/omv.display.rgbdisplay.rst index 1a1ab46f41c6..a6740e047413 100644 --- a/docs/library/omv.display.rgbdisplay.rst +++ b/docs/library/omv.display.rgbdisplay.rst @@ -24,11 +24,11 @@ Example usage for driving the 800x480 24-bit Parallel LCD:: Constructors ------------ -.. class:: display.RGBDisplay([framesize=display.FWVGA, [refresh=60, [display_on=True, [portrait=False, [controller]]]]]) +.. class:: display.RGBDisplay([framesize=display.FWVGA, [refresh=60, [display_on=True, [portrait=False, [controller, [backlight]]]]]]) ``framesize`` One of the standard supported resolutions. - ``refresh`` Sets the LCD refresh rate in hertz. This controls the SPI LCD shield clock. + ``refresh`` Sets the screen refresh rate in hertz. This controls the RGB LCD clock. ``display_on`` Enables the display. Pass `False` here when the 24-bit parallel LCD output is shared by multiple devices like the TFP410 chip for driving HDMI displays to keep the display @@ -38,6 +38,9 @@ Constructors ``controller`` Pass the controller chip class here to initialize it along with the display. + ``backlight`` specify a backlight controller module to use. By default the backlight will be + controlled via a GPIO pin. + Methods ------- @@ -57,16 +60,20 @@ Methods Returns the refresh rate. -.. method:: RGBDisplay.write(image, [x=0, [y=0, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None]]]]]]]]]]]]) +.. method:: RGBDisplay.write(image, [x=0, [y=0, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0]]]]]]]]]]) + + Displays an ``image`` whose top-left corner starts at location x, y. - Displays an ``image`` whose top-left corner starts at location x, y. You may either pass x, y - separately, as a tuple (x, y), or neither. + You may also pass a path instead of an image object for this method to automatically load the image + from disk and draw it in one step. E.g. ``write("test.jpg")``. ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the image to display. This allows you to extract just the pixels in the ROI to scale. @@ -78,7 +85,7 @@ Methods ``alpha`` controls how opaque the image is. A value of 256 displays an opaque image while a value lower than 256 produces a black transparent image. 0 results in a perfectly black image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the input image is. This is applied after ``rgb_channel`` extraction if used. @@ -93,19 +100,18 @@ Methods * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being displayed on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to display - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to display - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). .. method:: RGBDisplay.clear([display_off=False]) @@ -117,8 +123,9 @@ Methods .. method:: RGBDisplay.backlight([value]) - Sets the lcd backlight dimming value. 0 (off) to 255 (on). + Sets the lcd backlight dimming value. 0 (off) to 100 (on). - This controls a PWM signal to a standard backlight dimming circuit. + Note that unless you pass `DACBacklight` or `PWMBacklight` the backlight will be controlled + as a GPIO pin and will only go from 0 (off) to !0 (on). Pass no arguments to get the state of the backlight value. diff --git a/docs/library/omv.display.rst b/docs/library/omv.display.rst index 8b1aa1e7726a..be301f7ec66f 100644 --- a/docs/library/omv.display.rst +++ b/docs/library/omv.display.rst @@ -17,6 +17,8 @@ Classes omv.display.dsidisplay.rst omv.display.displaydata.rst omv.display.ST7701.rst + omv.display.DACBacklight.rst + omv.display.PWMBacklight.rst Constants --------- diff --git a/docs/library/omv.display.spidisplay.rst b/docs/library/omv.display.spidisplay.rst index f253e5d33fec..b4abbb116f60 100644 --- a/docs/library/omv.display.spidisplay.rst +++ b/docs/library/omv.display.spidisplay.rst @@ -24,7 +24,7 @@ Example usage for driving the 128x160 LCD shield:: Constructors ------------ -.. class:: SPIDisplay([width=128, [height=160, [refresh=60, [bgr=False, [byte_swap=False, [triple_buffer]]]]]]) +.. class:: SPIDisplay([width=128, [height=160, [refresh=60, [bgr=False, [byte_swap=False, [triple_buffer, [backlight]]]]]]]) ``width`` SPI LCD width. By default this is 128 to match the OpenMV 128x160 LCD shield. @@ -41,6 +41,9 @@ Constructors ``triple_buffer`` If True then makes updates to the screen non-blocking at the cost of 3X the display size in RAM. This is on by default for OpenMV Cam boards with SDRAM. + ``backlight`` specify a backlight controller module to use. By default the backlight will be + controlled via a GPIO pin. + .. note:: Uses pins P0, P2, P3, P6, P7, and P8. @@ -76,16 +79,20 @@ Methods Returns if triple buffering is enabled. -.. method:: SPIDisplay.write(image, [x=0, [y=0, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None]]]]]]]]]]]]) +.. method:: SPIDisplay.write(image, [x=0, [y=0, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0]]]]]]]]]]) + + Displays an ``image`` whose top-left corner starts at location x, y. - Displays an ``image`` whose top-left corner starts at location x, y. You may either pass x, y - separately, as a tuple (x, y), or neither. + You may also pass a path instead of an image object for this method to automatically load the image + from disk and draw it in one step. E.g. ``write("test.jpg")``. ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the image to display. This allows you to extract just the pixels in the ROI to scale. @@ -97,7 +104,7 @@ Methods ``alpha`` controls how opaque the image is. A value of 256 displays an opaque image while a value lower than 256 produces a black transparent image. 0 results in a perfectly black image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the input image is. This is applied after ``rgb_channel`` extraction if used. @@ -112,19 +119,18 @@ Methods * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being displayed on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to display - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to display - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). .. method:: SPIDisplay.clear([display_off=False]) @@ -136,10 +142,9 @@ Methods .. method:: SPIDisplay.backlight([value]) - Sets the lcd backlight dimming value. 0 (off) to 255 (on). + Sets the lcd backlight dimming value. 0 (off) to 100 (on). - In this controls the DAC on P6 to provide the dimming value. If set to 0 - P6 is pulled low and if set to 255 P6 is unitialized assuming that the SPI LCD shield's backlight - is by default always on. + Note that unless you pass `DACBacklight` or `PWMBacklight` the backlight will be controlled + as a GPIO pin and will only go from 0 (off) to !0 (on). Pass no arguments to get the state of the backlight value. diff --git a/docs/library/omv.fir.rst b/docs/library/omv.fir.rst index 012fcf6b41c1..1f64124eb167 100644 --- a/docs/library/omv.fir.rst +++ b/docs/library/omv.fir.rst @@ -233,17 +233,19 @@ Functions ``ir`` is a (width * height) list of floats (4-bytes each). -.. function:: draw_ir(image, ir, [x, [y, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=128, [color_palette=fir.PALETTE_RAINBOW, [alpha_palette=-1, [hint=0, [x_size=None, [y_size=None, [scale=(ir_min, ir_max)]]]]]]]]]]]]]) +.. function:: draw_ir(image, ir, [x, [y, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=128, [color_palette=image.PALETTE_RAINBOW, [alpha_palette=-1, [hint=0, [scale=(ir_min, ir_max)]]]]]]]]]]]) - Draws an ``ir`` array on ``image`` whose top-left corner starts at location x, y. You may either pass x, y - separately, as a tuple (x, y), or not at all. This method automatically handles rendering the image passed - into the correct pixel format for the destination image while also handling clipping seamlessly. + Draws an ``ir`` array on ``image`` whose top-left corner starts at location x, y. This method + automatically handles rendering the image passed into the correct pixel format for the destination + image while also handling clipping seamlessly. - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -257,7 +259,7 @@ Functions 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -272,20 +274,18 @@ Functions * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). ``scale`` is a two value tuple which controls the min and max temperature (in celsius) to scale the ``ir`` image. By default it's equal to the image ``ir`` min and ``ir`` max. @@ -300,10 +300,10 @@ Functions (w, h, ir) as the ``ir`` array instead to use `draw_ir` to draw any floating point array with width ``w`` and height ``h``. -.. function:: snapshot([hmirror=False, [vflip=False, [transpose=False, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=128, [color_palette=fir.PALETTE_RAINBOW, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None, [scale=(ir_min, ir_max), [pixformat=fir.PIXFORMAT_RGB565, [copy_to_fb=False, [timeout=-1]]]]]]]]]]]]]]]]) +.. function:: snapshot([hmirror=False, [vflip=False, [transpose=False, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=128, [color_palette=fir.PALETTE_RAINBOW, [alpha_palette=None, [hint=0, [scale=(ir_min, ir_max), [pixformat=image.RGB565, [copy_to_fb=False, [timeout=-1]]]]]]]]]]]]]]) Works like `sensor.snapshot()` and returns an `image` object that is either - `fir.PIXFORMAT_GRAYSCALE` (grayscale) or `fir.PIXFORMAT_RGB565` (color). If ``copy_to_fb`` is False then + `image.GRAYSCALE` (grayscale) or `image.RGB565` (color). If ``copy_to_fb`` is False then the new image is allocated on the MicroPython heap. However, the MicroPython heap is limited and may not have space to store the new image if exhausted. Instead, set ``copy_to_fb`` to True to set the frame buffer to the new image making this function work just like `sensor.snapshot()`. @@ -321,11 +321,13 @@ Functions * vflip=True, hmirror=True, transpose=False -> 180 degree rotation * vflip=False, hmirror=True, transpose=True -> 270 degree rotation - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -339,7 +341,7 @@ Functions 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -354,37 +356,26 @@ Functions * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). ``scale`` is a two value tuple which controls the min and max temperature (in celsius) to scale the ``ir`` image. By default it's equal to the image ``ir`` min and ``ir`` max. ``pixformat`` if specified controls the final image pixel format. - ``copy_to_fb`` may also be another image object if you want to replace that image object's memory - buffer, type, width, and height with new image data. - ``timeout`` if not -1 then how many milliseconds to wait for the new frame. - .. note:: - - Any use of ``copy_to_fb`` invalidates the previous image object it overwrites. Do not use - any references to previous image objects anymore it overwrites. Either for an image object - referencing the frame buffer, frame buffer stack, or an image on the MicroPython heap. - Returns an image object. Constants @@ -417,19 +408,3 @@ Constants .. data:: FIR_LEPTON FIR_LEPTON FIR sensor. - -.. data:: PALETTE_RAINBOW - - Rainbow color palette for `fir.draw_ir()` and `fir.snapshot()`. - -.. data:: PALETTE_IRONBOW - - Ironbow color palette for `fir.draw_ir()` and `fir.snapshot()`. - -.. data:: PIXFORMAT_GRAYSCALE - - GRAYSCALE pixformat for `fir.snapshot()`. - -.. data:: PIXFORMAT_RGB565 - - RGB565 pixformat for `fir.snapshot()`. diff --git a/docs/library/omv.image.rst b/docs/library/omv.image.rst index 07bc9bc6cb7b..a3dc704103c1 100644 --- a/docs/library/omv.image.rst +++ b/docs/library/omv.image.rst @@ -1587,15 +1587,6 @@ or to memory. This class provides fast read/write random access for loading/stor ``pause`` if True causes this method to pause for a previously recorded number of milliseconds by write in-order to match the original frame rate that captured the image data. - ``copy_to_fb`` may also be another image object if you want to replace that image object's memory - buffer, type, width, and height with new image data. - - .. note:: - - Any use of ``copy_to_fb`` invalidates the previous image object it overwrites. Do not use - any references to previous image objects anymore it overwrites. Either for an image object - referencing the frame buffer, frame buffer stack, or an image on the MicroPython heap. - .. method:: seek(offset) Seeks to the image slot number ``offset`` in the ImageIO object. @@ -1624,33 +1615,28 @@ class Image -- Image object The image object is the basic object for machine vision operations. -.. class:: Image(path, [copy_to_fb=False]) +.. class:: Image(path, [buffer=None, [copy_to_fb=False]]) Creates a new image object from a file at ``path``. Alternatively, you may - pass a width, height, and either `sensor.BINARY`, `sensor.GRAYSCALE`, or - `sensor.RGB565` to create new blank image object (initialized to 0 - black). + pass a `width`, `height`, and either they any image format value like ``image.GRAYSCALE`` + to create new blank image object (initialized to 0 - black). - Supports bmp/pgm/ppm/jpg/jpeg image files. + Supports bmp/pgm/ppm/jpg/jpeg/png image files. ``copy_to_fb`` if True the image is loaded directly into the frame buffer allowing you to load up large images. If False, the image is loaded into MicroPython's heap which is much smaller than the frame buffer. - You may also set ``copy_to_fb`` equal to another image object and that - buffer will then be overwritten with the copied image changing the passed - image object's pixel format and resolution. - - .. note:: - - If ``copy_to_fb`` is set to True or another image object do not continue - using the old image object passed to this method or the frame buffer - image object. Use the new returned image object reference from this - method as the old references are now stale. + ``buffer`` can be set to the any buffer object to use that as the data source + for the image. For example, if you'd like to create a JPEG image from a JPEG + ``bytes()`` or ``bytearray()`` object you can pass the ``width``, ``height``, + ``image.JPEG`` for the JPEG along with setting ``buffer`` to the JPEG byte stream + to create a JPEG image. Finally, note that images are buffer objects themselves. Images support "[]" notation. Do ``image[index] = 8/16-bit value`` to assign an image pixel or ``image[index]`` to get an image pixel which will be - either an 8-bit value for grayscale images of a 16-bit RGB565 value for RGB - images. + either an 8-bit value for grayscale/bayer images of a 16-bit value for RGB565/YUV + images. Binary images return a 1-bit value. For JPEG images the "[]" allows you to access the compressed JPEG image blob as a byte-array. Reading and writing to the data array is opaque however as @@ -1671,8 +1657,8 @@ The image object is the basic object for machine vision operations. .. method:: format() - Returns `sensor.GRAYSCALE` for grayscale images, `sensor.RGB565` for RGB565 - images, `sensor.BAYER` for bayer pattern images, and `sensor.JPEG` for JPEG + Returns `image.GRAYSCALE` for grayscale images, `image.RGB565` for RGB565 + images, `image.BAYER` for bayer pattern images, and `image.JPEG` for JPEG images. .. method:: size() @@ -1780,7 +1766,7 @@ The image object is the basic object for machine vision operations. Not supported on compressed images or bayer images. - .. method:: to_bitmap([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None, [copy=False]]]]]]]]]]]) + .. method:: to_bitmap([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [copy=False]]]]]]]]]) Converts an image to a bitmap image (1 bit per pixel). If ``copy`` is False this method will try to modify the image in-place. If ``copy`` is True then @@ -1791,11 +1777,13 @@ The image object is the basic object for machine vision operations. the previous image objects storage space. After doing this do not use any references to the old image object anymore as they will be stale. - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -1809,7 +1797,7 @@ The image object is the basic object for machine vision operations. 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -1824,20 +1812,18 @@ The image object is the basic object for machine vision operations. * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). .. note:: @@ -1854,7 +1840,7 @@ The image object is the basic object for machine vision operations. Returns the image object so you can call another method using ``.`` notation. - .. method:: to_grayscale([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None, [copy=False]]]]]]]]]]]) + .. method:: to_grayscale([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [copy=False]]]]]]]]]) Converts an image to a grayscale image (8-bits per pixel). If ``copy`` is False this method will try to modify the image in-place. If ``copy`` is True then @@ -1865,11 +1851,13 @@ The image object is the basic object for machine vision operations. the previous image objects storage space. After doing this do not use any references to the old image object anymore as they will be stale. - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -1883,7 +1871,7 @@ The image object is the basic object for machine vision operations. 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -1898,24 +1886,22 @@ The image object is the basic object for machine vision operations. * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). Returns the image object so you can call another method using ``.`` notation. - .. method:: to_rgb565([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None, [copy=False]]]]]]]]]]]) + .. method:: to_rgb565([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [copy=False]]]]]]]]]) Converts an image to an RGB565 image (16-bits per pixel). If ``copy`` is False this method will try to modify the image in-place. If ``copy`` is True then @@ -1926,11 +1912,13 @@ The image object is the basic object for machine vision operations. the previous image objects storage space. After doing this do not use any references to the old image object anymore as they will be stale. - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -1944,7 +1932,7 @@ The image object is the basic object for machine vision operations. 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -1959,24 +1947,22 @@ The image object is the basic object for machine vision operations. * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). Returns the image object so you can call another method using ``.`` notation. - .. method:: to_rainbow([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=sensor.PALETTE_RAINBOW, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None, [copy=False]]]]]]]]]]]) + .. method:: to_rainbow([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=image.PALETTE_RAINBOW, [alpha_palette=None, [hint=0, [copy=False]]]]]]]]]) Converts an image to an RGB565 rainbow image (16-bits per pixel). If ``copy`` is False this method will try to modify the image in-place. If ``copy`` is True then @@ -1987,11 +1973,13 @@ The image object is the basic object for machine vision operations. the previous image objects storage space. After doing this do not use any references to the old image object anymore as they will be stale. - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -2005,7 +1993,7 @@ The image object is the basic object for machine vision operations. 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -2020,24 +2008,22 @@ The image object is the basic object for machine vision operations. * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). Returns the image object so you can call another method using ``.`` notation. - .. method:: to_ironbow([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=sensor.PALETTE_IRONBOW, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None, [copy=False]]]]]]]]]]]) + .. method:: to_ironbow([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=image.PALETTE_IRONBOW, [alpha_palette=None, [hint=0, [copy=False]]]]]]]]]) Converts an image to an RGB565 ironbow image (16-bits per pixel). If ``copy`` is False this method will try to modify the image in-place. If ``copy`` is True then @@ -2048,11 +2034,13 @@ The image object is the basic object for machine vision operations. the previous image objects storage space. After doing this do not use any references to the old image object anymore as they will be stale. - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -2066,7 +2054,7 @@ The image object is the basic object for machine vision operations. 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -2081,24 +2069,22 @@ The image object is the basic object for machine vision operations. * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). Returns the image object so you can call another method using ``.`` notation. - .. method:: to_jpeg([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None, [copy=False]]]]]]]]]]]) + .. method:: to_jpeg([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [copy=False]]]]]]]]]) Converts an image to a JPEG image. If ``copy`` is False this method will try to modify the image in-place. If ``copy`` is True then @@ -2109,11 +2095,13 @@ The image object is the basic object for machine vision operations. the previous image objects storage space. After doing this do not use any references to the old image object anymore as they will be stale. - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -2127,7 +2115,7 @@ The image object is the basic object for machine vision operations. 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -2142,24 +2130,22 @@ The image object is the basic object for machine vision operations. * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). Returns the image object so you can call another method using ``.`` notation. - .. method:: to_png([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None, [copy=False]]]]]]]]]]]) + .. method:: to_png([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [copy=False]]]]]]]]]) Converts an image to a PNG image. If ``copy`` is False this method will try to modify the image in-place. If ``copy`` is True then @@ -2170,11 +2156,13 @@ The image object is the basic object for machine vision operations. the previous image objects storage space. After doing this do not use any references to the old image object anymore as they will be stale. - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -2188,7 +2176,7 @@ The image object is the basic object for machine vision operations. 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -2203,20 +2191,18 @@ The image object is the basic object for machine vision operations. * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). Returns the image object so you can call another method using ``.`` notation. @@ -2314,18 +2300,20 @@ The image object is the basic object for machine vision operations. Only works on JPEG images. - .. method:: copy([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None, [copy_to_fb=False]]]]]]]]]]]) + .. method:: copy([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [copy_to_fb=False]]]]]]]]]) Creates a deep copy of the image object. If ``copy_to_fb`` is False then the new image is allocated on the MicroPython heap. However, the MicroPython heap is limited and may not have space to store the new image if exhausted. Instead, set ``copy_to_fb`` to True to set the frame buffer to the new image making this function work just like `sensor.snapshot()`. - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -2339,7 +2327,7 @@ The image object is the basic object for machine vision operations. 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -2354,35 +2342,24 @@ The image object is the basic object for machine vision operations. * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. - - ``copy_to_fb`` may also be another image object if you want to replace that image object's memory - buffer, type, width, and height with new image data. - - .. note:: - - Any use of ``copy_to_fb`` invalidates the previous image object it overwrites. Do not use - any references to previous image objects anymore it overwrites. Either for an image object - referencing the frame buffer, frame buffer stack, or an image on the MicroPython heap. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). Returns the new image object. Not supported on compressed images. - .. method:: crop([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None, [copy=False]]]]]]]]]]]) + .. method:: crop([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [copy=False]]]]]]]]]) Modifies an image in-place without changing the underlying image type. If ``copy`` is False this method will try to modify the image in-place. If ``copy`` is True then @@ -2393,11 +2370,13 @@ The image object is the basic object for machine vision operations. the previous image objects storage space. After doing this do not use any references to the old image object anymore as they will be stale. - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -2411,7 +2390,7 @@ The image object is the basic object for machine vision operations. 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -2426,26 +2405,24 @@ The image object is the basic object for machine vision operations. * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). Returns the image object so you can call another method using ``.`` notation. Not supported on compressed images. - .. method:: scale([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None, [copy=False]]]]]]]]]]]) + .. method:: scale([x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [copy=False]]]]]]]]]) Modifies an image in-place without changing the underlying image type. If ``copy`` is False this method will try to modify the image in-place. If ``copy`` is True then @@ -2456,11 +2433,13 @@ The image object is the basic object for machine vision operations. the previous image objects storage space. After doing this do not use any references to the old image object anymore as they will be stale. - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -2474,7 +2453,7 @@ The image object is the basic object for machine vision operations. 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -2489,20 +2468,18 @@ The image object is the basic object for machine vision operations. * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). Returns the image object so you can call another method using ``.`` notation. @@ -2701,17 +2678,22 @@ The image object is the basic object for machine vision operations. Not supported on compressed images or bayer images. - .. method:: draw_image(image, x, y, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None]]]]]]]]]]) + .. method:: draw_image(image, x, y, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0]]]]]]]]) Draws an ``image`` whose top-left corner starts at location x, y. You may either pass x, y separately or as a tuple (x, y). This method automatically handles rendering the image passed into the correct pixel format for the destination image while also handling clipping seamlessly. - ``x_scale`` controls how much the drawn image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + You may also pass a path instead of an image object for this method to automatically load the image + from disk and draw it in one step. E.g. ``draw_image("test.jpg")``. + + ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. - ``y_scale`` controls how much the drawn image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the source image to draw. This allows you to extract just the pixels in the ROI to scale and draw on the destination image. @@ -2725,7 +2707,7 @@ The image object is the basic object for machine vision operations. 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination image. 0 results in no modification to the destination image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -2740,20 +2722,19 @@ The image object is the basic object for machine vision operations. * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being draw on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - * `image.BLACK_BACKGROUND`: Assume the destination image is black. This speeds up drawing. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to draw - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to draw - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). + * `image.BLACK_BACKGROUND`: Assume the background image being drawn on is black speeding up blending. Returns the image object so you can call another method using ``.`` notation. @@ -4561,6 +4542,14 @@ Constants A PNG image. +.. data:: PALETTE_RAINBOW + + Default OpenMV Cam color palette for thermal images using a smooth color wheel. + +.. data:: PALETTE_IRONBOW + + Makes images look like the FLIR Lepton thermal images using a very non-linear color palette. + .. data:: AREA Use area scaling when downscaling an image (Nearest Neighbor is used for upscaling). @@ -4583,9 +4572,22 @@ Constants When downscaling an image this method will subsample the input image to produce the downscaled image. Use `image.AREA` for the higest quality downscaling if speed is not an issue. +.. data:: VFLIP + + Vertically flip the image being drawn by `draw_image`. + +.. data:: HMIRROR + + Horizontally mirror the image being drawn by `draw_image`. + +.. data:: TRANSPOSE + + Transpose (swap x/y) the image being draw by `draw_image`. + .. data:: CENTER - Anchor the image being drawn with `draw_image` in the center versus the top left hand corner. + Center the image being drawn to the center of the image/canvas it's being drawn on. Any x/y + offsets passed will move the image being drawn from the center by that amount. .. data:: EXTRACT_RGB_CHANNEL_FIRST @@ -4597,6 +4599,37 @@ Constants When applying a color lookup table to an image using `draw_image` apply the color look table first before scaling versus afterwards to prevent any artifacts. +.. data:: SCALE_ASPECT_KEEP + + Scale the image being drawn to fit inside of the image/canvas being drawn on while maintaining + the aspect ratio. Unless the image aspect ratios match the image being drawn will not completley + cover the image/canvas being drawn on. Any x_scale/y_scale values passed will additionally scale + the scaled image. + +.. data:: SCALE_ASPECT_EXPAND + + Scale the image being drawn to fill image/canvas being drawn on while maintaining + the aspect ratio. Unless the image aspect ratios match the image being drawn will be cropped. + Any x_scale/y_scale values passed will additionally scale the scaled image. + +.. data:: SCALE_ASPECT_IGNORE + + Scale the image being drawn to fill the image/canvas being drawn on. This does not maintain + the aspect ratio of the image being drawn. Any x_scale/y_scale values passed will additionally + scale the scaled image. + +.. data:: ROTATE_90 + + Rotate the image by 90 degrees (this is just `image.VFLIP` ORed with `image.TRANSPOSE`). + +.. data:: ROTATE_180 + + Rotate the image by 180 degrees (this is just `image.HMIRROR` ORed with `image.VFLIP`). + +.. data:: ROTATE_270 + + Rotate the image by 270 degrees (this is just `image.HMIRROR` ORed with `image.TRANSPOSE`). + .. data:: BLACK_BACKGROUND Speeds up `draw_image` when drawing on a black destination image when using alpha effects that diff --git a/docs/library/omv.mjpeg.rst b/docs/library/omv.mjpeg.rst index d04fc529d80f..0a80ef5807e3 100644 --- a/docs/library/omv.mjpeg.rst +++ b/docs/library/omv.mjpeg.rst @@ -92,7 +92,7 @@ Constructors 256 draws an opaque source image while a value lower than 256 produces a blend between the source and destination (which is a black background in this case). 0 results in a black image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the source image is. This is applied after ``rgb_channel`` extraction if used. @@ -107,8 +107,18 @@ Constructors * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). ``quality`` is the compression quality (0-100) (int) to be used for non-JPEG images. diff --git a/docs/library/omv.sensor.rst b/docs/library/omv.sensor.rst index cf40476d488b..a7fb190f471a 100644 --- a/docs/library/omv.sensor.rst +++ b/docs/library/omv.sensor.rst @@ -526,6 +526,8 @@ Functions * `sensor.IOCTL_GET_READOUT_WINDOW` - Pass this enum for `sensor.ioctl` to return the current readout window rect tuple (x, y, w, h). By default this is (0, 0, maximum_camera_sensor_pixel_width, maximum_camera_sensor_pixel_height). * `sensor.IOCTL_SET_TRIGGERED_MODE` - Pass this enum followed by True or False set triggered mode for the MT9V034 sensor. * `sensor.IOCTL_GET_TRIGGERED_MODE` - Pass this enum for `sensor.ioctl` to return the current triggered mode state. + * `sensor.IOCTL_SET_FOV_WIDE` - Pass this enum followed by True or False enable `sensor.set_framesize()` to optimize for the field-of-view over FPS. + * `sensor.IOCTL_GET_FOV_WIDE` - Pass this enum for `sensor.ioctl` to return the current field-of-view over fps optimization state. * `sensor.IOCTL_TRIGGER_AUTO_FOCUS` - Pass this enum for `sensor.ioctl` to trigger auto focus on the OV5640 FPC camera module. * `sensor.IOCTL_PAUSE_AUTO_FOCUS` - Pass this enum for `sensor.ioctl` to pause auto focus (after triggering) on the OV5640 FPC camera module. * `sensor.IOCTL_RESET_AUTO_FOCUS` - Pass this enum for `sensor.ioctl` to reset auto focus (after triggering) on the OV5640 FPC camera module. @@ -564,7 +566,7 @@ Functions .. function:: get_color_palette() - Returns the current color palette setting. Defaults to `sensor.PALETTE_RAINBOW`. + Returns the current color palette setting. Defaults to `image.PALETTE_RAINBOW`. .. function:: __write_reg(address, value) @@ -847,14 +849,6 @@ Constants 2592x1944 resolution for the camera sensor. Only works for the OV5640 camera. -.. data:: PALETTE_RAINBOW - - Default OpenMV Cam color palette for thermal images using a smooth color wheel. - -.. data:: PALETTE_IRONBOW - - Makes images look like the FLIR Lepton thermal images using a very non-linear color palette. - .. data:: IOCTL_SET_READOUT_WINDOW Lets you set the readout window for the OV5640. @@ -871,6 +865,14 @@ Constants Lets you get the triggered mode for the MT9V034. +.. data:: IOCTL_SET_FOV_WIDE + + Enable `sensor.set_framesize()` to optimize for the field-of-view over FPS. + +.. data:: IOCTL_GET_FOV_WIDE + + Return if `sensor.set_framesize()` is optimizing for field-of-view over FPS. + .. data:: IOCTL_TRIGGER_AUTO_FOCUS Used to trigger auto focus for the OV5640 FPC camera module. diff --git a/docs/library/omv.tv.rst b/docs/library/omv.tv.rst index e6849b611876..60f8d11de49a 100644 --- a/docs/library/omv.tv.rst +++ b/docs/library/omv.tv.rst @@ -65,16 +65,17 @@ Functions For the wireless TV shield this sets the broadcast channel between 1-8. If passed without a channel argument then this method returns the previously set channel (1-8). Default is channel 8. -.. function:: display(image, [x=0, [y=0, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0, [x_size=None, [y_size=None]]]]]]]]]]]]) +.. function:: display(image, [x=0, [y=0, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None, [hint=0]]]]]]]]]]) - Displays an ``image`` whose top-left corner starts at location x, y. You may either pass x, y - separately, as a tuple (x, y), or neither. + Displays an ``image`` whose top-left corner starts at location x, y. ``x_scale`` controls how much the displayed image is scaled by in the x direction (float). If this - value is negative the image will be flipped horizontally. + value is negative the image will be flipped horizontally. Note that if ``y_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``y_scale`` controls how much the displayed image is scaled by in the y direction (float). If this - value is negative the image will be flipped vertically. + value is negative the image will be flipped vertically. Note that if ``x_scale`` is not specified + then it will match ``x_scale`` to maintain the aspect ratio. ``roi`` is the region-of-interest rectangle tuple (x, y, w, h) of the image to display. This allows you to extract just the pixels in the ROI to scale. @@ -86,7 +87,7 @@ Functions ``alpha`` controls how opaque the image is. A value of 256 displays an opaque image while a value lower than 256 produces a black transparent image. 0 results in a perfectly black image. - ``color_palette`` if not ``-1`` can be `sensor.PALETTE_RAINBOW`, `sensor.PALETTE_IRONBOW`, or + ``color_palette`` if not ``-1`` can be `image.PALETTE_RAINBOW`, `image.PALETTE_IRONBOW`, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the input image is. This is applied after ``rgb_channel`` extraction if used. @@ -101,19 +102,18 @@ Functions * `image.AREA`: Use area scaling when downscaling versus the default of nearest neighbor. * `image.BILINEAR`: Use bilinear scaling versus the default of nearest neighbor scaling. * `image.BICUBIC`: Use bicubic scaling versus the default of nearest neighbor scaling. - * `image.CENTER`: Center the image image being displayed on (x, y). + * `image.CENTER`: Center the image being drawn on the display. This is applied after scaling. + * `image.HMIRROR`: Horizontally mirror the image. + * `image.VFLIP`: Vertically flip the image. + * `image.TRANSPOSE`: Transpose the image (swap x/y). * `image.EXTRACT_RGB_CHANNEL_FIRST`: Do rgb_channel extraction before scaling. * `image.APPLY_COLOR_PALETTE_FIRST`: Apply color palette before scaling. - - ``x_size`` may be passed if ``x_scale`` is not passed to specify the size of the image to display - and ``x_scale`` will automatically be determined passed on the input image size. If neither - ``y_scale`` or ``y_size`` are specified then ``y_scale`` internally will be set to be equal to - ``x_size`` to maintain the aspect-ratio. - - ``y_size`` may be passed if ``y_scale`` is not passed to specify the size of the image to display - and ``y_scale`` will automatically be determined passed on the input image size. If neither - ``x_scale`` or ``x_size`` are specified then ``x_scale`` internally will be set to be equal to - ``y_size`` to maintain the aspect-ratio. + * `image.SCALE_ASPECT_KEEP`: Scale the image being drawn to fit inside the display. + * `image.SCALE_ASPECT_EXPAND`: Scale the image being drawn to fill the display (results in cropping) + * `image.SCALE_ASPECT_IGNORE`: Scale the image being drawn to fill the display (results in stretching). + * `image.ROTATE_90`: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE). + * `image.ROTATE_180`: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP). + * `image.ROTATE_270`: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE). Constants --------- diff --git a/docs/openmvcam/pinout-openmv-cam-rt1062-ov5640.png b/docs/openmvcam/pinout-openmv-cam-rt1062-ov5640.png new file mode 100644 index 000000000000..b4c31de515b6 Binary files /dev/null and b/docs/openmvcam/pinout-openmv-cam-rt1062-ov5640.png differ diff --git a/docs/openmvcam/quickref.rst b/docs/openmvcam/quickref.rst index 159a840c42b7..c0db8a8fa9ad 100644 --- a/docs/openmvcam/quickref.rst +++ b/docs/openmvcam/quickref.rst @@ -12,6 +12,10 @@ the OpenMV Cam please consider reading the following sections first: general.rst tutorial/index.rst +.. image:: pinout-openmv-cam-rt1062-ov5640.png + :alt: OpenMV Cam RT1062 OV5640 Pinout + :width: 700px + .. image:: pinout-openmv-cam-h7-plus-ov5640.png :alt: OpenMV Cam H7 Plus OV5640 Pinout :width: 700px @@ -32,19 +36,274 @@ the OpenMV Cam please consider reading the following sections first: :alt: OpenMV Cam M4 OV2640 Pinout :width: 700px -General board control ---------------------- +General OpenMV Cams Board Control +--------------------------------- + +All OpenMV Cams can use the `machine` module to control the camera hardware. Please refer to the +pinout image for which SPI/I2C/UART/CAN/PWM/TIMER channels are avialable on what I/O pins. + +Delay and timing +^^^^^^^^^^^^^^^^ + +Use the :mod:`time