diff --git a/README.md b/README.md index a6d2390..a9d2652 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,12 @@ The tests were done on the ESP32D0WDQ6 (revision 1): +## What works + +TODO: Resume what works + + + ## Installing esp-idf toolchain First thing to do is to install the toolchain for the esp32 (see https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) @@ -74,7 +80,7 @@ cmake \ -DCMAKE_BUILD_TYPE=Release \ -DESP32=ON \ -DBUILD_SHARED_LIBS=OFF \ --DCV_DISABLE_OPTIMIZATION=ON \ +-DCV_DISABLE_OPTIMIZATION=OFF \ -DWITH_IPP=OFF \ -DWITH_TBB=OFF \ -DWITH_OPENMP=OFF \ @@ -86,6 +92,7 @@ cmake \ -DWITH_OPENCLAMDFFT=OFF \ -DWITH_OPENCLAMDBLAS=OFF \ -DWITH_VA_INTEL=OFF \ +-DWITH_EIGEN=OFF \ \ -DWITH_GSTREAMER=OFF \ -DWITH_GTK=OFF \ @@ -96,6 +103,7 @@ cmake \ -DBUILD_PNG=ON \ -DWITH_TIFF=OFF \ -DWITH_V4L=OFF \ +-DWITH_LAPACK=OFF \ -DWITH_ITT=OFF \ -DWITH_PROTOBUF=OFF \ -DWITH_IMGCODEC_HDR=OFF \ @@ -305,7 +313,7 @@ The `cmake` command is run, leading to the following errors: **FIX:** - * Changed the file `cmake/checks/atomic_check.cpp` in OpenCV repo. The `std::atomic` was changed in `std::atomic`, and also every `std::atomic` occurrence in the OpenCV files. + * Changed the file `cmake/checks/atomic_check.cpp` in OpenCV repo. The `std::atomic` was changed in `std::atomic`, and also in file `modules/core/include/opencv2/core/utils/allocator_stats.impl.hpp` line 24. * CMake Error at `/usr/share/cmake-3.16/Modules/TestBigEndian.cmake:50`. The ESP32 is in little endian. @@ -484,9 +492,7 @@ ESP_LOGI(TAG, "heap left: %d Bytes", esp_get_free_heap_size()); ## Adding images codecs support -Things tried to read/writes images in JPEG, PNG, etc.. - - +Things done to read/writes images in JPEG, PNG, etc.. #### PNG @@ -500,7 +506,7 @@ The library is compiled in the `3rdparty/` folder. Copy this folder into the esp #### JPEG * Remove `-DWITH_JPEG=OFF` and add `-DBUILD_JPEG=ON` of the cmake command - * => Problem at compilation time + * => Problem at compilation time. TODO diff --git a/esp32/examples/esp_opencv_tests/benchmark_with-optimization_26-03.txt b/esp32/examples/esp_opencv_tests/benchmark_with-optimization_26-03.txt new file mode 100644 index 0000000..2bea5f7 --- /dev/null +++ b/esp32/examples/esp_opencv_tests/benchmark_with-optimization_26-03.txt @@ -0,0 +1,87 @@ +I (12398) SYSTEM: task stack left: 29028 Bytes +I (12408) SYSTEM: heap left: 4379580 Bytes +I (12678) opencv_tests: Image read of 399x473x3, with 0 pixel depth +I (12678) opencv_tests: ==================== Thresholding tests ==================== +Time taken by Binary threshold: 26 [ms] +Time taken by Triangle threshold: 40 [ms] +Time taken by OTSU threshold: 43 [ms] +Time taken by To zero threshold: 26 [ms] +I (13138) SYSTEM: task stack left: 26124 Bytes +I (13138) SYSTEM: heap left: 3813264 Bytes +I (13138) opencv_tests: ==================== Blurring tests ==================== +Time taken by GaussianBlur: 1068 [ms] +Time taken by medianBlur: 1592 [ms] +Time taken by bilateralFilter: 2774 [ms] +I (29458) SYSTEM: task stack left: 26124 Bytes +I (29458) SYSTEM: heap left: 3812992 Bytes +I (29458) opencv_tests: =========== Morphology transformations tests =========== +Time taken by erode: 279 [ms] +Time taken by dilate: 278 [ms] +Time taken by open: 533 [ms] +I (32748) SYSTEM: task stack left: 26124 Bytes +I (32748) SYSTEM: heap left: 3812992 Bytes +I (32748) opencv_tests: ==================== Resizing tests ==================== +Time taken by linear resize: 105 [ms] +Time taken by cubic resize: 340 [ms] +Time taken by pyrUp: 498 [ms] +Time taken by pyrDown: 77 [ms] +I (35828) SYSTEM: task stack left: 936 Bytes +I (35828) SYSTEM: heap left: 3812992 Bytes +I (35828) opencv_tests: ================= Edge detection tests ================= +Time taken by Sobel: 121 [ms] +Time taken by Canny: 317 [ms] +I (36568) SYSTEM: task stack left: 936 Bytes +I (36568) SYSTEM: heap left: 3812992 Bytes + + +OpenCV compiled with: +cmake \ +-DCMAKE_BUILD_TYPE=Release \ +-DESP32=ON \ +-DBUILD_SHARED_LIBS=OFF \ +-DCV_DISABLE_OPTIMIZATION=OFF \ +-DWITH_IPP=OFF \ +-DWITH_TBB=OFF \ +-DWITH_OPENMP=OFF \ +-DWITH_PTHREADS_PF=OFF \ +-DWITH_QUIRC=OFF \ +-DWITH_1394=OFF \ +-DWITH_CUDA=OFF \ +-DWITH_OPENCL=OFF \ +-DWITH_OPENCLAMDFFT=OFF \ +-DWITH_OPENCLAMDBLAS=OFF \ +-DWITH_VA_INTEL=OFF \ +-DWITH_EIGEN=OFF \ + \ +-DWITH_GSTREAMER=OFF \ +-DWITH_GTK=OFF \ +-DWITH_JASPER=OFF \ +-DWITH_JPEG=OFF \ +-DWITH_WEBP=OFF \ +-DBUILD_ZLIB=ON \ +-DBUILD_PNG=ON \ +-DWITH_TIFF=OFF \ +-DWITH_V4L=OFF \ +-DWITH_LAPACK=OFF \ +-DWITH_ITT=OFF \ +-DWITH_PROTOBUF=OFF \ +-DWITH_IMGCODEC_HDR=OFF \ +-DWITH_IMGCODEC_SUNRASTER=OFF \ +-DWITH_IMGCODEC_PXM=OFF \ +-DWITH_IMGCODEC_PFM=OFF \ + \ +-DBUILD_LIST=core,imgproc,imgcodecs \ +-DBUILD_JAVA=OFF \ +-DBUILD_opencv_python=OFF \ +-DBUILD_opencv_java=OFF \ + \ +-DBUILD_opencv_apps=OFF \ +-DBUILD_PACKAGE=OFF \ +-DBUILD_PERF_TESTS=OFF \ +-DBUILD_TESTS=OFF \ +-DCV_ENABLE_INTRINSICS=OFF \ +-DCV_TRACE=OFF \ +-DOPENCV_ENABLE_MEMALIGN=OFF \ + \ +-DCMAKE_TOOLCHAIN_FILE=~/esp/esp-idf/tools/cmake/toolchain-esp32.cmake \ +.. diff --git a/esp32/examples/esp_opencv_tests/benchmark_without-optimization_26-03.txt b/esp32/examples/esp_opencv_tests/benchmark_without-optimization_26-03.txt new file mode 100644 index 0000000..f2a5ca0 --- /dev/null +++ b/esp32/examples/esp_opencv_tests/benchmark_without-optimization_26-03.txt @@ -0,0 +1,85 @@ +I (12395) SYSTEM: task stack left: 29028 Bytes +I (12395) SYSTEM: heap left: 4379580 Bytes +I (12695) opencv_tests: Image read of 399x473x3, with 0 pixel depth +I (12695) opencv_tests: ==================== Thresholding tests ==================== +Time taken by Binary threshold: 30 [ms] +Time taken by Triangle threshold: 49 [ms] +Time taken by OTSU threshold: 52 [ms] +Time taken by To zero threshold: 30 [ms] +I (13235) SYSTEM: task stack left: 29028 Bytes +I (13235) SYSTEM: heap left: 3813264 Bytes +I (13235) opencv_tests: ==================== Blurring tests ==================== +Time taken by GaussianBlur: 1102 [ms] +Time taken by medianBlur: 1596 [ms] +Time taken by bilateralFilter: 2773 [ms] +I (29665) SYSTEM: task stack left: 27340 Bytes +I (29665) SYSTEM: heap left: 3812992 Bytes +I (29665) opencv_tests: =========== Morphology transformations tests =========== +Time taken by erode: 355 [ms] +Time taken by dilate: 355 [ms] +Time taken by open: 686 [ms] +I (33875) SYSTEM: task stack left: 27340 Bytes +I (33875) SYSTEM: heap left: 3812992 Bytes +I (33875) opencv_tests: ==================== Resizing tests ==================== +Time taken by linear resize: 109 [ms] +Time taken by cubic resize: 337 [ms] +Time taken by pyrUp: 499 [ms] +Time taken by pyrDown: 77 [ms] +I (36955) SYSTEM: task stack left: 936 Bytes +I (36955) SYSTEM: heap left: 3812992 Bytes +I (36955) opencv_tests: ================= Edge detection tests ================= +Time taken by Sobel: 153 [ms] +Time taken by Canny: 324 [ms] +I (37805) SYSTEM: task stack left: 936 Bytes +I (37805) SYSTEM: heap left: 3812992 Bytes + + +OpenCV compiled with : +cmake \ +-DCMAKE_BUILD_TYPE=Release \ +-DESP32=ON \ +-DBUILD_SHARED_LIBS=OFF \ +-DCV_DISABLE_OPTIMIZATION=ON \ +-DWITH_IPP=OFF \ +-DWITH_TBB=OFF \ +-DWITH_OPENMP=OFF \ +-DWITH_PTHREADS_PF=OFF \ +-DWITH_QUIRC=OFF \ +-DWITH_1394=OFF \ +-DWITH_CUDA=OFF \ +-DWITH_OPENCL=OFF \ +-DWITH_OPENCLAMDFFT=OFF \ +-DWITH_OPENCLAMDBLAS=OFF \ +-DWITH_VA_INTEL=OFF \ + \ +-DWITH_GSTREAMER=OFF \ +-DWITH_GTK=OFF \ +-DWITH_JASPER=OFF \ +-DWITH_JPEG=OFF \ +-DWITH_WEBP=OFF \ +-DBUILD_ZLIB=ON \ +-DBUILD_PNG=ON \ +-DWITH_TIFF=OFF \ +-DWITH_V4L=OFF \ +-DWITH_ITT=OFF \ +-DWITH_PROTOBUF=OFF \ +-DWITH_IMGCODEC_HDR=OFF \ +-DWITH_IMGCODEC_SUNRASTER=OFF \ +-DWITH_IMGCODEC_PXM=OFF \ +-DWITH_IMGCODEC_PFM=OFF \ + \ +-DBUILD_LIST=core,imgproc,imgcodecs \ +-DBUILD_JAVA=OFF \ +-DBUILD_opencv_python=OFF \ +-DBUILD_opencv_java=OFF \ + \ +-DBUILD_opencv_apps=OFF \ +-DBUILD_PACKAGE=OFF \ +-DBUILD_PERF_TESTS=OFF \ +-DBUILD_TESTS=OFF \ +-DCV_ENABLE_INTRINSICS=OFF \ +-DCV_TRACE=OFF \ +-DOPENCV_ENABLE_MEMALIGN=OFF \ + \ +-DCMAKE_TOOLCHAIN_FILE=~/esp/esp-idf/tools/cmake/toolchain-esp32.cmake \ +.. diff --git a/esp32/examples/esp_opencv_tests/main/main.cpp b/esp32/examples/esp_opencv_tests/main/main.cpp index 90993fe..c74e2fc 100644 --- a/esp32/examples/esp_opencv_tests/main/main.cpp +++ b/esp32/examples/esp_opencv_tests/main/main.cpp @@ -81,7 +81,7 @@ void test_spiffs() fgets(line, sizeof(line), f); fclose(f); - printf("Read from file: '%s'", line); + printf("Read from file: '%s'\n", line); /* Images reading/writing tests */ Mat src; @@ -203,7 +203,7 @@ void app_main(void) ESP_LOGI(TAG, "Image read of %dx%dx%d, with %d pixel depth", src.rows, src.cols, src.channels(), src.depth()); /* Conversions and thresholds tests */ - //test_thresholds(src); + test_thresholds(src); disp_mem_infos(); /* Blurring tests */ diff --git a/esp32/examples/esp_opencv_tests/main/opencv/3rdparty/liblibpng.a b/esp32/examples/esp_opencv_tests/main/opencv/3rdparty/liblibpng.a index e5f3788..a60399c 100644 Binary files a/esp32/examples/esp_opencv_tests/main/opencv/3rdparty/liblibpng.a and b/esp32/examples/esp_opencv_tests/main/opencv/3rdparty/liblibpng.a differ diff --git a/esp32/examples/esp_opencv_tests/main/opencv/3rdparty/libzlib.a b/esp32/examples/esp_opencv_tests/main/opencv/3rdparty/libzlib.a index 0a7bd7e..8e87dd9 100644 Binary files a/esp32/examples/esp_opencv_tests/main/opencv/3rdparty/libzlib.a and b/esp32/examples/esp_opencv_tests/main/opencv/3rdparty/libzlib.a differ diff --git a/esp32/examples/esp_opencv_tests/main/opencv/libade.a b/esp32/examples/esp_opencv_tests/main/opencv/libade.a index db6767d..3c7f376 100644 Binary files a/esp32/examples/esp_opencv_tests/main/opencv/libade.a and b/esp32/examples/esp_opencv_tests/main/opencv/libade.a differ diff --git a/esp32/examples/esp_opencv_tests/main/opencv/libopencv_core.a b/esp32/examples/esp_opencv_tests/main/opencv/libopencv_core.a index 33a7c1f..6de666e 100644 Binary files a/esp32/examples/esp_opencv_tests/main/opencv/libopencv_core.a and b/esp32/examples/esp_opencv_tests/main/opencv/libopencv_core.a differ diff --git a/esp32/examples/esp_opencv_tests/main/opencv/libopencv_imgcodecs.a b/esp32/examples/esp_opencv_tests/main/opencv/libopencv_imgcodecs.a index 6df819f..048a8af 100644 Binary files a/esp32/examples/esp_opencv_tests/main/opencv/libopencv_imgcodecs.a and b/esp32/examples/esp_opencv_tests/main/opencv/libopencv_imgcodecs.a differ diff --git a/esp32/examples/esp_opencv_tests/main/opencv/libopencv_imgproc.a b/esp32/examples/esp_opencv_tests/main/opencv/libopencv_imgproc.a index 53ed3a9..425bec1 100644 Binary files a/esp32/examples/esp_opencv_tests/main/opencv/libopencv_imgproc.a and b/esp32/examples/esp_opencv_tests/main/opencv/libopencv_imgproc.a differ diff --git a/esp32/examples/esp_opencv_tests/main/opencv/opencv2/core/utils/allocator_stats.impl.hpp b/esp32/examples/esp_opencv_tests/main/opencv/opencv2/core/utils/allocator_stats.impl.hpp index e418d7c..0e5e924 100644 --- a/esp32/examples/esp_opencv_tests/main/opencv/opencv2/core/utils/allocator_stats.impl.hpp +++ b/esp32/examples/esp_opencv_tests/main/opencv/opencv2/core/utils/allocator_stats.impl.hpp @@ -21,7 +21,8 @@ class AllocatorStatistics : public AllocatorStatisticsInterface { protected: #ifdef CV_CXX11 - std::atomic curr, total, total_allocs, peak; // ESP32 modification (from to ) + // std::atomic curr, total, total_allocs, peak; + std::atomic curr, total, total_allocs, peak; // esp32 doesn't support hardware 64bit atomic. FIXME: add software support #else volatile long long curr, total, total_allocs, peak; // overflow is possible, CV_XADD operates with 'int' only #endif diff --git a/esp32/examples/esp_opencv_tests/main/opencv/opencv2/cvconfig.h b/esp32/examples/esp_opencv_tests/main/opencv/opencv2/cvconfig.h index a3018a8..7e90d8d 100644 --- a/esp32/examples/esp_opencv_tests/main/opencv/opencv2/cvconfig.h +++ b/esp32/examples/esp_opencv_tests/main/opencv/opencv2/cvconfig.h @@ -8,7 +8,7 @@ /* #undef CV_ENABLE_INTRINSICS */ /* OpenCV additional optimized code */ -#define CV_DISABLE_OPTIMIZATION +/* #undef CV_DISABLE_OPTIMIZATION */ /* Compile for 'real' NVIDIA GPU architectures */ #define CUDA_ARCH_BIN "" diff --git a/esp32/lib/opencv/3rdparty/liblibpng.a b/esp32/lib/opencv/3rdparty/liblibpng.a index 74483e0..a60399c 100644 Binary files a/esp32/lib/opencv/3rdparty/liblibpng.a and b/esp32/lib/opencv/3rdparty/liblibpng.a differ diff --git a/esp32/lib/opencv/3rdparty/libzlib.a b/esp32/lib/opencv/3rdparty/libzlib.a index 14c0b56..8e87dd9 100644 Binary files a/esp32/lib/opencv/3rdparty/libzlib.a and b/esp32/lib/opencv/3rdparty/libzlib.a differ diff --git a/esp32/lib/opencv/libade.a b/esp32/lib/opencv/libade.a index 98f50ad..3c7f376 100644 Binary files a/esp32/lib/opencv/libade.a and b/esp32/lib/opencv/libade.a differ diff --git a/esp32/lib/opencv/libopencv_core.a b/esp32/lib/opencv/libopencv_core.a index d5e350e..6de666e 100644 Binary files a/esp32/lib/opencv/libopencv_core.a and b/esp32/lib/opencv/libopencv_core.a differ diff --git a/esp32/lib/opencv/libopencv_imgcodecs.a b/esp32/lib/opencv/libopencv_imgcodecs.a index 4d8b9e2..048a8af 100644 Binary files a/esp32/lib/opencv/libopencv_imgcodecs.a and b/esp32/lib/opencv/libopencv_imgcodecs.a differ diff --git a/esp32/lib/opencv/libopencv_imgproc.a b/esp32/lib/opencv/libopencv_imgproc.a index 64b6cc2..425bec1 100644 Binary files a/esp32/lib/opencv/libopencv_imgproc.a and b/esp32/lib/opencv/libopencv_imgproc.a differ diff --git a/esp32/lib/opencv/opencv2/core/utils/allocator_stats.impl.hpp b/esp32/lib/opencv/opencv2/core/utils/allocator_stats.impl.hpp index e418d7c..0e5e924 100644 --- a/esp32/lib/opencv/opencv2/core/utils/allocator_stats.impl.hpp +++ b/esp32/lib/opencv/opencv2/core/utils/allocator_stats.impl.hpp @@ -21,7 +21,8 @@ class AllocatorStatistics : public AllocatorStatisticsInterface { protected: #ifdef CV_CXX11 - std::atomic curr, total, total_allocs, peak; // ESP32 modification (from to ) + // std::atomic curr, total, total_allocs, peak; + std::atomic curr, total, total_allocs, peak; // esp32 doesn't support hardware 64bit atomic. FIXME: add software support #else volatile long long curr, total, total_allocs, peak; // overflow is possible, CV_XADD operates with 'int' only #endif diff --git a/esp32/lib/opencv/opencv2/cvconfig.h b/esp32/lib/opencv/opencv2/cvconfig.h index a3018a8..7e90d8d 100644 --- a/esp32/lib/opencv/opencv2/cvconfig.h +++ b/esp32/lib/opencv/opencv2/cvconfig.h @@ -8,7 +8,7 @@ /* #undef CV_ENABLE_INTRINSICS */ /* OpenCV additional optimized code */ -#define CV_DISABLE_OPTIMIZATION +/* #undef CV_DISABLE_OPTIMIZATION */ /* Compile for 'real' NVIDIA GPU architectures */ #define CUDA_ARCH_BIN "" diff --git a/esp32/scripts/build_opencv_for_esp32.sh b/esp32/scripts/build_opencv_for_esp32.sh index 26d64c6..e695b22 100755 --- a/esp32/scripts/build_opencv_for_esp32.sh +++ b/esp32/scripts/build_opencv_for_esp32.sh @@ -40,7 +40,7 @@ else fi -CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DESP32=ON -DBUILD_SHARED_LIBS=OFF -DCV_DISABLE_OPTIMIZATION=ON -DWITH_IPP=OFF -DWITH_TBB=OFF -DWITH_OPENMP=OFF -DWITH_PTHREADS_PF=OFF -DWITH_QUIRC=OFF -DWITH_1394=OFF -DWITH_CUDA=OFF -DWITH_OPENCL=OFF -DWITH_OPENCLAMDFFT=OFF -DWITH_OPENCLAMDBLAS=OFF -DWITH_VA_INTEL=OFF -DWITH_GSTREAMER=OFF -DWITH_GTK=OFF -DWITH_JASPER=OFF -DWITH_JPEG=OFF -DWITH_WEBP=OFF -DBUILD_ZLIB=ON -DBUILD_PNG=ON -DWITH_TIFF=OFF -DWITH_V4L=OFF -DWITH_ITT=OFF -DWITH_PROTOBUF=OFF -DWITH_IMGCODEC_HDR=OFF -DWITH_IMGCODEC_SUNRASTER=OFF -DWITH_IMGCODEC_PXM=OFF -DWITH_IMGCODEC_PFM=OFF -DBUILD_LIST=${OPENCV_MODULES_LIST} -DBUILD_JAVA=OFF -DBUILD_opencv_python=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_apps=OFF -DBUILD_PACKAGE=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DCV_ENABLE_INTRINSICS=OFF -DCV_TRACE=OFF -DOPENCV_ENABLE_MEMALIGN=OFF -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_CMAKE_PATH}" +CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DESP32=ON -DBUILD_SHARED_LIBS=OFF -DCV_DISABLE_OPTIMIZATION=OFF -DWITH_IPP=OFF -DWITH_TBB=OFF -DWITH_OPENMP=OFF -DWITH_PTHREADS_PF=OFF -DWITH_QUIRC=OFF -DWITH_1394=OFF -DWITH_CUDA=OFF -DWITH_OPENCL=OFF -DWITH_OPENCLAMDFFT=OFF -DWITH_OPENCLAMDBLAS=OFF -DWITH_VA_INTEL=OFF -DWITH_EIGEN=OFF -DWITH_GSTREAMER=OFF -DWITH_GTK=OFF -DWITH_JASPER=OFF -DWITH_JPEG=OFF -DWITH_WEBP=OFF -DBUILD_ZLIB=ON -DBUILD_PNG=ON -DWITH_TIFF=OFF -DWITH_V4L=OFF -DWITH_LAPACK=OFF -DWITH_ITT=OFF -DWITH_PROTOBUF=OFF -DWITH_IMGCODEC_HDR=OFF -DWITH_IMGCODEC_SUNRASTER=OFF -DWITH_IMGCODEC_PXM=OFF -DWITH_IMGCODEC_PFM=OFF -DBUILD_LIST=${OPENCV_MODULES_LIST} -DBUILD_JAVA=OFF -DBUILD_opencv_python=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_apps=OFF -DBUILD_PACKAGE=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DCV_ENABLE_INTRINSICS=OFF -DCV_TRACE=OFF -DOPENCV_ENABLE_MEMALIGN=OFF -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_CMAKE_PATH}" ### configure and build opencv ###