-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
samples: subsys: video: add capture to lcd sample
Add sample application to capture an image frame from a camera and send it for display on the LCD. Signed-off-by: Charles Dias <[email protected]>
- Loading branch information
1 parent
2765d23
commit 9b21fef
Showing
8 changed files
with
3,272 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(video_capture) | ||
|
||
FILE(GLOB app_sources src/*.c) | ||
target_sources(app PRIVATE ${app_sources}) |
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,9 @@ | ||
source "Kconfig.zephyr" | ||
|
||
config VIDEO_WIDTH | ||
int "Define the width of the video" | ||
default 160 | ||
|
||
config VIDEO_HEIGHT | ||
int "Define the height of the video" | ||
default 120 |
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,83 @@ | ||
.. zephyr:code-sample:: video-capture-to-lcd | ||
:name: Video capture to LCD | ||
:relevant-api: video_interface | ||
|
||
This sample application demonstrates how to use the video API to retrieve video | ||
frames from a capture device and display them on an LCD. | ||
|
||
Description | ||
*********** | ||
|
||
The application uses the :ref:`Video API <video_api>` to retrieve video frames from | ||
a video capture device, writes a frame count message to the console, and then sends | ||
the frame to an LCD display. | ||
|
||
Requirements | ||
************ | ||
|
||
This sample requires a video capture device (e.g., a camera) and an LCD display. | ||
|
||
- :ref:`mini_stm32h743` | ||
- OV2640 camera module | ||
- LCD display | ||
|
||
Wiring | ||
****** | ||
|
||
On the `WeAct Studio STM32H743_`, connect the OV2640 camera module and the 0.96" ST7735 | ||
TFT LCD display. Connect a USB cable from a host to the micro USB-C connector on the | ||
board to receive console output messages. | ||
|
||
Building and Running | ||
******************** | ||
|
||
For :ref:`mini_stm32h743`, build this sample application with the following commands: | ||
|
||
.. zephyr-app-commands:: | ||
:zephyr-app: samples/subsys/video/capture_to_lcd/ | ||
:board: mini_stm32h743 | ||
:goals: build flash | ||
:gen-args: -DCONFIG_BOOT_DELAY=5000 | ||
:compact: | ||
|
||
Sample Output | ||
============= | ||
|
||
.. code-block:: console | ||
- Device name: dcmi@48020000 | ||
- Capabilities: | ||
RGBP width [160; 160; 0] height [120; 120; 0] | ||
RGBP width [176; 176; 0] height [144; 144; 0] | ||
RGBP width [240; 240; 0] height [160; 160; 0] | ||
RGBP width [320; 320; 0] height [240; 240; 0] | ||
RGBP width [352; 352; 0] height [288; 288; 0] | ||
RGBP width [640; 640; 0] height [480; 480; 0] | ||
RGBP width [800; 800; 0] height [600; 600; 0] | ||
RGBP width [1024; 1024; 0] height [768; 768; 0] | ||
RGBP width [1280; 1280; 0] height [1024; 1024; 0] | ||
RGBP width [1600; 1600; 0] height [1200; 1200; 0] | ||
JPEG width [160; 160; 0] height [120; 120; 0] | ||
JPEG width [176; 176; 0] height [144; 144; 0] | ||
JPEG width [240; 240; 0] height [160; 160; 0] | ||
JPEG width [320; 320; 0] height [240; 240; 0] | ||
JPEG width [352; 352; 0] height [288; 288; 0] | ||
JPEG width [640; 640; 0] height [480; 480; 0] | ||
JPEG width [800; 800; 0] height [600; 600; 0] | ||
JPEG width [1024; 1024; 0] height [768; 768; 0] | ||
JPEG width [1280; 1280; 0] height [1024; 1024; 0] | ||
JPEG width [1600; 1600; 0] height [1200; 1200; 0] | ||
- Default format: RGBP 800x600 | ||
- New format: RGBP 160x120 320 | ||
[00:00:02.847,000] <inf> video_stm32_dcmi: Start stream capture | ||
Capture started | ||
Got frame 0! size: 38400; timestamp 2935 ms | ||
Got frame 1! size: 38400; timestamp 3001 ms | ||
Got frame 2! size: 38400; timestamp 8017 ms | ||
<repeats endlessly> | ||
References | ||
********** | ||
|
||
.. _WeAct Studio STM32H743: https://github.com/WeActStudio/MiniSTM32H7xx |
12 changes: 12 additions & 0 deletions
12
samples/subsys/video/capture_to_lcd/boards/mini_stm32h743.conf
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,12 @@ | ||
# | ||
# Copyright (c) 2024 Charles Dias <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
CONFIG_CLOCK_STM32_MCO1_SRC_HSI48=y | ||
CONFIG_CLOCK_STM32_MCO1_DIV=4 | ||
|
||
CONFIG_LOG_BUFFER_SIZE=2048 | ||
|
||
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=102400 |
170 changes: 170 additions & 0 deletions
170
samples/subsys/video/capture_to_lcd/boards/mini_stm32h743.overlay
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,170 @@ | ||
/* | ||
* Copyright (c) 2024 Charles Dias <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
/ { | ||
aliases { | ||
ov-cam = &ov2640; | ||
}; | ||
}; | ||
|
||
&pll { | ||
div-m = <5>; | ||
mul-n = <96>; | ||
div-p = <2>; | ||
div-q = <2>; | ||
div-r = <2>; | ||
clocks = <&clk_hse>; | ||
status = "okay"; | ||
}; | ||
|
||
&rcc { | ||
clocks = <&pll>; | ||
clock-frequency = <DT_FREQ_M(240)>; | ||
d1cpre = <1>; | ||
hpre = <1>; | ||
d1ppre = <2>; | ||
d2ppre1 = <2>; | ||
d2ppre2 = <2>; | ||
d3ppre = <2>; | ||
}; | ||
|
||
&i2c1 { | ||
pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9 &mco1_pa8>; | ||
pinctrl-names = "default"; | ||
status = "okay"; | ||
clock-frequency = <I2C_BITRATE_FAST>; | ||
|
||
ov2640: ov2640@30 { | ||
compatible = "ovti,ov2640"; | ||
reg = <0x30>; | ||
status = "okay"; | ||
supply-gpios = <&gpioa 7 GPIO_ACTIVE_HIGH>; | ||
clock-rate-control = <0x80>; | ||
|
||
port { | ||
ov2640_ep_out: endpoint { | ||
remote-endpoint = <&dcmi_ep_in>; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
&dcmi { | ||
status = "okay"; | ||
sensor = <&ov2640>; | ||
pinctrl-0 = <&dcmi_hsync_pa4 &dcmi_pixclk_pa6 &dcmi_vsync_pb7 | ||
&dcmi_d0_pc6 &dcmi_d1_pc7 &dcmi_d2_pe0 &dcmi_d3_pe1 | ||
&dcmi_d4_pe4 &dcmi_d5_pd3 &dcmi_d6_pe5 &dcmi_d7_pe6>; | ||
pinctrl-names = "default"; | ||
bus-width = <8>; | ||
hsync-active = <0>; | ||
vsync-active = <0>; | ||
pixelclk-active = <1>; | ||
capture-rate = <1>; | ||
dmas = <&dma1 0 75 (STM32_DMA_PERIPH_TO_MEMORY | STM32_DMA_PERIPH_NO_INC | | ||
STM32_DMA_MEM_INC | STM32_DMA_PERIPH_8BITS | STM32_DMA_MEM_32BITS | | ||
STM32_DMA_PRIORITY_HIGH) STM32_DMA_FIFO_1_4>; | ||
|
||
port { | ||
dcmi_ep_in: endpoint { | ||
remote-endpoint = <&ov2640_ep_out>; | ||
}; | ||
}; | ||
}; | ||
|
||
&dma1 { | ||
status = "okay"; | ||
}; | ||
|
||
&dmamux1 { | ||
status = "okay"; | ||
}; | ||
|
||
&pinctrl{ | ||
|
||
mco1_pa8: mco1_pa8 { | ||
pinmux = <STM32_PINMUX('A', 8, AF0)>; | ||
slew-rate = "very-high-speed"; | ||
}; | ||
|
||
/* DCMI_HSYNC */ | ||
|
||
/omit-if-no-ref/ dcmi_hsync_pa4: dcmi_hsync_pa4 { | ||
pinmux = <STM32_PINMUX('A', 4, AF13)>; | ||
slew-rate = "very-high-speed"; | ||
}; | ||
|
||
/* DCMI_PIXCLK */ | ||
|
||
/omit-if-no-ref/ dcmi_pixclk_pa6: dcmi_pixclk_pa6 { | ||
pinmux = <STM32_PINMUX('A', 6, AF13)>; | ||
slew-rate = "very-high-speed"; | ||
}; | ||
|
||
/* DCMI_VSYNC */ | ||
|
||
/omit-if-no-ref/ dcmi_vsync_pb7: dcmi_vsync_pb7 { | ||
pinmux = <STM32_PINMUX('B', 7, AF13)>; | ||
slew-rate = "very-high-speed"; | ||
}; | ||
|
||
/* DCMI_D0 */ | ||
|
||
/omit-if-no-ref/ dcmi_d0_pc6: dcmi_d0_pc6 { | ||
pinmux = <STM32_PINMUX('C', 6, AF13)>; | ||
slew-rate = "very-high-speed"; | ||
}; | ||
|
||
/* DCMI_D1 */ | ||
|
||
/omit-if-no-ref/ dcmi_d1_pc7: dcmi_d1_pc7 { | ||
pinmux = <STM32_PINMUX('C', 7, AF13)>; | ||
slew-rate = "very-high-speed"; | ||
}; | ||
|
||
/* DCMI_D2 */ | ||
|
||
/omit-if-no-ref/ dcmi_d2_pe0: dcmi_d2_pe0 { | ||
pinmux = <STM32_PINMUX('E', 0, AF13)>; | ||
slew-rate = "very-high-speed"; | ||
}; | ||
|
||
/* DCMI_D3 */ | ||
|
||
/omit-if-no-ref/ dcmi_d3_pe1: dcmi_d3_pe1 { | ||
pinmux = <STM32_PINMUX('E', 1, AF13)>; | ||
slew-rate = "very-high-speed"; | ||
}; | ||
|
||
/* DCMI_D4 */ | ||
|
||
/omit-if-no-ref/ dcmi_d4_pe4: dcmi_d4_pe4 { | ||
pinmux = <STM32_PINMUX('E', 4, AF13)>; | ||
slew-rate = "very-high-speed"; | ||
}; | ||
|
||
/* DCMI_D5 */ | ||
|
||
/omit-if-no-ref/ dcmi_d5_pd3: dcmi_d5_pd3 { | ||
pinmux = <STM32_PINMUX('D', 3, AF13)>; | ||
slew-rate = "very-high-speed"; | ||
}; | ||
|
||
/* DCMI_D6 */ | ||
|
||
/omit-if-no-ref/ dcmi_d6_pe5: dcmi_d6_pe5 { | ||
pinmux = <STM32_PINMUX('E', 5, AF13)>; | ||
slew-rate = "very-high-speed"; | ||
}; | ||
|
||
/* DCMI_D7 */ | ||
|
||
/omit-if-no-ref/ dcmi_d7_pe6: dcmi_d7_pe6 { | ||
pinmux = <STM32_PINMUX('E', 6, AF13)>; | ||
slew-rate = "very-high-speed"; | ||
}; | ||
}; |
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,20 @@ | ||
CONFIG_VIDEO=y | ||
CONFIG_VIDEO_SW_GENERATOR=y | ||
|
||
CONFIG_PRINTK=y | ||
CONFIG_LOG=y | ||
|
||
CONFIG_MAIN_STACK_SIZE=4096 | ||
|
||
CONFIG_DISPLAY=y | ||
CONFIG_DISPLAY_LOG_LEVEL_ERR=y | ||
|
||
CONFIG_LVGL=y | ||
CONFIG_LV_MEM_CUSTOM=y | ||
CONFIG_LV_USE_LOG=y | ||
CONFIG_LV_USE_LABEL=y | ||
CONFIG_LV_USE_BTN=y | ||
CONFIG_LV_USE_ARC=y | ||
CONFIG_LV_USE_IMG=y | ||
CONFIG_LV_FONT_MONTSERRAT_14=y | ||
CONFIG_LV_Z_MEM_POOL_SIZE=16384 |
Oops, something went wrong.