Skip to content

Commit 420acfe

Browse files
committed
optimize apps for maixcam2
1 parent 88235cc commit 420acfe

File tree

15 files changed

+23
-23
lines changed

15 files changed

+23
-23
lines changed

projects/app_benchmark/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from maix import camera, display, image, app, time, touchscreen, key
22

33
disp = display.Display()
4-
img = image.Image(disp.width(), disp.height())
4+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
55
msg = "loading..."
66
size = image.string_size(msg, scale=2, thickness=2)
77
img.draw_string((img.width() - size.width()) // 2, (img.height() - size.height()) // 2, msg, image.COLOR_WHITE, scale=2, thickness=2)

projects/app_face_emotion/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def main(disp):
129129
import traceback
130130
msg = traceback.format_exc()
131131
print(msg)
132-
img = image.Image(disp.width(), disp.height())
132+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
133133
img.draw_string(0, 0, msg, image.COLOR_WHITE)
134134
disp.show(img)
135135
while not app.need_exit():

projects/app_face_landmarks/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def main(disp):
114114
import traceback
115115
msg = traceback.format_exc()
116116
print(msg)
117-
img = image.Image(disp.width(), disp.height())
117+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
118118
img.draw_string(0, 0, msg, image.COLOR_WHITE)
119119
disp.show(img)
120120
while not app.need_exit():

projects/app_face_recognizer/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_back_btn_img(width):
1717

1818
def main(disp):
1919
global pressed_flag, learn_id
20-
img = image.Image(disp.width(), disp.height())
20+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
2121
msg = "loading ..."
2222
size = image.string_size(msg, scale=2, thickness=2)
2323
img.draw_string((img.width() - size.width()) // 2, (img.height() - size.height()) // 2, msg, color=image.COLOR_WHITE, scale=2, thickness=2)
@@ -127,7 +127,7 @@ def on_touch(x, y, pressed):
127127
import traceback
128128
msg = traceback.format_exc()
129129
print(msg)
130-
img = image.Image(disp.width(), disp.height())
130+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
131131
img.draw_string(0, 0, msg, image.COLOR_WHITE)
132132
disp.show(img)
133133
while not app.need_exit():

projects/app_hand_landmarks/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def main(disp):
8686
import traceback
8787
msg = traceback.format_exc()
8888
print(msg)
89-
img = image.Image(disp.width(), disp.height())
89+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
9090
img.draw_string(0, 0, msg, image.COLOR_WHITE)
9191
disp.show(img)
9292
while not app.need_exit():

projects/app_http_file_browser/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def main(disp, ts):
222222
image.set_default_font("sourcehansans")
223223
trans = i18n.Trans(trans_dict)
224224
tr = trans.tr
225-
img = image.Image(disp.width(), disp.height())
225+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
226226
draw_msg(img, tr, port)
227227
img.draw_image(0, 0, img_back)
228228
disp.show(img)
@@ -237,15 +237,15 @@ def main(disp, ts):
237237
if "Address in use" in err_msg:
238238
err_msg = ""
239239
port += 1
240-
img = image.Image(disp.width(), disp.height())
240+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
241241
draw_msg(img, tr, port)
242242
img.draw_image(0, 0, img_back)
243243
disp.show(img)
244244
th = threading.Thread(target=start_http_server, args=(port,))
245245
th.daemon = True
246246
th.start()
247247
continue
248-
img = image.Image(disp.width(), disp.height())
248+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
249249
img.draw_string(2, 2, err_msg, image.COLOR_WHITE, scale=0.8)
250250
img.draw_image(0, 0, img_back)
251251
disp.show(img)
@@ -264,7 +264,7 @@ def main(disp, ts):
264264
import traceback
265265
e = traceback.format_exc()
266266
print(e)
267-
img = image.Image(screen.width(), screen.height())
267+
img = image.Image(screen.width(), screen.height(), bg=image.COLOR_BLACK)
268268
img.draw_string(2, 2, e, image.COLOR_WHITE, font="hershey_complex_small", scale=0.6)
269269
img.draw_image(0, 0, img_back)
270270
screen.show(img)

projects/app_human_pose/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def main(disp):
5050
except Exception:
5151
import traceback
5252
msg = traceback.format_exc()
53-
img = image.Image(disp.width(), disp.height())
53+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
5454
img.draw_string(0, 0, msg, image.COLOR_WHITE)
5555
disp.show(img)
5656
while not app.need_exit():

projects/app_human_pose_classifier/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def main(disp):
6060
except Exception:
6161
import traceback
6262
msg = traceback.format_exc()
63-
img = image.Image(disp.width(), disp.height())
63+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
6464
img.draw_string(0, 0, msg, image.COLOR_WHITE)
6565
disp.show(img)
6666
while not app.need_exit():

projects/app_imu_ahrs/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def draw_image(img, angle, dir_cam=False):
6969
img.draw_string(int(v[2][0]), int(v[2][1]), "z", image.COLOR_GREEN, 1.5)
7070

7171
def show_msg(disp, msg):
72-
img = image.Image(disp.width(), disp.height())
72+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
7373
size = image.string_size(msg, 1.5)
7474
x = (img.width() - size.width()) // 2
7575
y = (img.height() - size.height()) // 2
@@ -93,7 +93,7 @@ def main(disp):
9393
try:
9494
sensor = imu.IMU("default")
9595
except Exception:
96-
img = image.Image(disp.width(), disp.height())
96+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
9797
msg = "Init IMU failed, maybe no IMU"
9898
size = image.string_size(msg, scale=1.2, font="hershey_complex_small")
9999
img.draw_string((img.width() - size.width()) // 2, (img.height() - size.height()) // 2 , msg, image.COLOR_WHITE, scale=1.2, font="hershey_complex_small")
@@ -123,7 +123,7 @@ def main(disp):
123123
# make y axis same with camera(x rotate 90 degree)
124124
angle.x -= pitch_offset
125125

126-
img = image.Image(disp.width(), disp.height())
126+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
127127
img.draw_string(2, 4, f"pitch: {angle.x:.2f}, roll: {angle.y:.2f}, yaw: {angle.z:.2f}", image.COLOR_WHITE, 1.5)
128128
img.draw_string(2, 36, f"dt: {int(dt * 1000):3d}ms, temp: {data.temp:.1f}", image.COLOR_WHITE, 1.5)
129129
draw_image(img, angle, pitch_offset == 90)
@@ -164,7 +164,7 @@ def main(disp):
164164
import traceback
165165
e = traceback.format_exc()
166166
print(e)
167-
img = image.Image(disp.width(), disp.height())
167+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
168168
img.draw_string(2, 2, e, image.COLOR_WHITE, font="hershey_complex_small", scale=0.6)
169169
disp.show(img)
170170
while not app.need_exit():

projects/app_maixhub_client/maixhub/ui.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from maix import display, image
22

33
disp = display.Display()
4-
img = image.Image(disp.width(), disp.height())
4+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
55
msg = "Loading ..."
66
size = image.string_size(msg, scale=2, thickness=2)
77
img.draw_string((img.width() - size.width()) // 2, (img.height() - size.height()) // 2, msg, scale=2, color=image.COLOR_WHITE, thickness=2)
@@ -617,7 +617,7 @@ def main():
617617
import traceback
618618
e = traceback.format_exc()
619619
print(e)
620-
img = image.Image(disp.width(), disp.height())
620+
img = image.Image(disp.width(), disp.height(), bg=image.COLOR_BLACK)
621621
img.draw_string(2, 2, e, image.COLOR_WHITE, font="hershey_complex_small", scale=0.6)
622622
disp.show(img)
623623
while not app.need_exit():

0 commit comments

Comments
 (0)