mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Android OpenCL support
This commit is contained in:
parent
36915db699
commit
b29f73d5e0
@ -177,6 +177,55 @@ static void *GetHandle(const char *file)
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
|
||||||
|
static const char *defaultAndroidPaths[] = {
|
||||||
|
"libOpenCL.so",
|
||||||
|
"/system/lib64/libOpenCL.so",
|
||||||
|
"/system/vendor/lib64/libOpenCL.so",
|
||||||
|
"/system/vendor/lib64/egl/libGLES_mali.so",
|
||||||
|
"/system/vendor/lib64/libPVROCL.so",
|
||||||
|
"/data/data/org.pocl.libs/files/lib64/libpocl.so",
|
||||||
|
"/system/lib/libOpenCL.so",
|
||||||
|
"/system/vendor/lib/libOpenCL.so",
|
||||||
|
"/system/vendor/lib/egl/libGLES_mali.so",
|
||||||
|
"/system/vendor/lib/libPVROCL.so",
|
||||||
|
"/data/data/org.pocl.libs/files/lib/libpocl.so"
|
||||||
|
};
|
||||||
|
|
||||||
|
static void* GetProcAddress(const char* name)
|
||||||
|
{
|
||||||
|
static bool initialized = false;
|
||||||
|
static void* handle = NULL;
|
||||||
|
if (!handle && !initialized)
|
||||||
|
{
|
||||||
|
cv::AutoLock lock(cv::getInitializationMutex());
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
bool foundOpenCL = false;
|
||||||
|
for (unsigned int i = 0; i < (sizeof(defaultAndroidPaths)/sizeof(char*)); i++)
|
||||||
|
{
|
||||||
|
const char* path = (i==0) ? getRuntimePath(defaultAndroidPaths[i]) : defaultAndroidPaths[i];
|
||||||
|
if (path) {
|
||||||
|
handle = GetHandle(path);
|
||||||
|
if (handle) {
|
||||||
|
foundOpenCL = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
initialized = true;
|
||||||
|
if (!foundOpenCL)
|
||||||
|
fprintf(stderr, ERROR_MSG_CANT_LOAD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!handle)
|
||||||
|
return NULL;
|
||||||
|
return dlsym(handle, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // NOT __ANDROID__
|
||||||
|
|
||||||
static void* GetProcAddress(const char* name)
|
static void* GetProcAddress(const char* name)
|
||||||
{
|
{
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
@ -206,6 +255,8 @@ static void* GetProcAddress(const char* name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
return dlsym(handle, name);
|
return dlsym(handle, name);
|
||||||
}
|
}
|
||||||
|
#endif // __ANDROID__
|
||||||
|
|
||||||
#define CV_CL_GET_PROC_ADDRESS(name) GetProcAddress(name)
|
#define CV_CL_GET_PROC_ADDRESS(name) GetProcAddress(name)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -158,6 +158,7 @@ class Builder:
|
|||||||
self.debug = True if config.debug else False
|
self.debug = True if config.debug else False
|
||||||
self.debug_info = True if config.debug_info else False
|
self.debug_info = True if config.debug_info else False
|
||||||
self.no_samples_build = True if config.no_samples_build else False
|
self.no_samples_build = True if config.no_samples_build else False
|
||||||
|
self.opencl = True if config.opencl else False
|
||||||
|
|
||||||
def get_cmake(self):
|
def get_cmake(self):
|
||||||
if not self.config.use_android_buildtools and check_executable(['cmake', '--version']):
|
if not self.config.use_android_buildtools and check_executable(['cmake', '--version']):
|
||||||
@ -236,6 +237,9 @@ class Builder:
|
|||||||
if self.debug_info: # Release with debug info
|
if self.debug_info: # Release with debug info
|
||||||
cmake_vars['BUILD_WITH_DEBUG_INFO'] = "ON"
|
cmake_vars['BUILD_WITH_DEBUG_INFO'] = "ON"
|
||||||
|
|
||||||
|
if self.opencl:
|
||||||
|
cmake_vars['WITH_OPENCL'] = "ON"
|
||||||
|
|
||||||
if self.config.modules_list is not None:
|
if self.config.modules_list is not None:
|
||||||
cmd.append("-DBUILD_LIST='%s'" % self.config.modules_list)
|
cmd.append("-DBUILD_LIST='%s'" % self.config.modules_list)
|
||||||
|
|
||||||
@ -354,6 +358,7 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument('--debug', action="store_true", help="Build 'Debug' binaries (CMAKE_BUILD_TYPE=Debug)")
|
parser.add_argument('--debug', action="store_true", help="Build 'Debug' binaries (CMAKE_BUILD_TYPE=Debug)")
|
||||||
parser.add_argument('--debug_info', action="store_true", help="Build with debug information (useful for Release mode: BUILD_WITH_DEBUG_INFO=ON)")
|
parser.add_argument('--debug_info', action="store_true", help="Build with debug information (useful for Release mode: BUILD_WITH_DEBUG_INFO=ON)")
|
||||||
parser.add_argument('--no_samples_build', action="store_true", help="Do not build samples (speeds up build)")
|
parser.add_argument('--no_samples_build', action="store_true", help="Do not build samples (speeds up build)")
|
||||||
|
parser.add_argument('--opencl', action="store_true", help="Enable OpenCL support")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
log.basicConfig(format='%(message)s', level=log.DEBUG)
|
log.basicConfig(format='%(message)s', level=log.DEBUG)
|
||||||
|
Loading…
Reference in New Issue
Block a user