本文参考链接http://www.cnblogs.com/hrlnw/p/4720977.html
1. 本机配置
windows7 64为
cmake 版本 3.1.0
opencv版本 3.1.0
2. 基本步骤
1) 下载opencv3.1.0 官方源码 https://github.com/Itseez/opencv/archive/3.1.0.zip
2) 下载cmake
3) 修改opencv根目录下的CMakeLists.txt,修改WITH_OPENCL
OCV_OPTION(WITH_OPENCL "Include OpenCL Runtime support" ON )
4) 修改opencl的文件使之支持android : 在\modules\core\src\opencl\runtime\opencl_core.cpp文件修改为
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the OpenCV Foundation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "../../precomp.hpp"
#if defined(HAVE_OPENCL) && !defined(HAVE_OPENCL_STATIC)
#include "opencv2/core.hpp" // CV_Error
#include "opencv2/core/opencl/runtime/opencl_core.hpp"
#define OPENCL_FUNC_TO_CHECK_1_1 "clEnqueueReadBufferRect"
#define ERROR_MSG_CANT_LOAD "Failed to load OpenCL runtime\n"
#define ERROR_MSG_INVALID_VERSION "Failed to load OpenCL runtime (expected version 1.1+)\n"
#if defined(__APPLE__)
#include <dlfcn.h>
static void* AppleCLGetProcAddress(const char* name)
{
static bool initialized = false;
static void* handle = NULL;
if (!handle)
{
if(!initialized)
{
initialized = true;
const char* path = "/System/Library/Frameworks/OpenCL.framework/Versions/Current/OpenCL";
const char* envPath = getenv("OPENCV_OPENCL_RUNTIME");
if (envPath)
path = envPath;
handle = dlopen(oclpath, RTLD_LAZY | RTLD_GLOBAL);
if (handle == NULL)
{
if (envPath)
fprintf(stderr, ERROR_MSG_CANT_LOAD);
}
else if (dlsym(handle, OPENCL_FUNC_TO_