build(boards): 所有板卡执行 npm run build:prod
This commit is contained in:
@@ -1,69 +1,47 @@
|
||||
"""
|
||||
Camera GC032A/FrameBuffer(Inherit C module)
|
||||
Camera
|
||||
|
||||
MicroPython library for the GC032A(Inherit C module)
|
||||
MicroPython library for the Camera(Inherit C module)
|
||||
=======================================================
|
||||
@dahanzimin From the Mixly Team
|
||||
"""
|
||||
|
||||
import time
|
||||
import base64
|
||||
from sensor import *
|
||||
import jpeg
|
||||
from _camera import *
|
||||
from jpeg import Encoder
|
||||
from machine import SoftI2C, Pin
|
||||
from mixgo_sant import onboard_bot
|
||||
from esp_usb import CAM
|
||||
|
||||
class GC032A(Camera):
|
||||
def __init__(self, framesize=LCD, hmirror=None, frame=1):
|
||||
onboard_bot.cam_en(1, 500)
|
||||
super().__init__(frame)
|
||||
super().set_framesize(framesize)
|
||||
time.sleep_ms(100)
|
||||
if hmirror is not None:
|
||||
super().set_hmirror(hmirror)
|
||||
time.sleep_ms(100)
|
||||
SoftI2C(scl=Pin(47), sda=Pin(48), freq=400000)
|
||||
SoftI2C(scl=Pin(47), sda=Pin(38), freq=400000)
|
||||
|
||||
class Camera(Camera):
|
||||
def __init__(self, frame_size=FrameSize.R240X240, pixel_format=PixelFormat.RGB565, hmirror=False, vflip=False, **kwargs):
|
||||
onboard_bot.cam_en(1, 150)
|
||||
super().__init__(frame_size=frame_size, pixel_format=pixel_format, **kwargs)
|
||||
self.set_hmirror(not hmirror)
|
||||
time.sleep_ms(50)
|
||||
self.set_vflip(not vflip)
|
||||
time.sleep_ms(50)
|
||||
SoftI2C(scl=Pin(47), sda=Pin(48), freq=400000) # 恢复I2C
|
||||
|
||||
def deinit(self):
|
||||
super().deinit()
|
||||
onboard_bot.cam_en(0, 100)
|
||||
|
||||
def display(self, show=True):
|
||||
if show:
|
||||
super().display()
|
||||
def snapshot(self, path=None, formats=0, quality=90, rotation=0):
|
||||
if formats == 0 and path is None:
|
||||
return self.capture()
|
||||
else:
|
||||
super().display_stop()
|
||||
|
||||
def snapshot(self, path=None, formats=0, quality=50):
|
||||
if path is None:
|
||||
_data = super().snapshot(formats=formats, quality=quality)
|
||||
if formats >= 2:
|
||||
return b'data:image/jpg;base64,' + base64.b64encode(_data)
|
||||
_encoder = Encoder(pixel_format="RGB565_BE", quality=quality, rotation=rotation, width=self.get_pixel_width(), height=self.get_pixel_height())
|
||||
_jpeg = _encoder.encode(self.capture())
|
||||
del _encoder
|
||||
if path is None:
|
||||
if formats == 1:
|
||||
return _jpeg
|
||||
else:
|
||||
return b'data:image/jpg;base64,' + base64.b64encode(_jpeg)
|
||||
else:
|
||||
return _data
|
||||
else:
|
||||
return super().snapshot(path, quality=50)
|
||||
|
||||
class UVC(CAM):
|
||||
def __init__(self, framesize=QVGA):
|
||||
super().__init__(framesize)
|
||||
|
||||
def deinit(self):
|
||||
super().deinit()
|
||||
|
||||
def display(self, show=True):
|
||||
if show:
|
||||
super().display()
|
||||
else:
|
||||
super().display_stop()
|
||||
|
||||
def snapshot(self, path=None, formats=0, quality=50):
|
||||
if path is None:
|
||||
_data = super().snapshot(formats=formats, quality=quality)
|
||||
if formats >= 2:
|
||||
return b'data:image/jpg;base64,' + base64.b64encode(_data)
|
||||
else:
|
||||
return _data
|
||||
else:
|
||||
return super().snapshot(path, quality=50)
|
||||
with open(path, 'wb') as f:
|
||||
f.write(_jpeg)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user