This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ca6db4
commit 63c4ec2
Showing
5 changed files
with
120 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
from maix import camera | ||
|
||
print(camera.camera.cam.cfg(240, 240, 0)) | ||
img = camera.camera.cam.get() | ||
print(len(img[0])) | ||
|
||
print(camera.camera.cam.cfg(320, 240, 0)) | ||
img = camera.camera.cam.get() | ||
print(len(img[0])) | ||
|
||
# camera.config(size=(240, 240)) | ||
|
||
# camera.config(size=(320, 240)) | ||
|
||
from _maix_vivo import _v83x_vivo | ||
cam = _v83x_vivo(320, 240) | ||
|
||
print(cam.cfg(240, 240, 0)) | ||
frame = cam.get() | ||
print(len(frame)) | ||
if len(frame) > 0: | ||
print(len(frame[0])) | ||
|
||
print(cam.cfg(320, 240, 0)) | ||
frame = cam.get() | ||
print(len(frame)) | ||
if len(frame) > 0: | ||
print(len(frame[0])) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from maix import event, display, image | ||
from select import select | ||
|
||
dev = event.InputDevice("/dev/input/event1") | ||
while True: | ||
r, w, x = select([dev], [], [], 0) # if r == 0 or set 0 will read() raise BlockingIOError | ||
if r: | ||
img = display.as_image() | ||
img.draw_rectangle(0, 0, 240, 240, color=(255, 0, 0), thickness=-1) | ||
x, y = 0, 0 | ||
for data in dev.read(): | ||
if (data.type == 0x03): | ||
print(' type: ', data.type, ' code: ', hex(data.code), ' value: ', hex(data.value)) | ||
if data.code == 0x35: # ABS_MT_POSITION_X | ||
x = data.value | ||
if data.code == 0x36: # ABS_MT_POSITION_Y | ||
y = data.value | ||
if data.code == 0x30: # ABS_MT_TOUCH_MAJOR | ||
tmp = "(%d, %d, %d)" % (x, y, hex(data.value)) | ||
w, h = image.get_string_size(tmp) | ||
img.draw_string(120 - w // 2, 120, tmp) | ||
display.show(img) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,59 @@ | ||
from maix import camera, display | ||
|
||
camera.config(size=(240, 240)) | ||
img = camera.capture() | ||
print(img) | ||
img.save("240x240.jpg") | ||
display.show(img) | ||
|
||
camera.config(size=(320, 240)) | ||
img = camera.capture() | ||
print(img) | ||
img.save("320x240.jpg") | ||
display.show(img) | ||
|
||
for i in range(10): | ||
camera.config(size=(240, 240)) | ||
for i in range(10): | ||
img = camera.capture() | ||
display.show(img) | ||
camera.config(size=(320, 240)) | ||
for i in range(10): | ||
img = camera.capture() | ||
display.show(img) | ||
|
||
display.config((416, 416)) | ||
# camera.config is remove. | ||
camera.camera.config((640, 480), 0, 1, 0) | ||
|
||
while True: | ||
t = camera.capture() | ||
print(t) | ||
print(type(t)) | ||
display.show(t) | ||
# while True: | ||
# t = camera.capture() | ||
# print(t) | ||
# print(type(t)) | ||
# display.show(t) | ||
|
||
# from maix import camera, display | ||
# t = camera.capture() | ||
# print(t) | ||
# print(type(t)) | ||
# display.show(t) | ||
from maix import camera, display | ||
t = camera.capture() | ||
print(t) | ||
print(type(t)) | ||
display.show(t) | ||
|
||
# camera.camera.config((640, 480)) | ||
# t = camera.capture() | ||
# print(t) | ||
# print(type(t)) | ||
# display.show(t) | ||
camera.camera.config((640, 480)) | ||
t = camera.capture() | ||
print(t) | ||
print(type(t)) | ||
display.show(t) | ||
|
||
# from maix import camera, display | ||
# t = camera.capture().draw_rectangle(30, 50, 130, 140, color=(255, 50, 50), thickness=-1) | ||
from maix import camera, display | ||
t = camera.capture().draw_rectangle(30, 50, 130, 140, color=(255, 50, 50), thickness=-1) | ||
|
||
# print(len(t.tobytes())) | ||
print(len(t.tobytes())) | ||
|
||
# with open("t.bmp", "wb") as f: | ||
# f.write(t.tobytes("bmp")) | ||
with open("t.bmp", "wb") as f: | ||
f.write(t.tobytes("bmp")) | ||
|
||
# with open("t.jpg", "wb") as f: | ||
# f.write(t.tobytes("jpg")) | ||
with open("t.jpg", "wb") as f: | ||
f.write(t.tobytes("jpg")) | ||
|
||
# with open("t.png", "wb") as f: | ||
# f.write(t.tobytes("png", (16, 3))) | ||
with open("t.png", "wb") as f: | ||
f.write(t.tobytes("png", (16, 3))) |