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
52a785e9
Commit
52a785e9
authored
Dec 17, 2013
by
Roman Donchenko
Committed by
OpenCV Buildbot
Dec 17, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1996 from SpecLad:merge-2.4
parents
0cf76073
f2befa01
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
369 additions
and
59 deletions
+369
-59
tocDefinitions.rst
doc/tutorials/definitions/tocDefinitions.rst
+1
-0
clojure_dev_intro.rst
...ials/introduction/clojure_dev_intro/clojure_dev_intro.rst
+0
-0
blurred.png
...torials/introduction/clojure_dev_intro/images/blurred.png
+0
-0
lena.png
doc/tutorials/introduction/clojure_dev_intro/images/lena.png
+0
-0
clojure-logo.png
...ion/table_of_content_introduction/images/clojure-logo.png
+0
-0
table_of_content_introduction.rst
...of_content_introduction/table_of_content_introduction.rst
+16
-0
utility.hpp
modules/core/include/opencv2/core/utility.hpp
+26
-0
ocl.cpp
modules/core/src/ocl.cpp
+4
-4
precomp.hpp
modules/core/src/precomp.hpp
+6
-5
rand.cpp
modules/core/src/rand.cpp
+1
-1
system.cpp
modules/core/src/system.cpp
+158
-46
freak.cpp
modules/features2d/src/freak.cpp
+0
-0
CMakeLists.txt
modules/ocl/CMakeLists.txt
+3
-0
structures_and_utility_functions.rst
modules/ocl/doc/structures_and_utility_functions.rst
+15
-1
ocl.hpp
modules/ocl/include/opencv2/ocl.hpp
+6
-0
matrix_operations.hpp
modules/ocl/include/opencv2/ocl/matrix_operations.hpp
+1
-0
cl_context.cpp
modules/ocl/src/cl_context.cpp
+0
-0
test_api.cpp
modules/ocl/test/test_api.cpp
+85
-1
stereo_match.cpp
samples/cpp/stereo_match.cpp
+1
-1
.gitignore
samples/java/clojure/simple-sample/.gitignore
+9
-0
project.clj
samples/java/clojure/simple-sample/project.clj
+14
-0
lena.png
samples/java/clojure/simple-sample/resources/images/lena.png
+0
-0
core.clj
...les/java/clojure/simple-sample/src/simple_sample/core.clj
+16
-0
core_test.clj
...va/clojure/simple-sample/test/simple_sample/core_test.clj
+7
-0
No files found.
doc/tutorials/definitions/tocDefinitions.rst
View file @
52a785e9
...
...
@@ -11,5 +11,6 @@
.. |Author_EricCh| unicode:: Eric U+0020 Christiansen
.. |Author_AndreyP| unicode:: Andrey U+0020 Pavlenko
.. |Author_AlexS| unicode:: Alexander U+0020 Smorkalov
.. |Author_MimmoC| unicode:: Mimmo U+0020 Cosenza
.. |Author_BarisD| unicode:: Bar U+0131 U+015F U+0020 Evrim U+0020 Demir U+00F6 z
.. |Author_DomenicoB| unicode:: Domenico U+0020 Daniele U+0020 Bloisi
doc/tutorials/introduction/clojure_dev_intro/clojure_dev_intro.rst
0 → 100644
View file @
52a785e9
This diff is collapsed.
Click to expand it.
doc/tutorials/introduction/clojure_dev_intro/images/blurred.png
0 → 100644
View file @
52a785e9
351 KB
doc/tutorials/introduction/clojure_dev_intro/images/lena.png
0 → 100644
View file @
52a785e9
606 KB
doc/tutorials/introduction/table_of_content_introduction/images/clojure-logo.png
0 → 100644
View file @
52a785e9
7.68 KB
doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.rst
View file @
52a785e9
...
...
@@ -156,6 +156,21 @@ world of the OpenCV.
:height: 90pt
:width: 90pt
================ =================================================
|ClojureLogo| **Title:** :ref:`clojure_dev_intro`
*Compatibility:* > OpenCV 2.4.4
*Author:* |Author_MimmoC|
A tutorial on how to interactively use OpenCV from the Clojure REPL.
================ =================================================
.. |ClojureLogo| image:: images/clojure-logo.png
:height: 90pt
:width: 90pt
* **Android**
.. tabularcolumns:: m{100pt} m{300pt}
...
...
@@ -314,6 +329,7 @@ world of the OpenCV.
../windows_visual_studio_image_watch/windows_visual_studio_image_watch
../desktop_java/java_dev_intro
../java_eclipse/java_eclipse
../clojure_dev_intro/clojure_dev_intro
../android_binary_package/android_dev_intro
../android_binary_package/O4A_SDK
../android_binary_package/dev_with_OCV_on_Android
...
...
modules/core/include/opencv2/core/utility.hpp
View file @
52a785e9
...
...
@@ -305,6 +305,32 @@ private:
AutoLock
&
operator
=
(
const
AutoLock
&
);
};
class
CV_EXPORTS
TLSDataContainer
{
private
:
int
key_
;
protected
:
TLSDataContainer
();
virtual
~
TLSDataContainer
();
public
:
virtual
void
*
createDataInstance
()
const
=
0
;
virtual
void
deleteDataInstance
(
void
*
data
)
const
=
0
;
void
*
getData
()
const
;
};
template
<
typename
T
>
class
TLSData
:
protected
TLSDataContainer
{
public
:
inline
TLSData
()
{}
inline
~
TLSData
()
{}
inline
T
*
get
()
const
{
return
(
T
*
)
getData
();
}
private
:
virtual
void
*
createDataInstance
()
const
{
return
new
T
;
}
virtual
void
deleteDataInstance
(
void
*
data
)
const
{
delete
(
T
*
)
data
;
}
};
// The CommandLineParser class is designed for command line arguments parsing
class
CV_EXPORTS
CommandLineParser
...
...
modules/core/src/ocl.cpp
View file @
52a785e9
...
...
@@ -1338,7 +1338,7 @@ bool haveOpenCL()
bool
useOpenCL
()
{
TLSData
*
data
=
TLSData
::
get
();
CoreTLSData
*
data
=
coreTlsData
.
get
();
if
(
data
->
useOpenCL
<
0
)
data
->
useOpenCL
=
(
int
)
haveOpenCL
();
return
data
->
useOpenCL
>
0
;
...
...
@@ -1348,7 +1348,7 @@ void setUseOpenCL(bool flag)
{
if
(
haveOpenCL
()
)
{
TLSData
*
data
=
TLSData
::
get
();
CoreTLSData
*
data
=
coreTlsData
.
get
();
data
->
useOpenCL
=
flag
?
1
:
0
;
}
}
...
...
@@ -1765,7 +1765,7 @@ size_t Device::profilingTimerResolution() const
const
Device
&
Device
::
getDefault
()
{
const
Context2
&
ctx
=
Context2
::
getDefault
();
int
idx
=
TLSData
::
get
()
->
device
;
int
idx
=
coreTlsData
.
get
()
->
device
;
return
ctx
.
device
(
idx
);
}
...
...
@@ -2059,7 +2059,7 @@ void* Queue::ptr() const
Queue
&
Queue
::
getDefault
()
{
Queue
&
q
=
TLSData
::
get
()
->
oclQueue
;
Queue
&
q
=
coreTlsData
.
get
()
->
oclQueue
;
if
(
!
q
.
p
&&
haveOpenCL
()
)
q
.
create
(
Context2
::
getDefault
());
return
q
;
...
...
modules/core/src/precomp.hpp
View file @
52a785e9
...
...
@@ -106,7 +106,6 @@ extern const uchar g_Saturate8u[];
#if defined WIN32 || defined _WIN32
void
deleteThreadAllocData
();
void
deleteThreadData
();
#endif
template
<
typename
T1
,
typename
T2
=
T1
,
typename
T3
=
T1
>
struct
OpAdd
...
...
@@ -233,17 +232,19 @@ inline bool checkScalar(InputArray sc, int atype, int sckind, int akind)
void
convertAndUnrollScalar
(
const
Mat
&
sc
,
int
buftype
,
uchar
*
scbuf
,
size_t
blocksize
);
struct
TLSData
struct
Core
TLSData
{
TLSData
();
CoreTLSData
()
:
device
(
0
),
useOpenCL
(
-
1
)
{}
RNG
rng
;
int
device
;
ocl
::
Queue
oclQueue
;
int
useOpenCL
;
// 1 - use, 0 - do not use, -1 - auto/not initialized
static
TLSData
*
get
();
};
extern
TLSData
<
CoreTLSData
>
coreTlsData
;
#if defined(BUILD_SHARED_LIBS)
#if defined WIN32 || defined _WIN32 || defined WINCE
#define CL_RUNTIME_EXPORT __declspec(dllexport)
...
...
modules/core/src/rand.cpp
View file @
52a785e9
...
...
@@ -731,7 +731,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
cv
::
RNG
&
cv
::
theRNG
()
{
return
TLSData
::
get
()
->
rng
;
return
coreTlsData
.
get
()
->
rng
;
}
void
cv
::
randu
(
InputOutputArray
dst
,
InputArray
low
,
InputArray
high
)
...
...
modules/core/src/system.cpp
View file @
52a785e9
...
...
@@ -738,26 +738,6 @@ namespace cv {
bool
__termination
=
false
;
}
#if defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
#ifdef HAVE_WINRT
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
#endif
BOOL
WINAPI
DllMain
(
HINSTANCE
,
DWORD
,
LPVOID
);
BOOL
WINAPI
DllMain
(
HINSTANCE
,
DWORD
fdwReason
,
LPVOID
lpReserved
)
{
if
(
fdwReason
==
DLL_THREAD_DETACH
||
fdwReason
==
DLL_PROCESS_DETACH
)
{
if
(
lpReserved
!=
NULL
)
// called after ExitProcess() call
cv
::
__termination
=
true
;
cv
::
deleteThreadAllocData
();
cv
::
deleteThreadData
();
}
return
TRUE
;
}
#endif
namespace
cv
{
...
...
@@ -841,36 +821,54 @@ void Mutex::lock() { impl->lock(); }
void
Mutex
::
unlock
()
{
impl
->
unlock
();
}
bool
Mutex
::
trylock
()
{
return
impl
->
trylock
();
}
}
//////////////////////////////// thread-local storage ////////////////////////////////
namespace
cv
class
TLSStorage
{
std
::
vector
<
void
*>
tlsData_
;
public
:
TLSStorage
()
{
tlsData_
.
reserve
(
16
);
}
~
TLSStorage
();
inline
void
*
getData
(
int
key
)
const
{
CV_DbgAssert
(
key
>=
0
);
return
(
key
<
(
int
)
tlsData_
.
size
())
?
tlsData_
[
key
]
:
NULL
;
}
inline
void
setData
(
int
key
,
void
*
data
)
{
CV_DbgAssert
(
key
>=
0
);
if
(
key
>=
(
int
)
tlsData_
.
size
())
{
tlsData_
.
resize
(
key
+
1
,
NULL
);
}
tlsData_
[
key
]
=
data
;
}
TLSData
::
TLSData
()
{
device
=
0
;
useOpenCL
=
-
1
;
}
inline
static
TLSStorage
*
get
();
};
#ifdef WIN32
#pragma warning(disable:4505) // unreferenced local function has been removed
#ifdef HAVE_WINRT
// using C++11 thread attribute for local thread data
static
__declspec
(
thread
)
TLS
Data
*
g_tlsdata
=
NULL
;
static
__declspec
(
thread
)
TLS
Storage
*
g_tlsdata
=
NULL
;
static
void
deleteThread
RNG
Data
()
static
void
deleteThreadData
()
{
if
(
g_tlsdata
)
{
delete
g_tlsdata
;
g_tlsdata
=
NULL
;
}
}
TLSData
*
TLSData
::
get
()
inline
TLSStorage
*
TLSStorage
::
get
()
{
if
(
!
g_tlsdata
)
{
g_tlsdata
=
new
TLS
Data
;
g_tlsdata
=
new
TLS
Storage
;
}
return
g_tlsdata
;
}
...
...
@@ -880,55 +878,169 @@ TLSData::TLSData()
#endif
static
DWORD
tlsKey
=
TLS_OUT_OF_INDEXES
;
void
deleteThreadData
()
static
void
deleteThreadData
()
{
if
(
tlsKey
!=
TLS_OUT_OF_INDEXES
)
delete
(
TLSData
*
)
TlsGetValue
(
tlsKey
);
if
(
tlsKey
!=
TLS_OUT_OF_INDEXES
)
{
delete
(
TLSStorage
*
)
TlsGetValue
(
tlsKey
);
TlsSetValue
(
tlsKey
,
NULL
);
}
}
TLSData
*
TLSData
::
get
()
inline
TLSStorage
*
TLSStorage
::
get
()
{
if
(
tlsKey
==
TLS_OUT_OF_INDEXES
)
if
(
tlsKey
==
TLS_OUT_OF_INDEXES
)
{
tlsKey
=
TlsAlloc
();
CV_Assert
(
tlsKey
!=
TLS_OUT_OF_INDEXES
);
}
TLS
Data
*
d
=
(
TLSData
*
)
TlsGetValue
(
tlsKey
);
if
(
!
d
)
TLS
Storage
*
d
=
(
TLSStorage
*
)
TlsGetValue
(
tlsKey
);
if
(
!
d
)
{
d
=
new
TLS
Data
;
TlsSetValue
(
tlsKey
,
d
);
d
=
new
TLS
Storage
;
TlsSetValue
(
tlsKey
,
d
);
}
return
d
;
}
#endif //HAVE_WINRT
#if defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
#ifdef HAVE_WINRT
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
#endif
BOOL
WINAPI
DllMain
(
HINSTANCE
,
DWORD
fdwReason
,
LPVOID
);
BOOL
WINAPI
DllMain
(
HINSTANCE
,
DWORD
fdwReason
,
LPVOID
lpReserved
)
{
if
(
fdwReason
==
DLL_THREAD_DETACH
||
fdwReason
==
DLL_PROCESS_DETACH
)
{
if
(
lpReserved
!=
NULL
)
// called after ExitProcess() call
cv
::
__termination
=
true
;
cv
::
deleteThreadAllocData
();
cv
::
deleteThreadData
();
}
return
TRUE
;
}
#endif
#else
static
pthread_key_t
tlsKey
=
0
;
static
pthread_once_t
tlsKeyOnce
=
PTHREAD_ONCE_INIT
;
static
void
deleteTLS
Data
(
void
*
data
)
static
void
deleteTLS
Storage
(
void
*
data
)
{
delete
(
TLS
Data
*
)
data
;
delete
(
TLS
Storage
*
)
data
;
}
static
void
makeKey
()
{
int
errcode
=
pthread_key_create
(
&
tlsKey
,
deleteTLS
Data
);
int
errcode
=
pthread_key_create
(
&
tlsKey
,
deleteTLS
Storage
);
CV_Assert
(
errcode
==
0
);
}
TLSData
*
TLSData
::
get
()
inline
TLSStorage
*
TLSStorage
::
get
()
{
pthread_once
(
&
tlsKeyOnce
,
makeKey
);
TLS
Data
*
d
=
(
TLSData
*
)
pthread_getspecific
(
tlsKey
);
TLS
Storage
*
d
=
(
TLSStorage
*
)
pthread_getspecific
(
tlsKey
);
if
(
!
d
)
{
d
=
new
TLS
Data
;
d
=
new
TLS
Storage
;
pthread_setspecific
(
tlsKey
,
d
);
}
return
d
;
}
#endif
class
TLSContainerStorage
{
cv
::
Mutex
mutex_
;
std
::
vector
<
TLSDataContainer
*>
tlsContainers_
;
public
:
TLSContainerStorage
()
{
}
~
TLSContainerStorage
()
{
for
(
size_t
i
=
0
;
i
<
tlsContainers_
.
size
();
i
++
)
{
CV_DbgAssert
(
tlsContainers_
[
i
]
==
NULL
);
// not all keys released
tlsContainers_
[
i
]
=
NULL
;
}
}
int
allocateKey
(
TLSDataContainer
*
pContainer
)
{
cv
::
AutoLock
lock
(
mutex_
);
tlsContainers_
.
push_back
(
pContainer
);
return
(
int
)
tlsContainers_
.
size
()
-
1
;
}
void
releaseKey
(
int
id
,
TLSDataContainer
*
pContainer
)
{
cv
::
AutoLock
lock
(
mutex_
);
CV_Assert
(
tlsContainers_
[
id
]
==
pContainer
);
tlsContainers_
[
id
]
=
NULL
;
// currently, we don't go into thread's TLSData and release data for this key
}
void
destroyData
(
int
key
,
void
*
data
)
{
cv
::
AutoLock
lock
(
mutex_
);
TLSDataContainer
*
k
=
tlsContainers_
[
key
];
if
(
!
k
)
return
;
try
{
k
->
deleteDataInstance
(
data
);
}
catch
(...)
{
CV_DbgAssert
(
k
==
NULL
);
// Debug this!
}
}
};
static
TLSContainerStorage
tlsContainerStorage
;
TLSDataContainer
::
TLSDataContainer
()
:
key_
(
-
1
)
{
key_
=
tlsContainerStorage
.
allocateKey
(
this
);
}
TLSDataContainer
::~
TLSDataContainer
()
{
tlsContainerStorage
.
releaseKey
(
key_
,
this
);
key_
=
-
1
;
}
void
*
TLSDataContainer
::
getData
()
const
{
CV_Assert
(
key_
>=
0
);
TLSStorage
*
tlsData
=
TLSStorage
::
get
();
void
*
data
=
tlsData
->
getData
(
key_
);
if
(
!
data
)
{
data
=
this
->
createDataInstance
();
CV_DbgAssert
(
data
!=
NULL
);
tlsData
->
setData
(
key_
,
data
);
}
return
data
;
}
TLSStorage
::~
TLSStorage
()
{
for
(
int
i
=
0
;
i
<
(
int
)
tlsData_
.
size
();
i
++
)
{
void
*&
data
=
tlsData_
[
i
];
if
(
data
)
{
tlsContainerStorage
.
destroyData
(
i
,
data
);
data
=
NULL
;
}
}
tlsData_
.
clear
();
}
TLSData
<
CoreTLSData
>
coreTlsData
;
}
// namespace cv
/* End of file. */
modules/features2d/src/freak.cpp
View file @
52a785e9
This diff is collapsed.
Click to expand it.
modules/ocl/CMakeLists.txt
View file @
52a785e9
...
...
@@ -5,4 +5,7 @@ endif()
set
(
the_description
"OpenCL-accelerated Computer Vision"
)
ocv_define_module
(
ocl opencv_core opencv_imgproc opencv_features2d opencv_objdetect opencv_video opencv_calib3d opencv_ml
"
${
OPENCL_LIBRARIES
}
"
)
if
(
TARGET opencv_test_ocl
)
target_link_libraries
(
opencv_test_ocl
"
${
OPENCL_LIBRARIES
}
"
)
endif
()
ocv_warnings_disable
(
CMAKE_CXX_FLAGS -Wshadow
)
modules/ocl/doc/structures_and_utility_functions.rst
View file @
52a785e9
...
...
@@ -25,12 +25,26 @@ Returns the list of devices
ocl::setDevice
--------------
Returns void
Initialize OpenCL computation context
.. ocv:function:: void ocl::setDevice( const DeviceInfo* info )
:param info: device info
ocl::initializeContext
--------------------------------
Alternative way to initialize OpenCL computation context.
.. ocv:function:: void ocl::initializeContext(void* pClPlatform, void* pClContext, void* pClDevice)
:param pClPlatform: selected ``platform_id`` (via pointer, parameter type is ``cl_platform_id*``)
:param pClContext: selected ``cl_context`` (via pointer, parameter type is ``cl_context*``)
:param pClDevice: selected ``cl_device_id`` (via pointer, parameter type is ``cl_device_id*``)
This function can be used for context initialization with D3D/OpenGL interoperability.
ocl::setBinaryPath
------------------
Returns void
...
...
modules/ocl/include/opencv2/ocl.hpp
View file @
52a785e9
...
...
@@ -118,6 +118,7 @@ namespace cv
const
PlatformInfo
*
platform
;
DeviceInfo
();
~
DeviceInfo
();
};
struct
PlatformInfo
...
...
@@ -136,6 +137,7 @@ namespace cv
std
::
vector
<
const
DeviceInfo
*>
devices
;
PlatformInfo
();
~
PlatformInfo
();
};
//////////////////////////////// Initialization & Info ////////////////////////
...
...
@@ -151,6 +153,10 @@ namespace cv
// set device you want to use
CV_EXPORTS
void
setDevice
(
const
DeviceInfo
*
info
);
// Initialize from OpenCL handles directly.
// Argument types is (pointers): cl_platform_id*, cl_context*, cl_device_id*
CV_EXPORTS
void
initializeContext
(
void
*
pClPlatform
,
void
*
pClContext
,
void
*
pClDevice
);
enum
FEATURE_TYPE
{
FEATURE_CL_DOUBLE
=
1
,
...
...
modules/ocl/include/opencv2/ocl/matrix_operations.hpp
View file @
52a785e9
...
...
@@ -175,6 +175,7 @@ namespace cv
data
=
m
.
data
;
datastart
=
m
.
datastart
;
dataend
=
m
.
dataend
;
clCxt
=
m
.
clCxt
;
wholerows
=
m
.
wholerows
;
wholecols
=
m
.
wholecols
;
offset
=
m
.
offset
;
...
...
modules/ocl/src/cl_context.cpp
View file @
52a785e9
This diff is collapsed.
Click to expand it.
modules/ocl/test/test_api.cpp
View file @
52a785e9
...
...
@@ -40,7 +40,7 @@
//M*/
#include "test_precomp.hpp"
#include "opencv2/core/opencl/runtime/opencl_core.hpp" // for OpenCL types
: cl_mem
#include "opencv2/core/opencl/runtime/opencl_core.hpp" // for OpenCL types
& functions
#include "opencv2/core/ocl.hpp"
TEST
(
TestAPI
,
openCLExecuteKernelInterop
)
...
...
@@ -127,3 +127,87 @@ TEST(OCL_TestTAPI, performance)
t
=
(
double
)
cv
::
getTickCount
()
-
t
;
printf
(
"cpu exec time = %gms per iter
\n
"
,
t
*
1000.
/
niters
/
cv
::
getTickFrequency
());
}
// This test must be DISABLED by default!
// (We can't restore original context for other tests)
TEST
(
TestAPI
,
DISABLED_InitializationFromHandles
)
{
#define MAX_PLATFORMS 16
cl_platform_id
platforms
[
MAX_PLATFORMS
]
=
{
NULL
};
cl_uint
numPlatforms
=
0
;
cl_int
status
=
::
clGetPlatformIDs
(
MAX_PLATFORMS
,
&
platforms
[
0
],
&
numPlatforms
);
ASSERT_EQ
(
CL_SUCCESS
,
status
)
<<
"clGetPlatformIDs"
;
ASSERT_NE
(
0
,
(
int
)
numPlatforms
);
int
selectedPlatform
=
0
;
cl_platform_id
platform
=
platforms
[
selectedPlatform
];
ASSERT_NE
((
void
*
)
NULL
,
platform
);
cl_device_id
device
=
NULL
;
status
=
::
clGetDeviceIDs
(
platform
,
CL_DEVICE_TYPE_ALL
,
1
,
&
device
,
NULL
);
ASSERT_EQ
(
CL_SUCCESS
,
status
)
<<
"clGetDeviceIDs"
;
ASSERT_NE
((
void
*
)
NULL
,
device
);
cl_context_properties
cps
[
3
]
=
{
CL_CONTEXT_PLATFORM
,
(
cl_context_properties
)(
platform
),
0
};
cl_context
context
=
::
clCreateContext
(
cps
,
1
,
&
device
,
NULL
,
NULL
,
&
status
);
ASSERT_EQ
(
CL_SUCCESS
,
status
)
<<
"clCreateContext"
;
ASSERT_NE
((
void
*
)
NULL
,
context
);
ASSERT_NO_THROW
(
cv
::
ocl
::
initializeContext
(
&
platform
,
&
context
,
&
device
));
status
=
::
clReleaseContext
(
context
);
ASSERT_EQ
(
CL_SUCCESS
,
status
)
<<
"clReleaseContext"
;
#ifdef CL_VERSION_1_2
#if 1
{
cv
::
ocl
::
Context
*
ctx
=
cv
::
ocl
::
Context
::
getContext
();
ASSERT_NE
((
void
*
)
NULL
,
ctx
);
if
(
ctx
->
supportsFeature
(
cv
::
ocl
::
FEATURE_CL_VER_1_2
))
// device supports OpenCL 1.2+
{
status
=
::
clReleaseDevice
(
device
);
ASSERT_EQ
(
CL_SUCCESS
,
status
)
<<
"clReleaseDevice"
;
}
}
#else // code below doesn't work on Linux (SEGFAULTs on 1.1- devices are not handled via exceptions)
try
{
status
=
::
clReleaseDevice
(
device
);
// NOTE This works only with !DEVICES! that supports OpenCL 1.2
(
void
)
status
;
// no check
}
catch
(...)
{
// nothing, there is no problem
}
#endif
#endif
// print the name of current device
cv
::
ocl
::
Context
*
ctx
=
cv
::
ocl
::
Context
::
getContext
();
ASSERT_NE
((
void
*
)
NULL
,
ctx
);
const
cv
::
ocl
::
DeviceInfo
&
deviceInfo
=
ctx
->
getDeviceInfo
();
std
::
cout
<<
"Device name: "
<<
deviceInfo
.
deviceName
<<
std
::
endl
;
std
::
cout
<<
"Platform name: "
<<
deviceInfo
.
platform
->
platformName
<<
std
::
endl
;
ASSERT_EQ
(
context
,
*
(
cl_context
*
)
ctx
->
getOpenCLContextPtr
());
ASSERT_EQ
(
device
,
*
(
cl_device_id
*
)
ctx
->
getOpenCLDeviceIDPtr
());
// do some calculations and check results
cv
::
RNG
rng
;
Size
sz
(
100
,
100
);
cv
::
Mat
srcMat
=
cvtest
::
randomMat
(
rng
,
sz
,
CV_32FC4
,
-
10
,
10
,
false
);
cv
::
Mat
dstMat
;
cv
::
ocl
::
oclMat
srcGpuMat
(
srcMat
);
cv
::
ocl
::
oclMat
dstGpuMat
;
cv
::
Scalar
v
=
cv
::
Scalar
::
all
(
1
);
cv
::
add
(
srcMat
,
v
,
dstMat
);
cv
::
ocl
::
add
(
srcGpuMat
,
v
,
dstGpuMat
);
cv
::
Mat
dstGpuMatMap
;
dstGpuMat
.
download
(
dstGpuMatMap
);
EXPECT_LE
(
checkNorm
(
dstMat
,
dstGpuMatMap
),
1e-3
);
}
samples/cpp/stereo_match.cpp
View file @
52a785e9
...
...
@@ -46,7 +46,7 @@ int main(int argc, char** argv)
const
char
*
algorithm_opt
=
"--algorithm="
;
const
char
*
maxdisp_opt
=
"--max-disparity="
;
const
char
*
blocksize_opt
=
"--blocksize="
;
const
char
*
nodisplay_opt
=
"--no-display
=
"
;
const
char
*
nodisplay_opt
=
"--no-display"
;
const
char
*
scale_opt
=
"--scale="
;
if
(
argc
<
3
)
...
...
samples/java/clojure/simple-sample/.gitignore
0 → 100644
View file @
52a785e9
/target
/classes
/checkouts
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port
samples/java/clojure/simple-sample/project.clj
0 → 100644
View file @
52a785e9
(
defproject
simple-sample
"0.1.0-SNAPSHOT"
:pom-addition
[
:developers
[
:developer
{
:id
"magomimmo"
}
[
:name
"Mimmo Cosenza"
]
[
:url
"https://github.com/magomimmoo"
]]]
:description
"A simple project to start REPLing with OpenCV"
:url
"http://example.com/FIXME"
:license
{
:name
"BSD 3-Clause License"
:url
"http://opensource.org/licenses/BSD-3-Clause"
}
:dependencies
[[
org.clojure/clojure
"1.5.1"
]
[
opencv/opencv
"2.4.7"
]
[
opencv/opencv-native
"2.4.7"
]]
:main
simple-sample.core
:injections
[(
clojure.lang.RT/loadLibrary
org.opencv.core.Core/NATIVE_LIBRARY_NAME
)])
samples/java/clojure/simple-sample/resources/images/lena.png
0 → 100644
View file @
52a785e9
606 KB
samples/java/clojure/simple-sample/src/simple_sample/core.clj
0 → 100644
View file @
52a785e9
;;; to run this code from the terminal: "$ lein run". It will save a
;;; blurred image version of resources/images/lena.png as
;;; resources/images/blurred.png
(
ns
simple-sample.core
(
:import
[
org.opencv.core
Point
Rect
Mat
CvType
Size
Scalar
]
org.opencv.highgui.Highgui
org.opencv.imgproc.Imgproc
))
(
defn
-main
[
&
args
]
(
let
[
lena
(
Highgui/imread
"resources/images/lena.png"
)
blurred
(
Mat.
512
512
CvType/CV_8UC3
)]
(
print
"Blurring..."
)
(
Imgproc/GaussianBlur
lena
blurred
(
Size.
5
5
)
3
3
)
(
Highgui/imwrite
"resources/images/blurred.png"
blurred
)
(
println
"done!"
)))
samples/java/clojure/simple-sample/test/simple_sample/core_test.clj
0 → 100644
View file @
52a785e9
(
ns
simple-sample.core-test
(
:require
[
clojure.test
:refer
:all
]
[
simple-sample.core
:refer
:all
]))
(
deftest
a-test
(
testing
"FIXME, I fail."
(
is
(
=
0
1
))))
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