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
43b76e54
Commit
43b76e54
authored
Aug 27, 2015
by
Andrey Pavlenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding `NO_PROCESSING` (i.e. just preview) mode
parent
016011fd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
4 deletions
+23
-4
CLprocessor.cpp
samples/android/tutorial-4-opencl/jni/CLprocessor.cpp
+7
-0
GLrender.cpp
samples/android/tutorial-4-opencl/jni/GLrender.cpp
+4
-2
menu.xml
samples/android/tutorial-4-opencl/res/menu/menu.xml
+1
-0
NativeGLRenderer.java
...cl/src/org/opencv/samples/tutorial4/NativeGLRenderer.java
+1
-0
Tutorial4Activity.java
...l/src/org/opencv/samples/tutorial4/Tutorial4Activity.java
+10
-2
No files found.
samples/android/tutorial-4-opencl/jni/CLprocessor.cpp
View file @
43b76e54
...
...
@@ -79,6 +79,7 @@ void dumpCLinfo()
cl
::
Context
theContext
;
cl
::
CommandQueue
theQueue
;
cl
::
Program
theProgB2B
,
theProgI2B
,
theProgI2I
;
bool
haveOpenCL
=
false
;
void
initCL
()
{
...
...
@@ -100,6 +101,7 @@ void initCL()
try
{
haveOpenCL
=
false
;
cl
::
Platform
p
=
cl
::
Platform
::
getDefault
();
std
::
string
ext
=
p
.
getInfo
<
CL_PLATFORM_EXTENSIONS
>
();
if
(
ext
.
find
(
"cl_khr_gl_sharing"
)
==
std
::
string
::
npos
)
...
...
@@ -124,6 +126,7 @@ void initCL()
LOGD
(
"OpenCV+OpenCL works OK!"
);
else
LOGE
(
"Can't init OpenCV with OpenCL TAPI"
);
haveOpenCL
=
true
;
}
catch
(
cl
::
Error
&
e
)
{
...
...
@@ -147,6 +150,8 @@ void closeCL()
#define GL_TEXTURE_2D 0x0DE1
void
procOCL_I2I
(
int
texIn
,
int
texOut
,
int
w
,
int
h
)
{
if
(
!
haveOpenCL
)
return
;
LOGD
(
"procOCL_I2I(%d, %d, %d, %d)"
,
texIn
,
texOut
,
w
,
h
);
cl
::
ImageGL
imgIn
(
theContext
,
CL_MEM_READ_ONLY
,
GL_TEXTURE_2D
,
0
,
texIn
);
cl
::
ImageGL
imgOut
(
theContext
,
CL_MEM_WRITE_ONLY
,
GL_TEXTURE_2D
,
0
,
texOut
);
...
...
@@ -179,6 +184,8 @@ void procOCL_I2I(int texIn, int texOut, int w, int h)
void
procOCL_OCV
(
int
tex
,
int
w
,
int
h
)
{
if
(
!
haveOpenCL
)
return
;
int64_t
t
=
getTimeMs
();
cl
::
ImageGL
imgIn
(
theContext
,
CL_MEM_READ_ONLY
,
GL_TEXTURE_2D
,
0
,
tex
);
std
::
vector
<
cl
::
Memory
>
images
(
1
,
imgIn
);
...
...
samples/android/tutorial-4-opencl/jni/GLrender.cpp
View file @
43b76e54
...
...
@@ -63,9 +63,9 @@ GLuint FBO = 0;
GLuint
texOES
=
0
;
int
texWidth
=
0
,
texHeight
=
0
;
enum
ProcMode
{
PROC_MODE_CPU
=
1
,
PROC_MODE_OCL_DIRECT
=
2
,
PROC_MODE_OCL_OCV
=
3
};
enum
ProcMode
{
PROC_MODE_
NO_PROC
=
0
,
PROC_MODE_
CPU
=
1
,
PROC_MODE_OCL_DIRECT
=
2
,
PROC_MODE_OCL_OCV
=
3
};
ProcMode
procMode
=
PROC_MODE_
CPU
;
ProcMode
procMode
=
PROC_MODE_
NO_PROC
;
static
inline
void
deleteTex
(
GLuint
*
tex
)
{
...
...
@@ -298,6 +298,7 @@ extern "C" void drawFrame()
switch
(
procMode
)
{
case
PROC_MODE_NO_PROC
:
drawFrameOrig
();
break
;
case
PROC_MODE_CPU
:
drawFrameProcCPU
();
break
;
case
PROC_MODE_OCL_DIRECT
:
drawFrameProcOCL
();
break
;
case
PROC_MODE_OCL_OCV
:
drawFrameProcOCLOCV
();
break
;
...
...
@@ -366,6 +367,7 @@ extern "C" void setProcessingMode(int mode)
{
switch
(
mode
)
{
case
PROC_MODE_NO_PROC
:
procMode
=
PROC_MODE_NO_PROC
;
break
;
case
PROC_MODE_CPU
:
procMode
=
PROC_MODE_CPU
;
break
;
case
PROC_MODE_OCL_DIRECT
:
procMode
=
PROC_MODE_OCL_DIRECT
;
break
;
case
PROC_MODE_OCL_OCV
:
procMode
=
PROC_MODE_OCL_OCV
;
break
;
...
...
samples/android/tutorial-4-opencl/res/menu/menu.xml
View file @
43b76e54
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<group
android:checkableBehavior=
"single"
>
<item
android:id=
"@+id/no_proc"
android:title=
"No processing"
/>
<item
android:id=
"@+id/cpu"
android:title=
"Use CPU code"
/>
<item
android:id=
"@+id/ocl_direct"
android:title=
"Use OpenCL direct"
/>
<item
android:id=
"@+id/ocl_ocv"
android:title=
"Use OpenCL via OpenCV"
/>
...
...
samples/android/tutorial-4-opencl/src/org/opencv/samples/tutorial4/NativeGLRenderer.java
View file @
43b76e54
...
...
@@ -7,6 +7,7 @@ public class NativeGLRenderer {
System
.
loadLibrary
(
"JNIrender"
);
}
public
static
final
int
PROCESSING_MODE_NO_PROCESSING
=
0
;
public
static
final
int
PROCESSING_MODE_CPU
=
1
;
public
static
final
int
PROCESSING_MODE_OCL_DIRECT
=
2
;
public
static
final
int
PROCESSING_MODE_OCL_OCV
=
3
;
...
...
samples/android/tutorial-4-opencl/src/org/opencv/samples/tutorial4/Tutorial4Activity.java
View file @
43b76e54
...
...
@@ -34,11 +34,11 @@ public class Tutorial4Activity extends Activity {
mProcMode
=
(
TextView
)
findViewById
(
R
.
id
.
proc_mode_text_view
);
runOnUiThread
(
new
Runnable
()
{
public
void
run
()
{
mProcMode
.
setText
(
"Processing mode:
CPU
"
);
mProcMode
.
setText
(
"Processing mode:
No processing
"
);
}
});
NativeGLRenderer
.
setProcessingMode
(
NativeGLRenderer
.
PROCESSING_MODE_
CPU
);
}
NativeGLRenderer
.
setProcessingMode
(
NativeGLRenderer
.
PROCESSING_MODE_
NO_PROCESSING
);
}
@Override
protected
void
onPause
()
{
...
...
@@ -62,6 +62,14 @@ public class Tutorial4Activity extends Activity {
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
case
R
.
id
.
no_proc
:
runOnUiThread
(
new
Runnable
()
{
public
void
run
()
{
mProcMode
.
setText
(
"Processing mode: No Processing"
);
}
});
NativeGLRenderer
.
setProcessingMode
(
NativeGLRenderer
.
PROCESSING_MODE_NO_PROCESSING
);
return
true
;
case
R
.
id
.
cpu
:
runOnUiThread
(
new
Runnable
()
{
public
void
run
()
{
...
...
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