[Other] Add global SetProcLibCpuNumThreads method (#513)

[FlyCV] Add global SetProcLibCpuNumThreads method
This commit is contained in:
DefTruth
2022-11-07 19:45:12 +08:00
committed by GitHub
parent 3589c0fa94
commit ff24ed6a54
4 changed files with 14 additions and 2 deletions

View File

@@ -54,5 +54,12 @@ void DisableFlyCV() {
<< DefaultProcLib::default_lib << std::endl; << DefaultProcLib::default_lib << std::endl;
} }
void SetProcLibCpuNumThreads(int threads) {
cv::setNumThreads(threads);
#ifdef ENABLE_FLYCV
fcv::set_thread_num(threads);
#endif
}
} // namespace vision } // namespace vision
} // namespace fastdeploy } // namespace fastdeploy

View File

@@ -31,6 +31,11 @@ FASTDEPLOY_DECL void EnableFlyCV();
/// Disable using FlyCV to process image while deploy vision models. /// Disable using FlyCV to process image while deploy vision models.
FASTDEPLOY_DECL void DisableFlyCV(); FASTDEPLOY_DECL void DisableFlyCV();
/*! @brief Set the cpu num threads of ProcLib. The cpu num threads
* of FlyCV and OpenCV is 2 by default.
*/
FASTDEPLOY_DECL void SetProcLibCpuNumThreads(int threads);
class FASTDEPLOY_DECL Processor { class FASTDEPLOY_DECL Processor {
public: public:
// default_lib has the highest priority // default_lib has the highest priority

View File

@@ -46,7 +46,7 @@ dependencies {
def archives = [ def archives = [
[ [
'src' : 'https://bj.bcebos.com/fastdeploy/test/fastdeploy-android-0.5.0-shared-dev.tgz', 'src' : 'https://bj.bcebos.com/fastdeploy/test/fastdeploy-android-latest-shared-dev.tgz',
'dest': 'libs' 'dest': 'libs'
] ]
] ]

View File

@@ -12,7 +12,7 @@ project("fastdeploy_jni")
# You can define multiple libraries, and CMake builds them for you. # You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK. # Gradle automatically packages shared libraries with your APK.
set(FastDeploy_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/fastdeploy-android-0.5.0-shared-dev") set(FastDeploy_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/fastdeploy-android-latest-shared-dev")
find_package(FastDeploy REQUIRED) find_package(FastDeploy REQUIRED)