Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
6846f881
Commit
6846f881
authored
Mar 16, 2013
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move OpenCL SURF to nonfree module
parent
91ac9688
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
217 additions
and
242 deletions
+217
-242
CMakeLists.txt
modules/nonfree/CMakeLists.txt
+1
-1
ocl.hpp
modules/nonfree/include/opencv2/nonfree/ocl.hpp
+125
-0
surf.cl
modules/nonfree/src/opencl/surf.cl
+0
-0
precomp.hpp
modules/nonfree/src/precomp.hpp
+5
-0
surf.ocl.cpp
modules/nonfree/src/surf.ocl.cpp
+17
-16
CMakeLists.txt
modules/ocl/CMakeLists.txt
+1
-1
ocl.hpp
modules/ocl/include/opencv2/ocl/ocl.hpp
+9
-159
util.hpp
modules/ocl/include/opencv2/ocl/private/util.hpp
+55
-12
canny.cpp
modules/ocl/src/canny.cpp
+0
-2
filtering.cpp
modules/ocl/src/filtering.cpp
+1
-2
hog.cpp
modules/ocl/src/hog.cpp
+1
-1
interpolate_frames.cpp
modules/ocl/src/interpolate_frames.cpp
+0
-2
mcwutil.cpp
modules/ocl/src/mcwutil.cpp
+1
-1
precomp.hpp
modules/ocl/src/precomp.hpp
+1
-44
pyrlk.cpp
modules/ocl/src/pyrlk.cpp
+0
-1
No files found.
modules/nonfree/CMakeLists.txt
View file @
6846f881
...
@@ -3,7 +3,7 @@ if(BUILD_ANDROID_PACKAGE)
...
@@ -3,7 +3,7 @@ if(BUILD_ANDROID_PACKAGE)
endif
()
endif
()
set
(
the_description
"Functionality with possible limitations on the use"
)
set
(
the_description
"Functionality with possible limitations on the use"
)
ocv_add_module
(
nonfree opencv_imgproc opencv_features2d opencv_calib3d OPTIONAL opencv_gpu
)
ocv_add_module
(
nonfree opencv_imgproc opencv_features2d opencv_calib3d OPTIONAL opencv_gpu
opencv_ocl
)
ocv_module_include_directories
()
ocv_module_include_directories
()
if
(
HAVE_CUDA AND HAVE_opencv_gpu
)
if
(
HAVE_CUDA AND HAVE_opencv_gpu
)
...
...
modules/nonfree/include/opencv2/nonfree/ocl.hpp
0 → 100644
View file @
6846f881
/*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) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2013, OpenCV Foundation, 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 Intel Corporation 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*/
#ifndef __OPENCV_NONFREE_OCL_HPP__
#define __OPENCV_NONFREE_OCL_HPP__
#include "opencv2/ocl/ocl.hpp"
namespace
cv
{
namespace
ocl
{
//! Speeded up robust features, port from GPU module.
////////////////////////////////// SURF //////////////////////////////////////////
class
CV_EXPORTS
SURF_OCL
{
public
:
enum
KeypointLayout
{
X_ROW
=
0
,
Y_ROW
,
LAPLACIAN_ROW
,
OCTAVE_ROW
,
SIZE_ROW
,
ANGLE_ROW
,
HESSIAN_ROW
,
ROWS_COUNT
};
//! the default constructor
SURF_OCL
();
//! the full constructor taking all the necessary parameters
explicit
SURF_OCL
(
double
_hessianThreshold
,
int
_nOctaves
=
4
,
int
_nOctaveLayers
=
2
,
bool
_extended
=
false
,
float
_keypointsRatio
=
0.01
f
,
bool
_upright
=
false
);
//! returns the descriptor size in float's (64 or 128)
int
descriptorSize
()
const
;
//! upload host keypoints to device memory
void
uploadKeypoints
(
const
vector
<
cv
::
KeyPoint
>
&
keypoints
,
oclMat
&
keypointsocl
);
//! download keypoints from device to host memory
void
downloadKeypoints
(
const
oclMat
&
keypointsocl
,
vector
<
KeyPoint
>
&
keypoints
);
//! download descriptors from device to host memory
void
downloadDescriptors
(
const
oclMat
&
descriptorsocl
,
vector
<
float
>
&
descriptors
);
//! finds the keypoints using fast hessian detector used in SURF
//! supports CV_8UC1 images
//! keypoints will have nFeature cols and 6 rows
//! keypoints.ptr<float>(X_ROW)[i] will contain x coordinate of i'th feature
//! keypoints.ptr<float>(Y_ROW)[i] will contain y coordinate of i'th feature
//! keypoints.ptr<float>(LAPLACIAN_ROW)[i] will contain laplacian sign of i'th feature
//! keypoints.ptr<float>(OCTAVE_ROW)[i] will contain octave of i'th feature
//! keypoints.ptr<float>(SIZE_ROW)[i] will contain size of i'th feature
//! keypoints.ptr<float>(ANGLE_ROW)[i] will contain orientation of i'th feature
//! keypoints.ptr<float>(HESSIAN_ROW)[i] will contain response of i'th feature
void
operator
()(
const
oclMat
&
img
,
const
oclMat
&
mask
,
oclMat
&
keypoints
);
//! finds the keypoints and computes their descriptors.
//! Optionally it can compute descriptors for the user-provided keypoints and recompute keypoints direction
void
operator
()(
const
oclMat
&
img
,
const
oclMat
&
mask
,
oclMat
&
keypoints
,
oclMat
&
descriptors
,
bool
useProvidedKeypoints
=
false
);
void
operator
()(
const
oclMat
&
img
,
const
oclMat
&
mask
,
std
::
vector
<
KeyPoint
>
&
keypoints
);
void
operator
()(
const
oclMat
&
img
,
const
oclMat
&
mask
,
std
::
vector
<
KeyPoint
>
&
keypoints
,
oclMat
&
descriptors
,
bool
useProvidedKeypoints
=
false
);
void
operator
()(
const
oclMat
&
img
,
const
oclMat
&
mask
,
std
::
vector
<
KeyPoint
>
&
keypoints
,
std
::
vector
<
float
>
&
descriptors
,
bool
useProvidedKeypoints
=
false
);
void
releaseMemory
();
// SURF parameters
float
hessianThreshold
;
int
nOctaves
;
int
nOctaveLayers
;
bool
extended
;
bool
upright
;
//! max keypoints = min(keypointsRatio * img.size().area(), 65535)
float
keypointsRatio
;
oclMat
sum
,
mask1
,
maskSum
,
intBuffer
;
oclMat
det
,
trace
;
oclMat
maxPosBuffer
;
};
}
}
#endif __OPENCV_NONFREE_OCL_HPP__
\ No newline at end of file
modules/
ocl/src/opencl/nonfree_
surf.cl
→
modules/
nonfree/src/opencl/
surf.cl
View file @
6846f881
File moved
modules/nonfree/src/precomp.hpp
View file @
6846f881
...
@@ -66,4 +66,9 @@
...
@@ -66,4 +66,9 @@
#endif
#endif
#endif
#endif
#ifdef HAVE_OPENCV_OCL
# include "opencv2/nonfree/ocl.hpp"
# include "opencv2/ocl/private/util.hpp"
#endif
#endif
#endif
modules/
ocl/src/surf
.cpp
→
modules/
nonfree/src/surf.ocl
.cpp
View file @
6846f881
...
@@ -42,10 +42,9 @@
...
@@ -42,10 +42,9 @@
// the use of this software, even if advised of the possibility of such damage.
// the use of this software, even if advised of the possibility of such damage.
//
//
//M*/
//M*/
#include <iomanip>
#include "precomp.hpp"
#include "precomp.hpp"
#include "mcwutil.hpp"
//#include "opencv2/highgui/highgui.hpp"
#ifdef HAVE_OPENCV_OCL
using
namespace
cv
;
using
namespace
cv
;
using
namespace
cv
::
ocl
;
using
namespace
cv
::
ocl
;
...
@@ -56,7 +55,7 @@ namespace cv
...
@@ -56,7 +55,7 @@ namespace cv
namespace
ocl
namespace
ocl
{
{
///////////////////////////OpenCL kernel strings///////////////////////////
///////////////////////////OpenCL kernel strings///////////////////////////
extern
const
char
*
nonfree_
surf
;
extern
const
char
*
surf
;
const
char
*
noImage2dOption
=
"-D DISABLE_IMAGE2D"
;
const
char
*
noImage2dOption
=
"-D DISABLE_IMAGE2D"
;
...
@@ -268,7 +267,7 @@ private:
...
@@ -268,7 +267,7 @@ private:
int
maxFeatures
;
int
maxFeatures
;
oclMat
counters
;
oclMat
counters
;
// texture buffers
// texture buffers
cl_mem
imgTex
;
cl_mem
imgTex
;
cl_mem
sumTex
;
cl_mem
sumTex
;
...
@@ -510,7 +509,7 @@ void SURF_OCL_Invoker::icvCalcLayerDetAndTrace_gpu(oclMat &det, oclMat &trace, i
...
@@ -510,7 +509,7 @@ void SURF_OCL_Invoker::icvCalcLayerDetAndTrace_gpu(oclMat &det, oclMat &trace, i
divUp
(
max_samples_i
,
localThreads
[
1
])
*
localThreads
[
1
]
*
(
nOctaveLayers
+
2
),
divUp
(
max_samples_i
,
localThreads
[
1
])
*
localThreads
[
1
]
*
(
nOctaveLayers
+
2
),
1
1
};
};
openCLExecuteKernelSURF
(
clCxt
,
&
nonfree_
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
openCLExecuteKernelSURF
(
clCxt
,
&
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
}
}
void
SURF_OCL_Invoker
::
icvFindMaximaInLayer_gpu
(
const
oclMat
&
det
,
const
oclMat
&
trace
,
oclMat
&
maxPosBuffer
,
oclMat
&
maxCounter
,
int
counterOffset
,
void
SURF_OCL_Invoker
::
icvFindMaximaInLayer_gpu
(
const
oclMat
&
det
,
const
oclMat
&
trace
,
oclMat
&
maxPosBuffer
,
oclMat
&
maxCounter
,
int
counterOffset
,
...
@@ -556,7 +555,7 @@ void SURF_OCL_Invoker::icvFindMaximaInLayer_gpu(const oclMat &det, const oclMat
...
@@ -556,7 +555,7 @@ void SURF_OCL_Invoker::icvFindMaximaInLayer_gpu(const oclMat &det, const oclMat
1
1
};
};
openCLExecuteKernelSURF
(
clCxt
,
&
nonfree_
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
openCLExecuteKernelSURF
(
clCxt
,
&
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
}
}
void
SURF_OCL_Invoker
::
icvInterpolateKeypoint_gpu
(
const
oclMat
&
det
,
const
oclMat
&
maxPosBuffer
,
int
maxCounter
,
void
SURF_OCL_Invoker
::
icvInterpolateKeypoint_gpu
(
const
oclMat
&
det
,
const
oclMat
&
maxPosBuffer
,
int
maxCounter
,
...
@@ -581,7 +580,7 @@ void SURF_OCL_Invoker::icvInterpolateKeypoint_gpu(const oclMat &det, const oclMa
...
@@ -581,7 +580,7 @@ void SURF_OCL_Invoker::icvInterpolateKeypoint_gpu(const oclMat &det, const oclMa
size_t
localThreads
[
3
]
=
{
3
,
3
,
3
};
size_t
localThreads
[
3
]
=
{
3
,
3
,
3
};
size_t
globalThreads
[
3
]
=
{
maxCounter
*
localThreads
[
0
],
localThreads
[
1
],
1
};
size_t
globalThreads
[
3
]
=
{
maxCounter
*
localThreads
[
0
],
localThreads
[
1
],
1
};
openCLExecuteKernelSURF
(
clCxt
,
&
nonfree_
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
openCLExecuteKernelSURF
(
clCxt
,
&
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
}
}
void
SURF_OCL_Invoker
::
icvCalcOrientation_gpu
(
const
oclMat
&
keypoints
,
int
nFeatures
)
void
SURF_OCL_Invoker
::
icvCalcOrientation_gpu
(
const
oclMat
&
keypoints
,
int
nFeatures
)
...
@@ -608,7 +607,7 @@ void SURF_OCL_Invoker::icvCalcOrientation_gpu(const oclMat &keypoints, int nFeat
...
@@ -608,7 +607,7 @@ void SURF_OCL_Invoker::icvCalcOrientation_gpu(const oclMat &keypoints, int nFeat
size_t
localThreads
[
3
]
=
{
32
,
4
,
1
};
size_t
localThreads
[
3
]
=
{
32
,
4
,
1
};
size_t
globalThreads
[
3
]
=
{
nFeatures
*
localThreads
[
0
],
localThreads
[
1
],
1
};
size_t
globalThreads
[
3
]
=
{
nFeatures
*
localThreads
[
0
],
localThreads
[
1
],
1
};
openCLExecuteKernelSURF
(
clCxt
,
&
nonfree_
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
openCLExecuteKernelSURF
(
clCxt
,
&
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
}
}
void
SURF_OCL_Invoker
::
icvSetUpright_gpu
(
const
oclMat
&
keypoints
,
int
nFeatures
)
void
SURF_OCL_Invoker
::
icvSetUpright_gpu
(
const
oclMat
&
keypoints
,
int
nFeatures
)
...
@@ -625,7 +624,7 @@ void SURF_OCL_Invoker::icvSetUpright_gpu(const oclMat &keypoints, int nFeatures)
...
@@ -625,7 +624,7 @@ void SURF_OCL_Invoker::icvSetUpright_gpu(const oclMat &keypoints, int nFeatures)
size_t
localThreads
[
3
]
=
{
256
,
1
,
1
};
size_t
localThreads
[
3
]
=
{
256
,
1
,
1
};
size_t
globalThreads
[
3
]
=
{
saturate_cast
<
size_t
>
(
nFeatures
),
1
,
1
};
size_t
globalThreads
[
3
]
=
{
saturate_cast
<
size_t
>
(
nFeatures
),
1
,
1
};
openCLExecuteKernelSURF
(
clCxt
,
&
nonfree_
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
openCLExecuteKernelSURF
(
clCxt
,
&
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
}
}
...
@@ -665,7 +664,7 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
...
@@ -665,7 +664,7 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
_img
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
_img
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
_img
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
_img
.
step
));
openCLExecuteKernelSURF
(
clCxt
,
&
nonfree_
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
openCLExecuteKernelSURF
(
clCxt
,
&
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
kernelName
=
"normalize_descriptors64"
;
kernelName
=
"normalize_descriptors64"
;
...
@@ -679,7 +678,7 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
...
@@ -679,7 +678,7 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
descriptors
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
descriptors
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
descriptors
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
descriptors
.
step
));
openCLExecuteKernelSURF
(
clCxt
,
&
nonfree_
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
openCLExecuteKernelSURF
(
clCxt
,
&
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
}
}
else
else
{
{
...
@@ -707,8 +706,8 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
...
@@ -707,8 +706,8 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
_img
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
_img
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
_img
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
_img
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
_img
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
_img
.
step
));
openCLExecuteKernelSURF
(
clCxt
,
&
nonfree_
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
openCLExecuteKernelSURF
(
clCxt
,
&
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
kernelName
=
"normalize_descriptors128"
;
kernelName
=
"normalize_descriptors128"
;
...
@@ -721,7 +720,9 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
...
@@ -721,7 +720,9 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
args
.
clear
();
args
.
clear
();
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
descriptors
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
descriptors
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
descriptors
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
descriptors
.
step
));
openCLExecuteKernelSURF
(
clCxt
,
&
nonfree_
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
openCLExecuteKernelSURF
(
clCxt
,
&
surf
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
);
}
}
}
}
#endif //HAVE_OPENCV_OCL
modules/ocl/CMakeLists.txt
View file @
6846f881
...
@@ -3,5 +3,5 @@ if(NOT HAVE_OPENCL)
...
@@ -3,5 +3,5 @@ if(NOT HAVE_OPENCL)
endif
()
endif
()
set
(
the_description
"OpenCL-accelerated Computer Vision"
)
set
(
the_description
"OpenCL-accelerated Computer Vision"
)
ocv_define_module
(
ocl opencv_core opencv_imgproc opencv_features2d opencv_objdetect opencv_video
opencv_nonfree
)
ocv_define_module
(
ocl opencv_core opencv_imgproc opencv_features2d opencv_objdetect opencv_video
)
ocv_warnings_disable
(
CMAKE_CXX_FLAGS -Wshadow
)
ocv_warnings_disable
(
CMAKE_CXX_FLAGS -Wshadow
)
modules/ocl/include/opencv2/ocl/ocl.hpp
View file @
6846f881
...
@@ -69,28 +69,28 @@ namespace cv
...
@@ -69,28 +69,28 @@ namespace cv
enum
DevMemRW
enum
DevMemRW
{
{
DEVICE_MEM_R_W
=
0
,
DEVICE_MEM_R_W
=
0
,
DEVICE_MEM_R_ONLY
,
DEVICE_MEM_R_ONLY
,
DEVICE_MEM_W_ONLY
DEVICE_MEM_W_ONLY
};
};
enum
DevMemType
enum
DevMemType
{
{
DEVICE_MEM_DEFAULT
=
0
,
DEVICE_MEM_DEFAULT
=
0
,
DEVICE_MEM_AHP
,
//alloc host pointer
DEVICE_MEM_AHP
,
//alloc host pointer
DEVICE_MEM_UHP
,
//use host pointer
DEVICE_MEM_UHP
,
//use host pointer
DEVICE_MEM_CHP
,
//copy host pointer
DEVICE_MEM_CHP
,
//copy host pointer
DEVICE_MEM_PM
//persistent memory
DEVICE_MEM_PM
//persistent memory
};
};
//Get the global device memory and read/write type
//Get the global device memory and read/write type
//return 1 if unified memory system supported, otherwise return 0
//return 1 if unified memory system supported, otherwise return 0
CV_EXPORTS
int
getDevMemType
(
DevMemRW
&
rw_type
,
DevMemType
&
mem_type
);
CV_EXPORTS
int
getDevMemType
(
DevMemRW
&
rw_type
,
DevMemType
&
mem_type
);
//Set the global device memory and read/write type,
//Set the global device memory and read/write type,
//the newly generated oclMat will all use this type
//the newly generated oclMat will all use this type
//return -1 if the target type is unsupported, otherwise return 0
//return -1 if the target type is unsupported, otherwise return 0
CV_EXPORTS
int
setDevMemType
(
DevMemRW
rw_type
=
DEVICE_MEM_R_W
,
DevMemType
mem_type
=
DEVICE_MEM_DEFAULT
);
CV_EXPORTS
int
setDevMemType
(
DevMemRW
rw_type
=
DEVICE_MEM_R_W
,
DevMemType
mem_type
=
DEVICE_MEM_DEFAULT
);
//this class contains ocl runtime information
//this class contains ocl runtime information
class
CV_EXPORTS
Info
class
CV_EXPORTS
Info
...
@@ -135,7 +135,7 @@ namespace cv
...
@@ -135,7 +135,7 @@ namespace cv
//////////////////////////////// OpenCL context ////////////////////////
//////////////////////////////// OpenCL context ////////////////////////
//This is a global singleton class used to represent a OpenCL context.
//This is a global singleton class used to represent a OpenCL context.
class
Context
class
C
V_EXPORTS
C
ontext
{
{
protected
:
protected
:
Context
();
Context
();
...
@@ -1073,156 +1073,6 @@ namespace cv
...
@@ -1073,156 +1073,6 @@ namespace cv
};
};
//! Speeded up robust features, port from GPU module.
////////////////////////////////// SURF //////////////////////////////////////////
class
CV_EXPORTS
SURF_OCL
{
public
:
enum
KeypointLayout
{
X_ROW
=
0
,
Y_ROW
,
LAPLACIAN_ROW
,
OCTAVE_ROW
,
SIZE_ROW
,
ANGLE_ROW
,
HESSIAN_ROW
,
ROWS_COUNT
};
//! the default constructor
SURF_OCL
();
//! the full constructor taking all the necessary parameters
explicit
SURF_OCL
(
double
_hessianThreshold
,
int
_nOctaves
=
4
,
int
_nOctaveLayers
=
2
,
bool
_extended
=
false
,
float
_keypointsRatio
=
0.01
f
,
bool
_upright
=
false
);
//! returns the descriptor size in float's (64 or 128)
int
descriptorSize
()
const
;
//! upload host keypoints to device memory
void
uploadKeypoints
(
const
vector
<
cv
::
KeyPoint
>
&
keypoints
,
oclMat
&
keypointsocl
);
//! download keypoints from device to host memory
void
downloadKeypoints
(
const
oclMat
&
keypointsocl
,
vector
<
KeyPoint
>
&
keypoints
);
//! download descriptors from device to host memory
void
downloadDescriptors
(
const
oclMat
&
descriptorsocl
,
vector
<
float
>
&
descriptors
);
//! finds the keypoints using fast hessian detector used in SURF
//! supports CV_8UC1 images
//! keypoints will have nFeature cols and 6 rows
//! keypoints.ptr<float>(X_ROW)[i] will contain x coordinate of i'th feature
//! keypoints.ptr<float>(Y_ROW)[i] will contain y coordinate of i'th feature
//! keypoints.ptr<float>(LAPLACIAN_ROW)[i] will contain laplacian sign of i'th feature
//! keypoints.ptr<float>(OCTAVE_ROW)[i] will contain octave of i'th feature
//! keypoints.ptr<float>(SIZE_ROW)[i] will contain size of i'th feature
//! keypoints.ptr<float>(ANGLE_ROW)[i] will contain orientation of i'th feature
//! keypoints.ptr<float>(HESSIAN_ROW)[i] will contain response of i'th feature
void
operator
()(
const
oclMat
&
img
,
const
oclMat
&
mask
,
oclMat
&
keypoints
);
//! finds the keypoints and computes their descriptors.
//! Optionally it can compute descriptors for the user-provided keypoints and recompute keypoints direction
void
operator
()(
const
oclMat
&
img
,
const
oclMat
&
mask
,
oclMat
&
keypoints
,
oclMat
&
descriptors
,
bool
useProvidedKeypoints
=
false
);
void
operator
()(
const
oclMat
&
img
,
const
oclMat
&
mask
,
std
::
vector
<
KeyPoint
>
&
keypoints
);
void
operator
()(
const
oclMat
&
img
,
const
oclMat
&
mask
,
std
::
vector
<
KeyPoint
>
&
keypoints
,
oclMat
&
descriptors
,
bool
useProvidedKeypoints
=
false
);
void
operator
()(
const
oclMat
&
img
,
const
oclMat
&
mask
,
std
::
vector
<
KeyPoint
>
&
keypoints
,
std
::
vector
<
float
>
&
descriptors
,
bool
useProvidedKeypoints
=
false
);
void
releaseMemory
();
// SURF parameters
float
hessianThreshold
;
int
nOctaves
;
int
nOctaveLayers
;
bool
extended
;
bool
upright
;
//! max keypoints = min(keypointsRatio * img.size().area(), 65535)
float
keypointsRatio
;
oclMat
sum
,
mask1
,
maskSum
,
intBuffer
;
oclMat
det
,
trace
;
oclMat
maxPosBuffer
;
};
////////////////////////feature2d_ocl/////////////////
////////////////////////feature2d_ocl/////////////////
/****************************************************************************************\
/****************************************************************************************\
* Distance *
* Distance *
...
...
modules/ocl/
src/mcw
util.hpp
→
modules/ocl/
include/opencv2/ocl/private/
util.hpp
View file @
6846f881
...
@@ -43,39 +43,82 @@
...
@@ -43,39 +43,82 @@
//
//
//M*/
//M*/
#ifndef _
OPENCV_MCWUTIL
_
#ifndef _
_OPENCV_OCL_PRIVATE_UTIL_
_
#define _
OPENCV_MCWUTIL
_
#define _
_OPENCV_OCL_PRIVATE_UTIL_
_
#include "precomp.hpp"
#include "opencv2/ocl/ocl.hpp"
using
namespace
std
;
#if defined __APPLE__
#include <OpenCL/OpenCL.h>
#else
#include <CL/opencl.h>
#endif
namespace
cv
namespace
cv
{
{
namespace
ocl
namespace
ocl
{
{
///////////////////////////OpenCL call wrappers////////////////////////////
void
CV_EXPORTS
openCLMallocPitch
(
Context
*
clCxt
,
void
**
dev_ptr
,
size_t
*
pitch
,
size_t
widthInBytes
,
size_t
height
);
void
CV_EXPORTS
openCLMallocPitchEx
(
Context
*
clCxt
,
void
**
dev_ptr
,
size_t
*
pitch
,
size_t
widthInBytes
,
size_t
height
,
DevMemRW
rw_type
,
DevMemType
mem_type
);
void
CV_EXPORTS
openCLMemcpy2D
(
Context
*
clCxt
,
void
*
dst
,
size_t
dpitch
,
const
void
*
src
,
size_t
spitch
,
size_t
width
,
size_t
height
,
enum
openCLMemcpyKind
kind
,
int
channels
=
-
1
);
void
CV_EXPORTS
openCLCopyBuffer2D
(
Context
*
clCxt
,
void
*
dst
,
size_t
dpitch
,
int
dst_offset
,
const
void
*
src
,
size_t
spitch
,
size_t
width
,
size_t
height
,
int
src_offset
);
void
CV_EXPORTS
openCLFree
(
void
*
devPtr
);
cl_mem
CV_EXPORTS
openCLCreateBuffer
(
Context
*
clCxt
,
size_t
flag
,
size_t
size
);
void
CV_EXPORTS
openCLReadBuffer
(
Context
*
clCxt
,
cl_mem
dst_buffer
,
void
*
host_buffer
,
size_t
size
);
cl_kernel
CV_EXPORTS
openCLGetKernelFromSource
(
const
Context
*
clCxt
,
const
char
**
source
,
std
::
string
kernelName
);
cl_kernel
CV_EXPORTS
openCLGetKernelFromSource
(
const
Context
*
clCxt
,
const
char
**
source
,
std
::
string
kernelName
,
const
char
*
build_options
);
void
CV_EXPORTS
openCLVerifyKernel
(
const
Context
*
clCxt
,
cl_kernel
kernel
,
size_t
*
localThreads
);
void
CV_EXPORTS
openCLExecuteKernel
(
Context
*
clCxt
,
const
char
**
source
,
string
kernelName
,
std
::
vector
<
std
::
pair
<
size_t
,
const
void
*>
>
&
args
,
int
globalcols
,
int
globalrows
,
size_t
blockSize
=
16
,
int
kernel_expand_depth
=
-
1
,
int
kernel_expand_channel
=
-
1
);
void
CV_EXPORTS
openCLExecuteKernel_
(
Context
*
clCxt
,
const
char
**
source
,
std
::
string
kernelName
,
size_t
globalThreads
[
3
],
size_t
localThreads
[
3
],
std
::
vector
<
std
::
pair
<
size_t
,
const
void
*>
>
&
args
,
int
channels
,
int
depth
,
const
char
*
build_options
);
void
CV_EXPORTS
openCLExecuteKernel
(
Context
*
clCxt
,
const
char
**
source
,
std
::
string
kernelName
,
size_t
globalThreads
[
3
],
size_t
localThreads
[
3
],
std
::
vector
<
std
::
pair
<
size_t
,
const
void
*>
>
&
args
,
int
channels
,
int
depth
);
void
CV_EXPORTS
openCLExecuteKernel
(
Context
*
clCxt
,
const
char
**
source
,
std
::
string
kernelName
,
size_t
globalThreads
[
3
],
size_t
localThreads
[
3
],
std
::
vector
<
std
::
pair
<
size_t
,
const
void
*>
>
&
args
,
int
channels
,
int
depth
,
const
char
*
build_options
);
cl_mem
CV_EXPORTS
load_constant
(
cl_context
context
,
cl_command_queue
command_queue
,
const
void
*
value
,
const
size_t
size
);
cl_mem
CV_EXPORTS
openCLMalloc
(
cl_context
clCxt
,
size_t
size
,
cl_mem_flags
flags
,
void
*
host_ptr
);
int
CV_EXPORTS
savetofile
(
const
Context
*
clcxt
,
cl_program
&
program
,
const
char
*
fileName
);
enum
FLUSH_MODE
enum
FLUSH_MODE
{
{
CLFINISH
=
0
,
CLFINISH
=
0
,
CLFLUSH
,
CLFLUSH
,
DISABLE
DISABLE
};
};
void
openCLExecuteKernel2
(
Context
*
clCxt
,
const
char
**
source
,
string
kernelName
,
size_t
globalThreads
[
3
],
size_t
localThreads
[
3
],
vector
<
pair
<
size_t
,
const
void
*>
>
&
args
,
int
channels
,
int
depth
,
FLUSH_MODE
finish_mode
=
DISABLE
);
void
CV_EXPORTS
openCLExecuteKernel2
(
Context
*
clCxt
,
const
char
**
source
,
std
::
string
kernelName
,
size_t
globalThreads
[
3
],
void
openCLExecuteKernel2
(
Context
*
clCxt
,
const
char
**
source
,
string
kernelName
,
size_t
globalThreads
[
3
],
size_t
localThreads
[
3
],
std
::
vector
<
std
::
pair
<
size_t
,
const
void
*>
>
&
args
,
int
channels
,
int
depth
,
FLUSH_MODE
finish_mode
=
DISABLE
);
size_t
localThreads
[
3
],
vector
<
pair
<
size_t
,
const
void
*>
>
&
args
,
int
channels
,
void
CV_EXPORTS
openCLExecuteKernel2
(
Context
*
clCxt
,
const
char
**
source
,
std
::
string
kernelName
,
size_t
globalThreads
[
3
],
size_t
localThreads
[
3
],
std
::
vector
<
std
::
pair
<
size_t
,
const
void
*>
>
&
args
,
int
channels
,
int
depth
,
char
*
build_options
,
FLUSH_MODE
finish_mode
=
DISABLE
);
int
depth
,
char
*
build_options
,
FLUSH_MODE
finish_mode
=
DISABLE
);
// bind oclMat to OpenCL image textures
// bind oclMat to OpenCL image textures
// note:
// note:
// 1. there is no memory management. User need to explicitly release the resource
// 1. there is no memory management. User need to explicitly release the resource
// 2. for faster clamping, there is no buffer padding for the constructed texture
// 2. for faster clamping, there is no buffer padding for the constructed texture
cl_mem
bindTexture
(
const
oclMat
&
mat
);
cl_mem
CV_EXPORTS
bindTexture
(
const
oclMat
&
mat
);
void
releaseTexture
(
cl_mem
&
texture
);
void
CV_EXPORTS
releaseTexture
(
cl_mem
&
texture
);
// returns whether the current context supports image2d_t format or not
// returns whether the current context supports image2d_t format or not
bool
support_image2d
(
Context
*
clCxt
=
Context
::
getContext
());
bool
CV_EXPORTS
support_image2d
(
Context
*
clCxt
=
Context
::
getContext
());
}
//namespace ocl
}
//namespace ocl
}
//namespace cv
}
//namespace cv
#endif //_
OPENCV_MCWUTIL
_
#endif //_
_OPENCV_OCL_PRIVATE_UTIL_
_
modules/ocl/src/canny.cpp
View file @
6846f881
...
@@ -43,9 +43,7 @@
...
@@ -43,9 +43,7 @@
//
//
//M*/
//M*/
#include <iomanip>
#include "precomp.hpp"
#include "precomp.hpp"
#include "mcwutil.hpp"
using
namespace
cv
;
using
namespace
cv
;
using
namespace
cv
::
ocl
;
using
namespace
cv
::
ocl
;
...
...
modules/ocl/src/filtering.cpp
View file @
6846f881
...
@@ -48,8 +48,7 @@
...
@@ -48,8 +48,7 @@
//M*/
//M*/
#include "precomp.hpp"
#include "precomp.hpp"
#include "mcwutil.hpp"
#include <iostream>
using
namespace
std
;
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
;
using
namespace
cv
::
ocl
;
using
namespace
cv
::
ocl
;
...
...
modules/ocl/src/hog.cpp
View file @
6846f881
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
//M*/
//M*/
#include "precomp.hpp"
#include "precomp.hpp"
#include "mcwutil.hpp"
using
namespace
cv
;
using
namespace
cv
;
using
namespace
cv
::
ocl
;
using
namespace
cv
::
ocl
;
using
namespace
std
;
using
namespace
std
;
...
...
modules/ocl/src/interpolate_frames.cpp
View file @
6846f881
...
@@ -43,9 +43,7 @@
...
@@ -43,9 +43,7 @@
//
//
//M*/
//M*/
#include <iomanip>
#include "precomp.hpp"
#include "precomp.hpp"
#include "mcwutil.hpp"
using
namespace
std
;
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
;
...
...
modules/ocl/src/mcwutil.cpp
View file @
6846f881
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
//
//
//M*/
//M*/
#include "
mcw
util.hpp"
#include "
opencv2/ocl/private/
util.hpp"
#if defined (HAVE_OPENCL)
#if defined (HAVE_OPENCL)
#ifndef CL_VERSION_1_2
#ifndef CL_VERSION_1_2
...
...
modules/ocl/src/precomp.hpp
View file @
6846f881
...
@@ -78,12 +78,7 @@
...
@@ -78,12 +78,7 @@
#if defined (HAVE_OPENCL)
#if defined (HAVE_OPENCL)
#if defined __APPLE__
#include "opencv2/ocl/private/util.hpp"
#include <OpenCL/OpenCL.h>
#else
#include <CL/opencl.h>
#endif
#include "safe_call.hpp"
#include "safe_call.hpp"
using
namespace
std
;
using
namespace
std
;
...
@@ -92,44 +87,6 @@ namespace cv
...
@@ -92,44 +87,6 @@ namespace cv
{
{
namespace
ocl
namespace
ocl
{
{
///////////////////////////OpenCL call wrappers////////////////////////////
void
openCLMallocPitch
(
Context
*
clCxt
,
void
**
dev_ptr
,
size_t
*
pitch
,
size_t
widthInBytes
,
size_t
height
);
void
openCLMallocPitchEx
(
Context
*
clCxt
,
void
**
dev_ptr
,
size_t
*
pitch
,
size_t
widthInBytes
,
size_t
height
,
DevMemRW
rw_type
,
DevMemType
mem_type
);
void
openCLMemcpy2D
(
Context
*
clCxt
,
void
*
dst
,
size_t
dpitch
,
const
void
*
src
,
size_t
spitch
,
size_t
width
,
size_t
height
,
enum
openCLMemcpyKind
kind
,
int
channels
=
-
1
);
void
openCLCopyBuffer2D
(
Context
*
clCxt
,
void
*
dst
,
size_t
dpitch
,
int
dst_offset
,
const
void
*
src
,
size_t
spitch
,
size_t
width
,
size_t
height
,
int
src_offset
);
void
openCLFree
(
void
*
devPtr
);
cl_mem
openCLCreateBuffer
(
Context
*
clCxt
,
size_t
flag
,
size_t
size
);
void
openCLReadBuffer
(
Context
*
clCxt
,
cl_mem
dst_buffer
,
void
*
host_buffer
,
size_t
size
);
cl_kernel
openCLGetKernelFromSource
(
const
Context
*
clCxt
,
const
char
**
source
,
string
kernelName
);
cl_kernel
openCLGetKernelFromSource
(
const
Context
*
clCxt
,
const
char
**
source
,
string
kernelName
,
const
char
*
build_options
);
void
openCLVerifyKernel
(
const
Context
*
clCxt
,
cl_kernel
kernel
,
size_t
*
localThreads
);
void
openCLExecuteKernel
(
Context
*
clCxt
,
const
char
**
source
,
string
kernelName
,
vector
<
std
::
pair
<
size_t
,
const
void
*>
>
&
args
,
int
globalcols
,
int
globalrows
,
size_t
blockSize
=
16
,
int
kernel_expand_depth
=
-
1
,
int
kernel_expand_channel
=
-
1
);
void
openCLExecuteKernel_
(
Context
*
clCxt
,
const
char
**
source
,
string
kernelName
,
size_t
globalThreads
[
3
],
size_t
localThreads
[
3
],
vector
<
pair
<
size_t
,
const
void
*>
>
&
args
,
int
channels
,
int
depth
,
const
char
*
build_options
);
void
openCLExecuteKernel
(
Context
*
clCxt
,
const
char
**
source
,
string
kernelName
,
size_t
globalThreads
[
3
],
size_t
localThreads
[
3
],
vector
<
pair
<
size_t
,
const
void
*>
>
&
args
,
int
channels
,
int
depth
);
void
openCLExecuteKernel
(
Context
*
clCxt
,
const
char
**
source
,
string
kernelName
,
size_t
globalThreads
[
3
],
size_t
localThreads
[
3
],
vector
<
pair
<
size_t
,
const
void
*>
>
&
args
,
int
channels
,
int
depth
,
const
char
*
build_options
);
cl_mem
load_constant
(
cl_context
context
,
cl_command_queue
command_queue
,
const
void
*
value
,
const
size_t
size
);
cl_mem
openCLMalloc
(
cl_context
clCxt
,
size_t
size
,
cl_mem_flags
flags
,
void
*
host_ptr
);
//void openCLMemcpy2DWithNoPadding(cl_command_queue command_queue, cl_mem buffer, size_t size, size_t offset, void *ptr,
// enum openCLMemcpyKind kind, cl_bool blocking_write);
int
savetofile
(
const
Context
*
clcxt
,
cl_program
&
program
,
const
char
*
fileName
);
struct
Context
::
Impl
struct
Context
::
Impl
{
{
//Information of the OpenCL context
//Information of the OpenCL context
...
...
modules/ocl/src/pyrlk.cpp
View file @
6846f881
...
@@ -47,7 +47,6 @@
...
@@ -47,7 +47,6 @@
#include "precomp.hpp"
#include "precomp.hpp"
#include "mcwutil.hpp"
using
namespace
std
;
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
;
using
namespace
cv
::
ocl
;
using
namespace
cv
::
ocl
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment