Skip to content

Commit e7670f8

Browse files
Cam works in color but not YUV
1 parent cb2376e commit e7670f8

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

internal_filesystem/apps/com.example.camtestnew/assets/camtestcolor.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import time
1313

14-
th.disable()
14+
#th.disable()
1515

1616

1717
from camera import Camera, GrabMode, PixelFormat, FrameSize, GainCeiling
@@ -26,10 +26,10 @@
2626
xclk_freq=20000000,
2727
powerdown_pin=-1,
2828
reset_pin=-1,
29-
#pixel_format=PixelFormat.RGB565,
29+
pixel_format=PixelFormat.RGB565,
3030
#pixel_format=PixelFormat.GRAYSCALE,
3131
#pixel_format=PixelFormat.YUV420,
32-
pixel_format=PixelFormat.YUV422, # works
32+
#pixel_format=PixelFormat.YUV422, # works
3333
frame_size=FrameSize.R240X240,
3434
grab_mode=GrabMode.LATEST
3535
)
@@ -38,18 +38,26 @@
3838

3939
image = lv.image(lv.screen_active())
4040
image.align(lv.ALIGN.LEFT_MID, 0, 0)
41-
image.set_rotation(900)
41+
#image.set_rotation(900)
4242

4343
# Create image descriptor once
4444
image_dsc = lv.image_dsc_t({
4545
"header": {
4646
"magic": lv.IMAGE_HEADER_MAGIC,
4747
"w": width,
4848
"h": height,
49-
"stride": width,
50-
"cf": lv.COLOR_FORMAT.I422
49+
"stride": width *2,
50+
#"cf": lv.COLOR_FORMAT.L8 # works
51+
"cf": lv.COLOR_FORMAT.RGB565 # works
52+
#"cf": lv.COLOR_FORMAT.I422 #doesnt show anything
53+
#"cf": lv.COLOR_FORMAT.I420 #doesnt show anything
54+
#"cf": lv.COLOR_FORMAT.I420
55+
#"cf": lv.COLOR_FORMAT.YUY2
56+
#"cf": lv.COLOR_FORMAT.UYVY
57+
#"cf": lv.COLOR_FORMAT.NV12
5158
},
52-
'data_size': width * height,
59+
'data_size': width * height * 2 ,
60+
#'data_size': 86400,
5361
'data': None # Will be updated per frame
5462
})
5563
image.set_src(image_dsc)
@@ -61,13 +69,13 @@
6169
image_dsc.data = cam.capture() # Returns memoryview
6270
image.set_src(image_dsc)
6371
#image.invalidate()
64-
lv.task_handler()
72+
#lv.task_handler()
6573
time.sleep_ms(5) # seems to need more than 0 or 1 ms, otherwise there's almost never a new image...
66-
lv.tick_inc(5)
74+
#lv.tick_inc(5)
6775

6876

6977
print("cleanup")
7078
cam.deinit()
7179

7280

73-
th.enable()
81+
#th.enable()

0 commit comments

Comments
 (0)