From 9bfa0c3519ba069b7d02a0e7aca0f80d1df8fe60 Mon Sep 17 00:00:00 2001 From: lxowalle Date: Fri, 12 Apr 2024 19:19:21 +0800 Subject: [PATCH] =?UTF-8?q?*=20Compatible=20with=20maixpy=20=E2=80=8B?= =?UTF-8?q?=E2=80=8Bv1=20sensor=20and=20lcd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/maixpy_v1/test_image.py | 18 + examples/maixpy_v1/test_lcd.py | 15 + examples/maixpy_v1/test_sensor.py | 20 + maix/v1/__init__.py | 3 +- maix/v1/audio.py | 15 + maix/v1/image.py | 835 +++++++++++++++++++++++++++++- maix/v1/lcd.py | 34 +- maix/v1/sensor.py | 161 +++++- maix/v1/video.py | 16 + 9 files changed, 1085 insertions(+), 32 deletions(-) create mode 100644 examples/maixpy_v1/test_image.py create mode 100644 examples/maixpy_v1/test_lcd.py create mode 100644 examples/maixpy_v1/test_sensor.py create mode 100644 maix/v1/audio.py diff --git a/examples/maixpy_v1/test_image.py b/examples/maixpy_v1/test_image.py new file mode 100644 index 00000000..4c72e628 --- /dev/null +++ b/examples/maixpy_v1/test_image.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +from maix.v1 import lcd, image +from maix import time + +lcd.init() +print('lcd width:', lcd.width()) +print('lcd height:', lcd.height()) + +img = image.Image("test.jpg") +print('img width:', img.width()) +print('img height:', img.height()) +print('img format:', img.format()) +print('img data size:', img.size()) +lcd.display(img) + +while True: + time.sleep(1) diff --git a/examples/maixpy_v1/test_lcd.py b/examples/maixpy_v1/test_lcd.py new file mode 100644 index 00000000..9f12f017 --- /dev/null +++ b/examples/maixpy_v1/test_lcd.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +from maix.v1 import lcd, image +from maix import time + +img = image.Image("test.jpg") + +lcd.init() +lcd.display(img) +# lcd.clear() +print('lcd width:', lcd.width()) +print('lcd height:', lcd.height()) + +while True: + time.sleep(1) diff --git a/examples/maixpy_v1/test_sensor.py b/examples/maixpy_v1/test_sensor.py new file mode 100644 index 00000000..f40fd3da --- /dev/null +++ b/examples/maixpy_v1/test_sensor.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +from maix.v1 import lcd, sensor +from maix import time + +lcd.init() +sensor.reset() +# sensor.set_pixformat(sensor.RGB565) +sensor.set_framesize(sensor.VGA) +sensor.run(1) +sensor.skip_frames(1) +# sensor.set_colorbar(1) + +print('sensor width:', sensor.width()) +print('sensor height:', sensor.height()) + +while True: + img = sensor.snapshot() + lcd.display(img) + time.sleep_ms(30) diff --git a/maix/v1/__init__.py b/maix/v1/__init__.py index df32d57c..0704e6e7 100644 --- a/maix/v1/__init__.py +++ b/maix/v1/__init__.py @@ -1,2 +1 @@ - -__all__ = ["image", "machine", "lcd", "sensor", "video"] +__all__ = ["image", "machine", "lcd", "sensor", "video", "audio"] diff --git a/maix/v1/audio.py b/maix/v1/audio.py new file mode 100644 index 00000000..17ef3552 --- /dev/null +++ b/maix/v1/audio.py @@ -0,0 +1,15 @@ +class Audio(): + def __init__(array=None, path=None, points=1024): + pass + + def to_bytes(): + pass + + def play_process(): + pass + + def play(): + pass + + def finish(): + pass diff --git a/maix/v1/image.py b/maix/v1/image.py index 4f79ed58..e68c2698 100644 --- a/maix/v1/image.py +++ b/maix/v1/image.py @@ -1,7 +1,838 @@ +from maix import image +SEARCH_EX = 0 +SEARCH_DS = 1 -class Image: +EDGE_CANNY = 0 +EDGE_SIMPLE = 1 + +CORNER_FAST = 0 +CORNER_AGAST = 1 + +TAG16H5 = 0 +TAG25H7 = 1 +TAG25H9 = 2 +TAG36H10 = 3 +TAG36H11 = 4 +ARTOOLKIT = 5 +EAN2 = 0 +EAN5 = 1 +EAN8 = 2 +UPCE = 3 +ISBN10 = 4 +UPCA = 5 +EAN13 = 6 +ISBN13 = 7 +I25 = 8 +DATABAR = 9 +DATABAR_EXP = 10 +CODABAR = 11 +CODE39 = 12 +PDF417 = 13 +CODE93 = 14 +CODE128 = 15 + +class Histogram: + def __init__(self): + raise ValueError('This operation is not supported') + + def bins(self): + raise ValueError('This operation is not supported') + + def l_bins(self): + raise ValueError('This operation is not supported') + + def a_bins(self): + raise ValueError('This operation is not supported') + + def b_bins(self): + raise ValueError('This operation is not supported') + + def get_percentile(self, percentile): + raise ValueError('This operation is not supported') + + def get_threhsold(self): + raise ValueError('This operation is not supported') + + def get_statistics(self): + raise ValueError('This operation is not supported') + +class Statistics: + def __init__(self): + raise ValueError('This operation is not supported') + + def mean(self): + raise ValueError('This operation is not supported') + + def median(self): + raise ValueError('This operation is not supported') + + def mode(self): + raise ValueError('This operation is not supported') + + def stdev(self): + raise ValueError('This operation is not supported') + + def min(self): + raise ValueError('This operation is not supported') + + def max(self): + raise ValueError('This operation is not supported') + + def lq(self): + raise ValueError('This operation is not supported') + + def uq(self): + raise ValueError('This operation is not supported') + + def l_mean(self): + raise ValueError('This operation is not supported') + + def l_median(self): + raise ValueError('This operation is not supported') + + def l_mode(self): + raise ValueError('This operation is not supported') + + def l_stdev(self): + raise ValueError('This operation is not supported') + + def l_min(self): + raise ValueError('This operation is not supported') + + def l_max(self): + raise ValueError('This operation is not supported') + + def l_lq(self): + raise ValueError('This operation is not supported') + + def l_uq(self): + raise ValueError('This operation is not supported') + + def a_mean(self): + raise ValueError('This operation is not supported') + + def a_median(self): + raise ValueError('This operation is not supported') + + def a_mode(self): + raise ValueError('This operation is not supported') + + def a_stdev(self): + raise ValueError('This operation is not supported') + + def a_min(self): + raise ValueError('This operation is not supported') + + def a_max(self): + raise ValueError('This operation is not supported') + + def a_lq(self): + raise ValueError('This operation is not supported') + + def a_uq(self): + raise ValueError('This operation is not supported') + + def b_mean(self): + raise ValueError('This operation is not supported') + + def b_median(self): + raise ValueError('This operation is not supported') + + def b_mode(self): + raise ValueError('This operation is not supported') + + def b_stdev(self): + raise ValueError('This operation is not supported') + + def b_min(self): + raise ValueError('This operation is not supported') + + def b_max(self): + raise ValueError('This operation is not supported') + + def b_lq(self): + raise ValueError('This operation is not supported') + + def b_uq(self): + raise ValueError('This operation is not supported') + +class Blob: def __init__(self): - pass + raise ValueError('This operation is not supported') + + def rect(self): + raise ValueError('This operation is not supported') + + def x(self): + raise ValueError('This operation is not supported') + + def y(self): + raise ValueError('This operation is not supported') + + def w(self): + raise ValueError('This operation is not supported') + + def h(self): + raise ValueError('This operation is not supported') + + def pixels(self): + raise ValueError('This operation is not supported') + + def cx(self): + raise ValueError('This operation is not supported') + + def cy(self): + raise ValueError('This operation is not supported') + + def rotation(self): + raise ValueError('This operation is not supported') + + def code(self): + raise ValueError('This operation is not supported') + + def count(self): + raise ValueError('This operation is not supported') + + def area(self): + raise ValueError('This operation is not supported') + + def density(self): + raise ValueError('This operation is not supported') + +class Line: + def __init__(self): + raise ValueError('This operation is not supported') + + def line(self): + raise ValueError('This operation is not supported') + + def x1(self): + raise ValueError('This operation is not supported') + + def y1(self): + raise ValueError('This operation is not supported') + + def x2(self): + raise ValueError('This operation is not supported') + + def y2(self): + raise ValueError('This operation is not supported') + + def length(self): + raise ValueError('This operation is not supported') + + def magnitude(self): + raise ValueError('This operation is not supported') + + def theta(self): + raise ValueError('This operation is not supported') + + def rho(self): + raise ValueError('This operation is not supported') + + +class Circle: + def __init__(self): + raise ValueError('This operation is not supported') + + def x(self): + raise ValueError('This operation is not supported') + + def y(self): + raise ValueError('This operation is not supported') + + def r(self): + raise ValueError('This operation is not supported') + + def magnitude(self): + raise ValueError('This operation is not supported') + + +class Rect: + def __init__(self): + raise ValueError('This operation is not supported') + + def corners(self): + raise ValueError('This operation is not supported') + + def rect(self): + raise ValueError('This operation is not supported') + + def x(self): + raise ValueError('This operation is not supported') + + def y(self): + raise ValueError('This operation is not supported') + + def w(self): + raise ValueError('This operation is not supported') + + def h(self): + raise ValueError('This operation is not supported') + + def magnitude(self): + raise ValueError('This operation is not supported') + + +class QRCode: + def __init__(self): + raise ValueError('This operation is not supported') + + def corners(self): + raise ValueError('This operation is not supported') + + def rect(self): + raise ValueError('This operation is not supported') + + def x(self): + raise ValueError('This operation is not supported') + + def y(self): + raise ValueError('This operation is not supported') + + def w(self): + raise ValueError('This operation is not supported') + + def h(self): + raise ValueError('This operation is not supported') + + def payload(self): + raise ValueError('This operation is not supported') + + def version(self): + raise ValueError('This operation is not supported') + + def ecc_level(self): + raise ValueError('This operation is not supported') + + def mask(self): + raise ValueError('This operation is not supported') + + def data_type(self): + raise ValueError('This operation is not supported') + + def eci(self): + raise ValueError('This operation is not supported') + + def is_numeric(self): + raise ValueError('This operation is not supported') + + def is_alphanumeric(self): + raise ValueError('This operation is not supported') + + def is_binary(self): + raise ValueError('This operation is not supported') + + def is_kanji(self): + raise ValueError('This operation is not supported') + + +class AprilTag: + def __init__(self): + raise ValueError('This operation is not supported') + + def corners(self): + raise ValueError('This operation is not supported') + + def rect(self): + raise ValueError('This operation is not supported') + + def x(self): + raise ValueError('This operation is not supported') + + def y(self): + raise ValueError('This operation is not supported') + + def w(self): + raise ValueError('This operation is not supported') + + def h(self): + raise ValueError('This operation is not supported') + + def id(self): + raise ValueError('This operation is not supported') + + def family(self): + raise ValueError('This operation is not supported') + + def cx(self): + raise ValueError('This operation is not supported') + + def cy(self): + raise ValueError('This operation is not supported') + + def rotation(self): + raise ValueError('This operation is not supported') + + def decision_margin(self): + raise ValueError('This operation is not supported') + + def hamming(self): + raise ValueError('This operation is not supported') + + def goodness(self): + raise ValueError('This operation is not supported') + + def x_translation(self): + raise ValueError('This operation is not supported') + + def y_translation(self): + raise ValueError('This operation is not supported') + + def z_translation(self): + raise ValueError('This operation is not supported') + + def x_rotation(self): + raise ValueError('This operation is not supported') + + def y_rotation(self): + raise ValueError('This operation is not supported') + + def z_rotation(self): + raise ValueError('This operation is not supported') + +class DataMatrix: + def __init__(self): + raise ValueError('This operation is not supported') + + def corners(self): + raise ValueError('This operation is not supported') + + def rect(self): + raise ValueError('This operation is not supported') + + def x(self): + raise ValueError('This operation is not supported') + + def y(self): + raise ValueError('This operation is not supported') + + def w(self): + raise ValueError('This operation is not supported') + + def h(self): + raise ValueError('This operation is not supported') + + def payload(self): + raise ValueError('This operation is not supported') + + def rotation(self): + raise ValueError('This operation is not supported') + + def rows(self): + raise ValueError('This operation is not supported') + + def columns(self): + raise ValueError('This operation is not supported') + + def capacity(self): + raise ValueError('This operation is not supported') + + def padding(self): + raise ValueError('This operation is not supported') + +class BarCode: + def __init__(self): + raise ValueError('This operation is not supported') + + def corners(self): + raise ValueError('This operation is not supported') + + def rect(self): + raise ValueError('This operation is not supported') + + def x(self): + raise ValueError('This operation is not supported') + + def y(self): + raise ValueError('This operation is not supported') + + def w(self): + raise ValueError('This operation is not supported') + + def h(self): + raise ValueError('This operation is not supported') + + def payload(self): + raise ValueError('This operation is not supported') + + def type(self): + raise ValueError('This operation is not supported') + + def rotation(self): + raise ValueError('This operation is not supported') + + def quality(self): + raise ValueError('This operation is not supported') + +class Displacement: + def __init__(self): + raise ValueError('This operation is not supported') + + def x_translation(self): + raise ValueError('This operation is not supported') + + def y_translation(self): + raise ValueError('This operation is not supported') + + def rotation(self): + raise ValueError('This operation is not supported') + + def scale(self): + raise ValueError('This operation is not supported') + + def response(self): + raise ValueError('This operation is not supported') + +class Image: + def __init__(self, path=None, copy_to_fb=False, width=640, height=480, do_nothing = False): + if do_nothing: + self.__img = None + else: + if path is None: + self.__img = image.Image(width, height) + else: + self.__img = image.load(path) + + def get_priv_img(self): + return self.__img + + def set_priv_img(self, new_image): + self.__img = new_image + + def width(self): + return self.__img.width() + + def height(self): + return self.__img.height() + + def format(self): + format_int = 0 + if self.__img.format() == image.Format.FMT_GRAYSCALE: + return 1 + elif self.__img.format() == image.Format.FMT_RGB565: + return 2 + elif self.__img.format() == image.Format.FMT_RGB888: + return 4 + elif self.__img.format() == image.Format.FMT_YVU420SP: + return 5 + else: + raise ValueError('Unknowed format') + + def size(self): + return self.__img.data_size() + + def get_pixel(self, x, y, rgbtuple = False): + return self.__img.get_pixel(x, y, rgbtuple) + + def set_pixel(self, x, y, pixel): + self.__img.set_pixel(x, y, pixel) + + def mean_pool(self, x_div, y_div): + img = self.__img.mean_pool(x_div, y_div, copy = False) + img_v1 = Image(do_nothing=True) + img_v1.set_priv_img(img) + return img_v1 + + def mean_pooled(self, x_div, y_div): + return self.mean_pool(x_div, y_div) + + def midpoint_pool(self, x_div, y_div, bias=0.5): + img = self.__img.midpoint_pool(x_div, y_div, bias, copy = False) + img_v1 = Image(do_nothing=True) + img_v1.set_priv_img(img) + return img_v1 + + def midpoint_pooled(self, x_div, y_div, bias=0.5): + return self.midpoint_pooled(x_div, y_div, bias) + + def to_grayscale(self, copy=False): + img = self.__img.to_format(image.Format.FMT_GRAYSCALE) + if copy: + img_v1 = Image(do_nothing=True) + img_v1.set_priv_img(img) + return img_v1 + else: + self.__img = img + return self + + def to_rgb565(self, copy=False): + raise ValueError('This operation is not supported') + + def to_rainbow(self, copy=False): + raise ValueError('This operation is not supported') + + def compress(self, quality=50): + img = self.__img.compress(quality) + img_v1 = Image(do_nothing=True) + img_v1.set_priv_img(img) + return img_v1 + + def compress_for_ide(self, quality=50): + raise ValueError('This operation is not supported') + + def copy(self, roi=None, copy_to_fb=False): + img = self.__img.copy() + img_v1 = Image(do_nothing=True) + img_v1.set_priv_img(img) + return img_v1 + + def save(self, path, roi=None, quality=50): + img = self.__img.save(path, quality) + img_v1 = Image(do_nothing=True) + img_v1.set_priv_img(img) + return img_v1 + + def clear(self): + self.__img.clear() + + def draw_line(self, x0, y0, x1, y1, color, thickness=1): + img_color = None + if isinstance(color, tuple) or isinstance(color, list) and len(color) > 2: + img_color = image.Color.from_rgb(color[0], color[1], color[2]) + elif isinstance(color, int): + img_color = image.Color.from_rgb(color, color, color) + + self.__img.draw_line(x0, y0, x1, y1, img_color, thickness) + return self + + def draw_rectangle(self, x, y, w, h, color, thickness=1, fill=False): + img_color = None + if isinstance(color, tuple) or isinstance(color, list) and len(color) > 2: + img_color = image.Color.from_rgb(color[0], color[1], color[2]) + elif isinstance(color, int): + img_color = image.Color.from_rgb(color, color, color) + + if fill: + self.__img.draw_rect(x, y, w, h, img_color, -1) + else: + self.__img.draw_rect(x, y, w, h, img_color, thickness) + + def draw_ellipse(self, cx, cy, rx, ry, rotation, color, thickness=1, fill=False): + img_color = None + if isinstance(color, tuple) or isinstance(color, list) and len(color) > 2: + img_color = image.Color.from_rgb(color[0], color[1], color[2]) + elif isinstance(color, int): + img_color = image.Color.from_rgb(color, color, color) + + if fill: + self.__img.draw_ellipse(cx, cy, rx, ry, rotation, 0, 360, img_color, thickness=-1) + else: + self.__img.draw_ellipse(cx, cy, rx, ry, rotation, 0, 360, img_color, thickness=thickness) + + def draw_circle(self, x, y, radius, color, thickness=1, fill=False): + raise ValueError('This operation is not supported') + + def draw_string(self, x, y, text, color, scale=1, x_spacing=0, y_spacing=0, mono_space=True): + raise ValueError('This operation is not supported') + + def draw_cross(self, x, y, color, size=5, thickness=1): + raise ValueError('This operation is not supported') + + def draw_arrow(self, x0, y0, x1, y1, color, thickness=1): + raise ValueError('This operation is not supported') + + def draw_image(self, image, x, y, x_scale=1.0, y_scale=1.0, mask=None, alpha=256): + raise ValueError('This operation is not supported') + + def draw_keypoints(self, keypoints, color, size=10, thickness=1, fill=False): + raise ValueError('This operation is not supported') + + def flood_fill(self, x, y, seed_threshold=0.05, floating_threshold=0.05, color=(255,255,255), invert=False, clear_background=False, mask=None): + raise ValueError('This operation is not supported') + + def binary(self, thresholds, invert=False, zero=False, mask=None): + raise ValueError('This operation is not supported') + + def invert(self): + raise ValueError('This operation is not supported') + + def b_and(self, image, mask=None): + raise ValueError('This operation is not supported') + + def b_nand(self, image, mask=None): + raise ValueError('This operation is not supported') + + def b_or(self, image, mask=None): + raise ValueError('This operation is not supported') + + def b_nor(self, image, mask=None): + raise ValueError('This operation is not supported') + + def b_xor(self, image, mask=None): + raise ValueError('This operation is not supported') + + def b_xnor(self, image, mask=None): + raise ValueError('This operation is not supported') + + def erode(self, size, threshold, mask=None): + raise ValueError('This operation is not supported') + + def dilate(self, size, threshold, mask=None): + raise ValueError('This operation is not supported') + + def open(self, size, threshold, mask=None): + raise ValueError('This operation is not supported') + + def close(self, size, threshold, mask=None): + raise ValueError('This operation is not supported') + + def top_hat(self, size, threshold, mask=None): + raise ValueError('This operation is not supported') + + def black_hat(self, size, threshold, mask=None): + raise ValueError('This operation is not supported') + + def negate(self): + raise ValueError('This operation is not supported') + + def replace(self, image, hmirror=False, vflip=False, mask=None): + raise ValueError('This operation is not supported') + + def add(self, image, mask=None): + raise ValueError('This operation is not supported') + + def sub(self, image, reverse=False, mask=None): + raise ValueError('This operation is not supported') + + def mul(self, image, invert=False, mask=None): + raise ValueError('This operation is not supported') + + def div(self, image, invert=False, mask=None): + raise ValueError('This operation is not supported') + + def min(self, image, mask=None): + raise ValueError('This operation is not supported') + + def max(self, image, mask=None): + raise ValueError('This operation is not supported') + + def difference(self, image, mask=None): + raise ValueError('This operation is not supported') + + def blend(self, image, alpha=128, mask=None): + raise ValueError('This operation is not supported') + + def histeq(self, adaptive=False, clip_limit=-1, mask=None): + raise ValueError('This operation is not supported') + + def mean(self, size, threshold=False, offset=0, invert=False, mask=None): + raise ValueError('This operation is not supported') + + def mode(self, size, threshold=False, offset=0, invert=False, mask=None): + raise ValueError('This operation is not supported') + + def midpoint(self, size, bias=0.5, threshold=False, offset=0, invert=False, mask=None): + raise ValueError('This operation is not supported') + + def morph(self, size, kernel, mul=-1, add=0): + raise ValueError('This operation is not supported') + + def gaussian(self, size, unsharp=False, mul=-1, add=0, threshold=False, offset=0, invert=False, mask=None): + raise ValueError('This operation is not supported') + + def laplacian(self, size, sharpen=False, mul=-1, add=0, threshold=False, offset=0, invert=False, mask=None): + raise ValueError('This operation is not supported') + + def bilateral(self, size, color_sigma=0.1, space_sigma=1, threshold=False, offset=0, invert=False, mask=None): + raise ValueError('This operation is not supported') + + def cartoon(self, size, seed_threshold=0.05, floating_threshold=0.05, mask=None): + raise ValueError('This operation is not supported') + + def remove_shadows(self, image): + raise ValueError('This operation is not supported') + + def chrominvar(self): + raise ValueError('This operation is not supported') + + def illuminvar(self): + raise ValueError('This operation is not supported') + + def linpolar(self, reverse=False): + raise ValueError('This operation is not supported') + + def logpolar(self, reverse=False): + raise ValueError('This operation is not supported') + + def lens_corr(self, strength=1.8, zoom=1.0): + raise ValueError('This operation is not supported') + + def rotation_corr(self, x_rotation=0.0, y_rotation=0.0, z_rotation=0.0, x_translation=0.0, y_translation=0.0, zoom=1.0, fov=60.0, corners=None): + raise ValueError('This operation is not supported') + + def get_similarity(self, image): + raise ValueError('This operation is not supported') + + def get_histogram(self, thresholds, invert=False, roi=None, bins=None, l_bins=None, a_bins=None, b_bins=None): + raise ValueError('This operation is not supported') + + def get_statistics(self, thresholds, invert=False, roi=None, bins=None, l_bins=None, a_bins=None, b_bins=None): + raise ValueError('This operation is not supported') + + def get_regression(self, thresholds, invert=False, roi=None, x_stride=2, y_stride=1, area_threshold=10, pixels_threshold=10, robust=False): + raise ValueError('This operation is not supported') + + def find_blobs(self, thresholds, invert=False, roi=None, x_stride=2, y_stride=1, area_threshold=10, pixels_threshold=10, merge=False, margin=0, threshold_cb=None, merge_cb=None): + raise ValueError('This operation is not supported') + + def find_lines(self, roi=None, x_stride=2, y_stride=1, threshold=1000, theta_margin=25, rho_margin=25): + raise ValueError('This operation is not supported') + + def find_line_segments(self, roi=None, merge_distance=0, max_theta_difference=15): + raise ValueError('This operation is not supported') + + def find_circles(self, roi=None, x_stride=2, y_stride=1, threshold=2000, x_margin=10, y_margin=10, r_margin=10): + raise ValueError('This operation is not supported') + + def find_rects(self, roi=None, threshold=10000): + raise ValueError('This operation is not supported') + + def find_qrcodes(self, roi=None): + raise ValueError('This operation is not supported') + + def find_barcodes(self, roi=None): + raise ValueError('This operation is not supported') + + def find_number(self, roi=None): + raise ValueError('This operation is not supported') + + def classify_object(self, roi=None): + raise ValueError('This operation is not supported') + + def find_features(self, cascade, threshold=0.5, scale=1.5, roi=None): + raise ValueError('This operation is not supported') + + def find_eye(self, roi=None): + raise ValueError('This operation is not supported') + + def find_lbp(self, roi=None): + raise ValueError('This operation is not supported') + + def find_keypoints(self, roi=None, threshold=20, normalized=False, scale_factor=1.5, max_keypoints=100, corner_detector=CORNER_AGAST): + raise ValueError('This operation is not supported') + + def find_edges(self, edge_type, threshold): + raise ValueError('This operation is not supported') + +def rgb_to_lab(rgb_tuple): + raise ValueError('This operation is not supported') + +def lab_to_rgb(lab_tuple): + raise ValueError('This operation is not supported') + +def rgb_to_grayscale(rgb_tuple): + raise ValueError('This operation is not supported') + +def grayscale_to_rgb(g_value): + raise ValueError('This operation is not supported') + +def load_decriptor(path): + raise ValueError('This operation is not supported') +def save_descriptor(path, descriptor): + raise ValueError('This operation is not supported') +def match_descriptor(descritor0, descriptor1, threshold=70, filter_outliers=False): + raise ValueError('This operation is not supported') \ No newline at end of file diff --git a/maix/v1/lcd.py b/maix/v1/lcd.py index b9e12411..e48664ea 100644 --- a/maix/v1/lcd.py +++ b/maix/v1/lcd.py @@ -1,41 +1,57 @@ +from maix import display as disp +from maix.v1 import image + +__disp = None def init(type=1, freq=15000000, color=0x000000, invert = 0, lcd_type = 0): + global __disp + __disp = disp.Display() pass def deinit(): pass def width(): - pass + return __disp.width() def height(): - pass + return __disp.height() def type(): - pass + raise ValueError('This operation is not supported') def freq(freq): - pass + raise ValueError('This operation is not supported') def set_backlight(value): - pass + __disp.set_backlight(value) + +def get_backlight(): + raise ValueError('This operation is not supported') def display(img, roi=None, oft=(0, 0)): + __disp.show(img.get_priv_img()) pass def clear(): + img = image.Image(width=__disp.width(), height=__disp.height()) + img.clear() + __disp.show(img.get_priv_img()) pass def rotation(dir): - pass + raise ValueError('This operation is not supported') + +def direction(dir): + rotation(dir) def mirror(invert): - pass + raise ValueError('This operation is not supported') def bgr_to_rgb(enable): - pass + raise ValueError('This operation is not supported') def fill_rectangle(x, y, w, h, color): - pass + raise ValueError('This operation is not supported') diff --git a/maix/v1/sensor.py b/maix/v1/sensor.py index 55f8df73..c5a07e97 100644 --- a/maix/v1/sensor.py +++ b/maix/v1/sensor.py @@ -1,61 +1,184 @@ - +from maix.v1 import image +from maix import camera + +__camera = None + +BAYER = 0 +RGB565 = 1 +YUV422 = 2 +GRAYSCALE = 3 +JPEG = 4 +RGB888 = 5 + +# C/SIF Resolutions +QQCIF = 1 # 88x72 +QCIF = 2 # 176x144 +CIF = 3 # 352x288 +QQSIF = 4 # 88x60 +QSIF = 5 # 176x120 +SIF = 6 # 352x240 +# VGA Resolutions +QQQQVGA = 7 # 40x30 +QQQVGA = 8 # 80x60 +QQVGA = 9 # 160x120 +QVGA = 10 # 320x240 +VGA = 11 # 640x480 +HQQQVGA = 12 # 60x40 +HQQVGA = 13 # 120x80 +HQVGA = 14 # 240x160 +# Other +LCD = 20 # 128x160 +QQVGA2 = 21 # 128x160 +WVGA = 22 # 720x480 +WVGA2 = 23 # 752x480 +SVGA = 24 # 800x600 +SXGA = 25 # 1280x1024 +UXGA = 26 # 1600x1200 def reset(freq=24000000, set_regs=True, dual_buff=True): + global __camera + __camera = camera.Camera() pass +def binocular_reset(): + raise ValueError('This operation is not supported') + def set_framesize(framesize, set_regs=True): - pass + w = 0 + h = 0 + if framesize == QQCIF: + w = 88 + h = 72 + elif framesize == QCIF: + w = 176 + h = 144 + elif framesize == CIF: + w = 352 + h = 288 + elif framesize == QQSIF: + w = 88 + h = 60 + elif framesize == QSIF: + w = 176 + h = 120 + elif framesize == SIF: + w = 352 + h = 240 + elif framesize == QQQQVGA: + w = 40 + h = 30 + elif framesize == QQQVGA: + w = 80 + h = 60 + elif framesize == QQVGA: + w = 160 + h = 120 + elif framesize == QVGA: + w = 320 + h = 240 + elif framesize == VGA: + w = 640 + h = 480 + elif framesize == HQQQVGA: + w = 60 + h = 40 + elif framesize == HQQVGA: + w = 120 + h = 80 + elif framesize == HQVGA: + w = 240 + h = 160 + elif framesize == LCD: + w = 128 + h = 160 + elif framesize == QQVGA2: + w = 128 + h = 160 + elif framesize == WVGA: + w = 720 + h = 480 + elif framesize == WVGA2: + w = 752 + h = 480 + elif framesize == SVGA: + w = 800 + h = 600 + elif framesize == SXGA: + w = 1280 + h = 1024 + elif framesize == UXGA: + w = 1600 + h = 1200 + else: + raise ValueError('This operation is not supported') + return __camera.set_resolution(w, h) + def set_pixformat(format, set_regs=True): - pass + raise ValueError('This operation is not supported') def run(enable=True): - pass + if enable: + __camera.open() + else: + __camera.close() def snapshot(): - pass + img = __camera.read() + v1_img = image.Image(do_nothing=True) + v1_img.set_priv_img(img) + return v1_img def shutdown(): - pass + raise ValueError('This operation is not supported') def skip_frames(n): - pass + __camera.skip_frames(n) + +def get_fb(): + raise ValueError('This operation is not supported') + +def get_id(): + raise ValueError('This operation is not supported') def set_hmirror(enable): - pass + raise ValueError('This operation is not supported') def set_vflip(enable): - pass + raise ValueError('This operation is not supported') def set_brightness(brightness): - pass + raise ValueError('This operation is not supported') def set_contrast(contrast): - pass + raise ValueError('This operation is not supported') def set_saturation(saturation): - pass + raise ValueError('This operation is not supported') def width(): - pass + return __camera.width() def height(): - pass + return __camera.height() def set_colorbar(enable): - pass + __camera.show_colorbar(enable) def set_auto_gain(enable, gain_db=0): - pass + raise ValueError('This operation is not supported') def get_gain_db(): - pass + raise ValueError('This operation is not supported') def __write_reg(addr, value): - pass + __camera.write_reg(addr, value) def __read_reg(addr): - pass + return __camera.read_reg(addr) + +def set_jb_quality(): + raise ValueError('This operation is not supported') diff --git a/maix/v1/video.py b/maix/v1/video.py index e69de29b..ae4e70d8 100644 --- a/maix/v1/video.py +++ b/maix/v1/video.py @@ -0,0 +1,16 @@ +def open(path, record=False, interval=100000, quality=50, width=320, height=240, audio=False, sample_rate=44100, channels=1): + pass + +class avi: + def play(): + pass + + def capture(img): + pass + + def volume(volume): + pass + + def record(): + pass +