Skip to content

Commit

Permalink
* update camera api and add rtsp demo
Browse files Browse the repository at this point in the history
  • Loading branch information
lxowalle committed Apr 30, 2024
1 parent c049462 commit fd285b3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
26 changes: 26 additions & 0 deletions examples/vision/streaming/rtsp_and_display.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from maix import app, rtsp, camera, image, display

# init camera
cam = camera.Camera(2560, 1440, image.Format.FMT_YVU420SP)
cam2 = cam.add_channel(640, 480)

# init display
disp = display.Display()

# init rtsp server
server = rtsp.Rtsp()
server.bind_camera(cam)
server.start()

# draw region
rgn = server.add_region(0, 0, 200, 100)
canvas = rgn.get_canvas()
canvas.draw_string(0, 0, "Hello MaixPy")
rgn.update_canvas()

print(server.get_url())
while not app.need_exit():
img = cam2.read()
disp.show(img)

server.stop()
10 changes: 5 additions & 5 deletions maix/v1/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,21 @@ def get_id():
raise ValueError('This operation is not supported')

def set_hmirror(enable):
__camera.set_vflip(enable)
__camera.hmirror(enable)

def set_vflip(enable):
__camera.set_vflip(enable)
__camera.vflip(enable)

def set_brightness(brightness):
brightness = brightness + 3
val = brightness * 100 / 4
__camera.set_luma(int(val))
__camera.luma(int(val))

def set_contrast(contrast):
__camera.set_constrast(contrast)
__camera.constrast(contrast)

def set_saturation(saturation):
__camera.set_saturation(saturation)
__camera.saturation(saturation)

def width():
return __camera.width()
Expand Down

0 comments on commit fd285b3

Please sign in to comment.