mirror of
https://gitcode.com/gh_mirrors/es/esp32-opencv.git
synced 2025-08-06 18:24:38 +08:00
Benchmark formatting + on different images sizes
TODO: - markdown formatting ? - header/footer
This commit is contained in:
@ -4,7 +4,7 @@ This example uses OpenCV library on the Esp32. Only the modules `core`, `imgproc
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
The goal of this example is to check which OpenCV features are working.
|
The goal of this example is to check which OpenCV features are working and to benchmark their computation time on the target.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
129
esp32/examples/esp_opencv_tests/benchmark_27-03.txt
Normal file
129
esp32/examples/esp_opencv_tests/benchmark_27-03.txt
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
============================== Thresholding tests ==============================
|
||||||
|
Image 160x120 -------------------------
|
||||||
|
Binary threshold 2 [ms]
|
||||||
|
Triangle threshold 3 [ms]
|
||||||
|
OTSU threshold 6 [ms]
|
||||||
|
To zero threshold 2 [ms]
|
||||||
|
Image 320x240 -------------------------
|
||||||
|
Binary threshold 10 [ms]
|
||||||
|
Triangle threshold 17 [ms]
|
||||||
|
OTSU threshold 19 [ms]
|
||||||
|
To zero threshold 10 [ms]
|
||||||
|
Image 640x480 -------------------------
|
||||||
|
Binary threshold 42 [ms]
|
||||||
|
Triangle threshold 66 [ms]
|
||||||
|
OTSU threshold 68 [ms]
|
||||||
|
To zero threshold 42 [ms]
|
||||||
|
================================ Blurring tests ================================
|
||||||
|
Image 160x120 -------------------------
|
||||||
|
GaussianBlur9x9 33 [ms]
|
||||||
|
medianBlur9x9 53 [ms]
|
||||||
|
bilateralFilter 137 [ms]
|
||||||
|
Image 320x240 -------------------------
|
||||||
|
GaussianBlur9x9 128 [ms]
|
||||||
|
medianBlur9x9 272 [ms]
|
||||||
|
bilateralFilter 534 [ms]
|
||||||
|
Image 640x480 -------------------------
|
||||||
|
GaussianBlur9x9 503 [ms]
|
||||||
|
medianBlur9x9 1424 [ms]
|
||||||
|
bilateralFilter 2118 [ms]
|
||||||
|
======================= Morphology transformations tests =======================
|
||||||
|
Image 160x120 -------------------------
|
||||||
|
erode 8 [ms]
|
||||||
|
dilate 8 [ms]
|
||||||
|
open 14 [ms]
|
||||||
|
Image 320x240 -------------------------
|
||||||
|
erode 30 [ms]
|
||||||
|
dilate 30 [ms]
|
||||||
|
open 57 [ms]
|
||||||
|
Image 640x480 -------------------------
|
||||||
|
erode 117 [ms]
|
||||||
|
dilate 117 [ms]
|
||||||
|
open 224 [ms]
|
||||||
|
================================ Resizing tests ================================
|
||||||
|
Image 160x120 -------------------------
|
||||||
|
linear resize 3 [ms]
|
||||||
|
cubic resize 6 [ms]
|
||||||
|
pyrUp 11 [ms]
|
||||||
|
Image 320x240 -------------------------
|
||||||
|
linear resize 16 [ms]
|
||||||
|
cubic resize 26 [ms]
|
||||||
|
pyrUp 49 [ms]
|
||||||
|
Image 640x480 -------------------------
|
||||||
|
linear resize 59 [ms]
|
||||||
|
cubic resize 107 [ms]
|
||||||
|
pyrUp 195 [ms]
|
||||||
|
============================= Edge detection tests =============================
|
||||||
|
Image 160x120 -------------------------
|
||||||
|
Sobel 14 [ms]
|
||||||
|
Canny: 35 [ms]
|
||||||
|
Image 320x240 -------------------------
|
||||||
|
Sobel 49 [ms]
|
||||||
|
Canny: 123 [ms]
|
||||||
|
Image 640x480 -------------------------
|
||||||
|
Sobel 186 [ms]
|
||||||
|
Canny: 462 [ms]
|
||||||
|
============================= Hough transform tests ============================
|
||||||
|
Image 160x120 -------------------------
|
||||||
|
HoughLines 847 [ms]
|
||||||
|
HoughLineP 1580 [ms]
|
||||||
|
Image 320x240 -------------------------
|
||||||
|
HoughLines 3121 [ms]
|
||||||
|
HoughLineP 6209 [ms]
|
||||||
|
Image 640x480 -------------------------
|
||||||
|
HoughLines 9954 [ms]
|
||||||
|
HoughLineP 17904 [ms]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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 \
|
||||||
|
..
|
@ -1,87 +0,0 @@
|
|||||||
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 \
|
|
||||||
..
|
|
@ -1,85 +0,0 @@
|
|||||||
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 \
|
|
||||||
..
|
|
@ -21,112 +21,52 @@ using namespace cv;
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
char* TAG="opencv_tests";
|
const char* TAG="opencv_tests";
|
||||||
const String imageFileName = "/spiffs/jack.png";
|
|
||||||
const int REPEAT = 3; // number of times to repeat the function call for the average
|
const int REPEAT = 3; // number of times to repeat the function call for the average
|
||||||
|
const int NB_IMAGES = 3; // number of images with different resolutions for the tests
|
||||||
|
const String images_res[] = {"160x120", "320x240", "640x480"};
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void app_main(void);
|
void app_main(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
Mat read_image_specific_res(const String &fileName)
|
||||||
* Function that tests the basics of OpenCV:
|
|
||||||
* - Matrices creation
|
|
||||||
* - Arithmetic operations
|
|
||||||
* -
|
|
||||||
*/
|
|
||||||
void test_basics()
|
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "Doing basic matrices test");
|
Mat img = imread(fileName, IMREAD_GRAYSCALE);
|
||||||
|
|
||||||
/* Matrices initialization tests */
|
if(img.empty()) {
|
||||||
Mat M1(2,2, CV_8UC3, Scalar(0,0,255));
|
ESP_LOGW(TAG, "cannot read the image: %s", fileName.c_str());
|
||||||
cout << "M1 = " << endl << " " << M1 << endl << endl;
|
return img;
|
||||||
|
|
||||||
Mat M2(2,2, CV_8UC3, Scalar(0,0,111));
|
|
||||||
cout << "M2 = " << endl << " " << M2 << endl << endl;
|
|
||||||
|
|
||||||
Mat eye = Mat::eye(10, 10, CV_32F) * 0.1;
|
|
||||||
cout << "eye = " << endl << " " << eye << endl << endl;
|
|
||||||
|
|
||||||
Mat ones = Mat::ones(15, 4, CV_8U)*3;
|
|
||||||
cout << "ones = " << endl << " " << ones << endl << endl;
|
|
||||||
|
|
||||||
vector<float> v;
|
|
||||||
v.push_back((float)CV_PI);
|
|
||||||
v.push_back(2);
|
|
||||||
v.push_back(3.01f);
|
|
||||||
cout << "floats vector = " << endl << " " << Mat(v) << endl << endl;
|
|
||||||
|
|
||||||
uint8_t data[15] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
|
||||||
Mat M3 = Mat(3, 5, CV_8UC1, data);
|
|
||||||
cout << "Gray matrix = " << endl << " " << M3 << endl << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function that reads and write on the SPI Flash File System
|
|
||||||
*/
|
|
||||||
void test_spiffs()
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "Doing SPIFFS read/write tests");
|
|
||||||
|
|
||||||
/* SPIFFS file reading test */
|
|
||||||
FILE* f = fopen("/spiffs/hello.txt", "r");
|
|
||||||
if (f == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to open file for reading");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
char line[64];
|
ESP_LOGI(TAG, "Image read of %dx%dx%d, with %d pixel depth", img.rows, img.cols, img.channels(), img.depth());
|
||||||
fgets(line, sizeof(line), f);
|
return img;
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
printf("Read from file: '%s'\n", line);
|
|
||||||
|
|
||||||
/* Images reading/writing tests */
|
|
||||||
Mat src;
|
|
||||||
src = imread(imageFileName, IMREAD_COLOR);
|
|
||||||
if(src.empty()) {
|
|
||||||
ESP_LOGW(TAG, "cannot read the image: %s", imageFileName.c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
imwrite("/spiffs/dst.png", src);
|
|
||||||
ESP_LOGI(TAG, "Image written!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_thresholds(const Mat &src)
|
void test_thresholds(const Mat &src)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "==================== Thresholding tests ====================");
|
Mat dst;
|
||||||
|
|
||||||
Mat gray, dst;
|
|
||||||
|
|
||||||
// convert to grayscale
|
|
||||||
cvtColor(src, gray, COLOR_BGR2GRAY);
|
|
||||||
|
|
||||||
// apply thresholds
|
// apply thresholds
|
||||||
BENCHMARK_MS("Binary threshold", REPEAT, threshold, gray, dst, 128, 255, THRESH_BINARY);
|
BENCHMARK_MS("Binary threshold", REPEAT, threshold, src, dst, 128, 255, THRESH_BINARY);
|
||||||
BENCHMARK_MS("Triangle threshold", REPEAT, threshold, gray, dst, 0, 255, THRESH_BINARY | THRESH_TRIANGLE);
|
BENCHMARK_MS("Triangle threshold", REPEAT, threshold, src, dst, 0, 255, THRESH_BINARY | THRESH_TRIANGLE);
|
||||||
BENCHMARK_MS("OTSU threshold", REPEAT, threshold, gray, dst, 0, 255, THRESH_BINARY | THRESH_OTSU);
|
BENCHMARK_MS("OTSU threshold", REPEAT, threshold, src, dst, 0, 255, THRESH_BINARY | THRESH_OTSU);
|
||||||
BENCHMARK_MS("To zero threshold", REPEAT, threshold, gray, dst, 128, 255, THRESH_TOZERO);
|
BENCHMARK_MS("To zero threshold", REPEAT, threshold, src, dst, 128, 255, THRESH_TOZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_blurring(const Mat &src)
|
void test_blurring(const Mat &src)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "==================== Blurring tests ====================");
|
|
||||||
|
|
||||||
Mat dst;
|
Mat dst;
|
||||||
|
|
||||||
// apply blurs
|
// apply blurs
|
||||||
BENCHMARK_MS("GaussianBlur", REPEAT, GaussianBlur, src, dst, Size(9, 9), 0, 0, BORDER_DEFAULT);
|
BENCHMARK_MS("GaussianBlur9x9", REPEAT, GaussianBlur, src, dst, Size(9, 9), 0, 0, BORDER_DEFAULT);
|
||||||
BENCHMARK_MS("medianBlur", REPEAT, medianBlur, src, dst, 9);
|
BENCHMARK_MS("medianBlur9x9", REPEAT, medianBlur, src, dst, 9);
|
||||||
BENCHMARK_MS("bilateralFilter", REPEAT, bilateralFilter, src, dst, 9, 18, 5, BORDER_DEFAULT);
|
BENCHMARK_MS("bilateralFilter", REPEAT, bilateralFilter, src, dst, 9, 18, 5, BORDER_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_morphology_transform(const Mat &src)
|
void test_morphology_transform(const Mat &src)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "=========== Morphology transformations tests ===========");
|
|
||||||
|
|
||||||
Mat dst;
|
Mat dst;
|
||||||
|
|
||||||
// create a kernel for the transformation
|
// create a kernel for the transformation
|
||||||
@ -140,8 +80,6 @@ void test_morphology_transform(const Mat &src)
|
|||||||
|
|
||||||
void test_resize(const Mat &src)
|
void test_resize(const Mat &src)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "==================== Resizing tests ====================");
|
|
||||||
|
|
||||||
Mat dst;
|
Mat dst;
|
||||||
|
|
||||||
BENCHMARK_MS("linear resize", REPEAT, resize, src, dst, Size(), 0.75, 0.75, INTER_LINEAR);
|
BENCHMARK_MS("linear resize", REPEAT, resize, src, dst, Size(), 0.75, 0.75, INTER_LINEAR);
|
||||||
@ -153,42 +91,34 @@ void test_resize(const Mat &src)
|
|||||||
|
|
||||||
void test_edge_detect(const Mat &src)
|
void test_edge_detect(const Mat &src)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "================= Edge detection tests =================");
|
Mat dst;
|
||||||
|
|
||||||
Mat dst, gray;
|
BENCHMARK_MS("Sobel", REPEAT, Sobel, src, dst, 2, 2, 1, 3, 1, 0, BORDER_DEFAULT);
|
||||||
|
//BENCHMARK_MS("Canny", REPEAT, Canny, src, dst, 8, 24, 3, false); // FIXME: can't deduce template parameter 'F'
|
||||||
// convert to grayscale
|
Canny(src, dst, 8, 24, 3, false); // cache warm up
|
||||||
cvtColor(src, gray, COLOR_BGR2GRAY);
|
|
||||||
|
|
||||||
BENCHMARK_MS("Sobel", REPEAT, Sobel, gray, dst, 2, 2, 1, 3, 1, 0, BORDER_DEFAULT);
|
|
||||||
//BENCHMARK_MS("Canny", REPEAT, Canny, gray, dst, 8, 24, 3, false); // FIXME: can't deduce template parameter 'F'
|
|
||||||
auto start = chrono::system_clock::now();
|
auto start = chrono::system_clock::now();
|
||||||
Canny(gray, dst, 8, 24, 3, false);
|
Canny(src, dst, 8, 24, 3, false);
|
||||||
auto duration = chrono::duration_cast<chrono::milliseconds >(chrono::system_clock::now() - start);
|
auto duration = chrono::duration_cast<chrono::milliseconds >(chrono::system_clock::now() - start);
|
||||||
std::cout << "Time taken by " << "Canny" << ": " << duration.count() << " [" << "ms" << "]" << std::endl;
|
std::cout << "Canny" << ": " << duration.count() << " [" << "ms" << "]" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_hough(const Mat &src)
|
void test_hough(const Mat &src)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "================= Hough transform tests =================");
|
Mat dst, blurred, edge;
|
||||||
|
|
||||||
Mat dst, gray, edge;
|
blur(src, blurred, Size(3,3));
|
||||||
|
Canny(blurred, edge, 10, 30, 3, false);
|
||||||
// Grayscale and edge detection
|
|
||||||
cvtColor(src, gray, COLOR_BGR2GRAY);
|
|
||||||
Canny(gray, edge, 8, 24, 3, false);
|
|
||||||
|
|
||||||
// hough
|
// hough
|
||||||
vector<Vec2f> lines;
|
vector<Vec2f> lines;
|
||||||
BENCHMARK_MS("HoughLines", REPEAT, HoughLines, edge, lines, 1, CV_PI/180, 200, 0, 0, 0, CV_PI);
|
BENCHMARK_MS("HoughLines", REPEAT, HoughLines, edge, lines, 1, CV_PI/180, 100, 0, 0, 0, CV_PI);
|
||||||
cout << lines.size() << " lines were detected" << endl;
|
|
||||||
|
|
||||||
// probabilistic hough
|
// probabilistic hough
|
||||||
vector<Vec4i> linesP;
|
vector<Vec4i> linesP;
|
||||||
BENCHMARK_MS("HoughLineP", REPEAT, HoughLinesP, edge, linesP, 1, CV_PI/180, 200, 30, 10);
|
BENCHMARK_MS("HoughLineP", REPEAT, HoughLinesP, edge, linesP, 1, CV_PI/180, 100, 80, 0);
|
||||||
cout << linesP.size() << " lines were detected" << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void app_main(void)
|
void app_main(void)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "Starting main");
|
ESP_LOGI(TAG, "Starting main");
|
||||||
@ -197,46 +127,59 @@ void app_main(void)
|
|||||||
/* SPIFFS init */
|
/* SPIFFS init */
|
||||||
init_spiffs();
|
init_spiffs();
|
||||||
|
|
||||||
/* Basics Matrices tests */
|
/* Read the images for the tests */
|
||||||
test_basics();
|
Mat src = read_image_specific_res("/spiffs/"+images_res[0]+".png");
|
||||||
|
Mat src2 = read_image_specific_res("/spiffs/"+images_res[1]+".png");
|
||||||
/* Test the spiffs read/write */
|
Mat src3 = read_image_specific_res("/spiffs/"+images_res[2]+".png");
|
||||||
test_spiffs();
|
vector<Mat> matrices;
|
||||||
disp_mem_infos();
|
matrices.push_back(src);
|
||||||
|
matrices.push_back(src2);
|
||||||
|
matrices.push_back(src3);
|
||||||
|
|
||||||
/* Read an image for the next tests */
|
// TODO: rename measure.hpp in benchmark.hpp and add printHeader method
|
||||||
Mat src = imread(imageFileName, IMREAD_COLOR);
|
// TODO: make an array of function and call them from a single loop
|
||||||
if(src.empty()) {
|
|
||||||
ESP_LOGW(TAG, "cannot read the image: %s", imageFileName.c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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 */
|
/* Conversions and thresholds tests */
|
||||||
test_thresholds(src);
|
printf("============================== Thresholding tests ==============================\n");
|
||||||
disp_mem_infos();
|
for(int i = 0; i < NB_IMAGES; i++) {
|
||||||
|
printf("Image %s -------------------------\n", images_res[i].c_str());
|
||||||
|
test_thresholds(matrices[i]);
|
||||||
|
}
|
||||||
|
|
||||||
/* Blurring tests */
|
/* Blurring tests */
|
||||||
test_blurring(src);
|
printf("================================ Blurring tests ================================\n");
|
||||||
disp_mem_infos();
|
for(int i = 0; i < NB_IMAGES; i++) {
|
||||||
|
printf("Image %s -------------------------\n", images_res[i].c_str());
|
||||||
|
test_blurring(matrices[i]);
|
||||||
|
}
|
||||||
|
|
||||||
/* Morphology transformations */
|
/* Morphology transformations */
|
||||||
test_morphology_transform(src);
|
printf("======================= Morphology transformations tests =======================\n");
|
||||||
disp_mem_infos();
|
for(int i = 0; i < NB_IMAGES; i++) {
|
||||||
|
printf("Image %s -------------------------\n", images_res[i].c_str());
|
||||||
|
test_morphology_transform(matrices[i]);
|
||||||
|
}
|
||||||
|
|
||||||
/* Edge detection */
|
/* Edge detection */
|
||||||
test_edge_detect(src);
|
printf("================================ Resizing tests ================================\n");
|
||||||
disp_mem_infos();
|
for(int i = 0; i < NB_IMAGES; i++) {
|
||||||
|
printf("Image %s -------------------------\n", images_res[i].c_str());
|
||||||
|
test_resize(matrices[i]);
|
||||||
|
}
|
||||||
|
|
||||||
/* Image resizing */
|
/* Image resizing */
|
||||||
test_resize(src);
|
printf("============================= Edge detection tests =============================\n");
|
||||||
disp_mem_infos();
|
for(int i = 0; i < NB_IMAGES; i++) {
|
||||||
|
printf("Image %s -------------------------\n", images_res[i].c_str());
|
||||||
wait_msec(500);
|
test_edge_detect(matrices[i]);
|
||||||
|
}
|
||||||
|
|
||||||
/* Hough transform */
|
/* Hough transform */
|
||||||
test_hough(src);
|
printf("============================= Hough transform tests ============================\n");
|
||||||
disp_mem_infos();
|
for(int i = 0; i < NB_IMAGES; i++) {
|
||||||
|
printf("Image %s -------------------------\n", images_res[i].c_str());
|
||||||
|
test_hough(matrices[i]);
|
||||||
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "End of main");
|
ESP_LOGI(TAG, "End of main");
|
||||||
}
|
}
|
@ -23,14 +23,15 @@
|
|||||||
*
|
*
|
||||||
* Usage examples:
|
* Usage examples:
|
||||||
* - without macro:
|
* - without macro:
|
||||||
* measure<chrono::milliseconds>::benchmark("ms", "medianBlur", repeat, medianBlur, src, dst, 9);
|
* measure<std::chrono::milliseconds>::benchmark("ms", "medianBlur", repeat, medianBlur, src, dst, 9);
|
||||||
* - with macro:
|
* - with macro:
|
||||||
* BENCHMARK_MS("medianBlur", repeat, medianBlur, src, dst, 9);
|
* BENCHMARK_MS("medianBlur", repeat, medianBlur, src, dst, 9);
|
||||||
*/
|
*/
|
||||||
#define BENCHMARK_NS(name, repeat, fct, ...) measure<chrono::nanoseconds>::benchmark("ns", name, repeat, fct, __VA_ARGS__)
|
#define BENCHMARK_NS(name, repeat, fct, ...) measure<std::chrono::nanoseconds>::benchmark("ns", name, repeat, fct, __VA_ARGS__)
|
||||||
#define BENCHMARK_US(name, repeat, fct, ...) measure<chrono::microseconds>::benchmark("us", name, repeat, fct, __VA_ARGS__)
|
#define BENCHMARK_US(name, repeat, fct, ...) measure<std::chrono::microseconds>::benchmark("us", name, repeat, fct, __VA_ARGS__)
|
||||||
#define BENCHMARK_MS(name, repeat, fct, ...) measure<chrono::milliseconds>::benchmark("ms", name, repeat, fct, __VA_ARGS__)
|
#define BENCHMARK_MS(name, repeat, fct, ...) measure<std::chrono::milliseconds>::benchmark("ms", name, repeat, fct, __VA_ARGS__)
|
||||||
#define BENCHMARK_S(name, repeat, fct, ...) measure<chrono::seconds>::benchmark("s", name, repeat, fct, __VA_ARGS__)
|
#define BENCHMARK_S(name, repeat, fct, ...) measure<std::chrono::seconds>::benchmark("s", name, repeat, fct, __VA_ARGS__)
|
||||||
|
|
||||||
|
|
||||||
#define fw(what) std::forward<decltype(what)>(what)
|
#define fw(what) std::forward<decltype(what)>(what)
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ struct measure
|
|||||||
avg += duration(func, (args)...);
|
avg += duration(func, (args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Time taken by " << name << ": " << (avg / repeat).count() << " [" << unit << "]" << std::endl;
|
std::cout << name << "\t " << (avg / repeat).count() << " [" << unit << "]" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
nvs, data, nvs, 0x9000, 0x6000,
|
nvs, data, nvs, 0x9000, 0x6000,
|
||||||
phy_init, data, phy, 0xf000, 0x1000,
|
phy_init, data, phy, 0xf000, 0x1000,
|
||||||
factory, app, factory, 0x10000, 2M,
|
factory, app, factory, 0x10000, 2M,
|
||||||
storage, data, spiffs, , 1M,
|
storage, data, spiffs, , 1M,
|
||||||
|
|
BIN
esp32/examples/esp_opencv_tests/spiffs_images/160x120.png
Normal file
BIN
esp32/examples/esp_opencv_tests/spiffs_images/160x120.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
esp32/examples/esp_opencv_tests/spiffs_images/320x240.png
Normal file
BIN
esp32/examples/esp_opencv_tests/spiffs_images/320x240.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 120 KiB |
BIN
esp32/examples/esp_opencv_tests/spiffs_images/640x480.png
Normal file
BIN
esp32/examples/esp_opencv_tests/spiffs_images/640x480.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 392 KiB |
@ -1 +1 @@
|
|||||||
Coucou Salut
|
Coucou Salut!
|
Binary file not shown.
Before Width: | Height: | Size: 109 KiB |
Binary file not shown.
Before Width: | Height: | Size: 35 KiB |
Reference in New Issue
Block a user