mirror of
https://gitcode.com/gh_mirrors/es/esp32-opencv.git
synced 2025-08-16 11:55:00 +08:00
Compilation success with pthreads enabled
- The project can be compiled with pthread enabled on opencv build - FIXME: Needed to add a call to pthread_cond_init() in the main component for the linker to work. The pthread_cond implementation is done in esp-idf/components/pthreads/ - The optimization hasn't yet enhanced the benchmark performances, hasn't found why for now
This commit is contained in:
18
README.md
18
README.md
@ -305,6 +305,12 @@ if(ESP32)
|
|||||||
endif()
|
endif()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The checks for system libraries (`libpthread`, `libdl`, `libm`, `librt`) are also activated by changing the line 607 of the `CMakeList.txt` file:
|
||||||
|
|
||||||
|
```cmake
|
||||||
|
if(UNIX OF ESP32)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
The `cmake` command is run, leading to the following errors:
|
The `cmake` command is run, leading to the following errors:
|
||||||
@ -512,7 +518,17 @@ The library is compiled in the `3rdparty/` folder. Copy this folder into the esp
|
|||||||
|
|
||||||
## Adding parallel support
|
## Adding parallel support
|
||||||
|
|
||||||
TODO
|
To add loop parallelization on the 2 cores of the esp32, the following modifications are done:
|
||||||
|
|
||||||
|
* Changed cmake command with `-DWITH_PTHREADS_PF=ON`
|
||||||
|
* Had to temporary add a pthread_cond usage in the main component for the link to work (otherwise had an *undefined reference to pthread_cond_* functions)
|
||||||
|
* The pthread_cond implementation is in the esp-idf pthread component. Haven't found yet how to link it
|
||||||
|
* In `parallel.cpp` function `getNumberOfCPUs`:
|
||||||
|
* For now, couldn't make `sysconf` function to work (to get the number of cpus), so returns 2 if ESP32 is defined
|
||||||
|
* In idf menuconfig:
|
||||||
|
* set pthread default stack size to 8192
|
||||||
|
|
||||||
|
These modifications haven't improved the performances on the benchmark for now.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BIN
esp32/lib/opencv/3rdparty/liblibpng.a
vendored
BIN
esp32/lib/opencv/3rdparty/liblibpng.a
vendored
Binary file not shown.
BIN
esp32/lib/opencv/3rdparty/libzlib.a
vendored
BIN
esp32/lib/opencv/3rdparty/libzlib.a
vendored
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -950,6 +950,10 @@ int cv::getNumberOfCPUs(void)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
ncpus = 2; // TODO: Only for ESP32D0WD
|
||||||
|
#endif
|
||||||
|
|
||||||
return ncpus != 0 ? ncpus : 1;
|
return ncpus != 0 ? ncpus : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,13 +7,7 @@
|
|||||||
#include "parallel_impl.hpp"
|
#include "parallel_impl.hpp"
|
||||||
|
|
||||||
#ifdef HAVE_PTHREADS_PF
|
#ifdef HAVE_PTHREADS_PF
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <opencv2/core/utils/configuration.private.hpp>
|
#include <opencv2/core/utils/configuration.private.hpp>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user