李昂 b463e812bf !42 Support PikaCV, can read data from Jpeg and convert to rgb888/rgb565
* add pikaCV-test.cpp
* read(Image) and convert to RGB565 is tested ok
* transfer can return res, but not assert
* format tjpgd
* add test for PikaCV
* add assert for newContent
* restore assets
* restore PikaCV.pyi
* restore PikaCV
* restore uint16_t
* add jpeg_test.py
* move ADC, GPIO, RGB ... to Device
* add jd_decomp
* convert_JPEGtoREG888 is not ok
* connecting tjpegdec
* Converter.toRGB565() .toRGB888() .toGRay() eachother is ok
* support Gray
* add PikaCV_Image, PikaCV_ImageFormat
* add classes for PikaCV
* add PikaCV
2022-07-08 09:33:53 +00:00

84 lines
2.4 KiB
Python

from PikaObj import *
class ImageFormat(TinyObj):
"""The ImageFormat class is used to
store the image format enum of an image."""
RGB888: int
RGB565: int
GRAY: int
JPEG: int
def __init__(self): ...
class Image(TinyObj):
"""Create a empty image. The image can be
filled with data by read a file e.g.: `read()`
or load bytes e.g:. `loadRGB888`, `loadRGB565`, `loadGray` or `loadJpeg`"""
def __init__(self): ...
def read(self, path: str):
"""Read the image from the specified path, Need implement the `__platform_fopen()`, `__platform_fread()` and `__platform_fclose()`"""
...
def loadJpeg(self, bytes: any):
"""Load the image from bytes"""
def loadRGB888(self, width: int, height: int, bytes: bytes):
"""Load the image from bytes"""
def loadRGB565(self, width: int, hight: int, bytes: bytes):
"""Load the image from bytes"""
def loadGray(self, width: int, hight: int, bytes: bytes):
"""Load the image from bytes"""
def width(self) -> int:
"""Get the width of the image"""
def hight(self) -> int:
"""Get the hight of the image"""
def format(self) -> int:
"""Get the format of the image.
The format is one of the `ImageFormat` enum,
like `ImageFormat.RGB888`"""
def data(self) -> bytes:
"""Get the data of the image"""
def getPixel(self, x: int, y: int, channel: int) -> int:
"""Get the pixel value of the specified channel.
For example, if the format of image is `RGB888`,
the channel `0`, `1`, `2`, means `R`, `G`, `B`,
and for the format of `GRAY8`, the channel is `0`
"""
def setPixel(self, x: int, y: int, channel: int, value: int):
"""Set the pixel value of the specified channel.
For example, if the format of image is `RGB888`,
the channel `0`, `1`, `2`, means `R`, `G`, `B`,
and for the format of `GRAY8`, the channel is `0`
"""
def size(self) -> int:
"""Get the size of the image by bytes"""
class Converter(TinyObj):
"""The Converter class is used to
convert an image from one format to another."""
@staticmethod
def toRGB888(image: Image):
"""Convert the image to RGB888"""
@staticmethod
def toRGB565(image: Image):
"""Convert the image to RGB565"""
@staticmethod
def toGray(image: Image):
"""Convert the image to Gray"""