Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjustments for ESP32-cam and ESP-IDF 5.3.0 #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nicklasb
Copy link

Hi,

Not sure if this will work for you, the PR perhaps does way too much, but it makes the hello- and benchmark examples work on ESP-IDF 5.3.0 and a normal ESP32 CAM, I adjusted down the spiffs to fit in 4MB. It should work on the ttgo aswell, but I am not sure. Either way the ESP32 CAM is super cheap and everyone seem to have one.

It might be possible to get the ttgo-demo to work as well actually, but then it would need to use a newer version of lgvl, which is beyond my use case.

@nopnop2002
Copy link

nopnop2002 commented Sep 5, 2024

@nicklasb

That's nice work.

I built esp32/examples/esp_opencv_tests using your repository.
https://github.com/nicklasb/esp32-opencv/tree/master/esp32/examples/esp_opencv_tests

We need sdkconfig.defaults in esp_opencv_tests directory.

Contents of sdkconfig.defaults

#
# Partition Table
#
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"

#
# Serial flasher config
#
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y

#
# Compiler options
#
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0
CONFIG_CXX_EXCEPTIONS=y
CONFIG_CXX_EXCEPTIONS_EMG_POOL_SIZE=0

#
# Memory protection
#
CONFIG_ESP_MAIN_TASK_STACK_SIZE=20480
CONFIG_ESP_TASK_WDT_EN=n

How to build

We need a esp32/esp32s3 development board that has PSRAM and 4M flash.
esp32s2 don't work.
esp32s2's ROM is smaller than others.
Probably something is missing in the esp32s2 rom component.
And we also need to enable PSRAM using menuconfig.
PSRAM configuration is different for ESP32 and ESP32S3.
For ESP32S3, you need to select QUAD mode PSRAM or OCTAL mode PSRAM depending on your board.
Therefore, enabling PSRAM is not included in sdkconfig.defaults.
We need to enable PSRAM using memoconfig.


$ idf.py --version
ESP-IDF v5.3-dirty

$ git clone https://github.com/nicklasb/esp32-opencv

$ cd esp32-opencv/esp32/examples/esp_opencv_tests

# Create sdkconfig.defaults

$ idf.py set-target {esp32/esp32s3}

$ idf.py menuconfig

# Enable PSRAM 

$ idf.py flash monitor


libpng warning: iCCP: known incorrect sRGB profile
I (2633) opencv_tests: Image read of 120x160x1, with 0 pixel depth
libpng warning: iCCP: known incorrect sRGB profile
I (2943) opencv_tests: Image read of 240x320x1, with 0 pixel depth
libpng warning: iCCP: known incorrect sRGB profile
I (3793) opencv_tests: Image read of 480x640x1, with 0 pixel depth
libpng warning: iCCP: known incorrect sRGB profile

+------------------------------------------------+-------------+-------------+-------------+-------------+
| Function name and arguments                    | BUILD_TYPE=Release                                    |
+------------------------------------------------+-------------+-------------+-------------+-------------+
|                                                |     160x120 |     320x240 |     640x480 |    1024x768 |
+================================================+=============+=============+=============+=============+
|                                                                                                        |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| **Threshold**                                                                                          |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| binaryThreshold                                |         3.1 |          15 |          60 |         154 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| triangleThreshold                              |         4.0 |          21 |          83 |         213 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| OTSUThreshold                                  |         7.7 |          25 |          87 |         216 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| toZeroThreshold                                |         3.2 |          15 |          60 |         155 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
|                                                                                                        |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| **Blurring**                                                                                           |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| GaussianBlur 3x3 kernel                        |         5.3 |          19 |          72 |         181 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| medianBlur 3x3 kernel                          |          27 |         106 |         423 |        1081 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| bilateralFilter diameter=5                     |          67 |         250 |         976 |        2483 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
|                                                                                                        |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| **Morphological tranforms**                                                                            |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| erode 5x5 kernel                               |         7.0 |          27 |         105 |         266 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| dilate 5x5 kernel                              |         7.1 |          27 |         105 |         266 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| open 5x5 kernel                                |          12 |          52 |         204 |         519 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
|                                                                                                        |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| **Resize image**                                                                                       |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| resize linear interpolation                    |         4.2 |          17 |          63 |         155 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| resize cubic interpolation                     |         7.4 |          27 |         106 |         278 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
|                                                                                                        |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| **Edge detection**                                                                                     |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| Sobel                                          |          16 |          57 |         216 |         821 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| Canny                                          |          38 |         132 |         489 |        1941 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
|                                                                                                        |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| **Hough tranformations**                                                                               |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| HoughLines                                     |         385 |         963 |        3472 |        5409 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| HoughLines probabilistic                       |         924 |        2189 |        6473 |       11174 |
+------------------------------------------------+-------------+-------------+-------------+-------------+

Using ESP32-CAM

ESP32-CAM is a good choice, but it gives errors in some tests.

I don't know why.

+------------------------------------------------+-------------+-------------+-------------+-------------+
| **Edge detection**                                                                                     |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| Sobel                                          |          23 |          80 |         302 |         821 |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| Canny                                          |          56 |         188 |         655 |         ERR |
+------------------------------------------------+-------------+-------------+-------------+-------------+
|                                                                                                        |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| **Hough tranformations**                                                                               |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| HoughLines                                     |         536 |        1184 |        3717 |         ERR |
+------------------------------------------------+-------------+-------------+-------------+-------------+
| HoughLines probabilistic                       |        1113 |        2505 |        6963 |         ERR |
+------------------------------------------------+-------------+-------------+-------------+-------------+

@riderman10000
Copy link

riderman10000 commented Sep 17, 2024

ERROR


Error: app partition is too small for binary hello_opencv.bin size 0x103fb0:

  • Part 'factory' 0/0 @ 0x10000 size 0x100000 (overflow 0x3fb0)
    ninja: build stopped: subcommand failed.

SOLUTION

Just leaving this comment for easy navigation.

for the vscode extension ESP-IDF, go to SDK Configuration editor (Ctrl + Shift + P type Menuconfig)
then like @nopnop2002's comment, edit the configurations given under the heading Contents of sdkconfig.defaults.
(thanks for the solution @nopnop2002)

Partition table

choose the value: Custom partition table CSV (Notice the name paritions.csv in your folder and in the setting be same)
image

serial flasher

set the flash size to higher
image

Compiler

set the Enable C++ exceptions
image

memory protection

change the value of Main task stack size to 20480

image

the watch dog is not set so no need to change it.
you can see the search word in each pictures.

memory error in esp32s3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants