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
9ab291ea
Commit
9ab291ea
authored
Jul 30, 2015
by
Andrey Pavlenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding displaying FPS
parent
0185cb27
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
12 deletions
+45
-12
activity.xml
samples/android/tutorial-4-opencl/res/layout/activity.xml
+10
-6
MyGLRendererBase.java
...cl/src/org/opencv/samples/tutorial4/MyGLRendererBase.java
+19
-1
MyGLSurfaceView.java
...ncl/src/org/opencv/samples/tutorial4/MyGLSurfaceView.java
+9
-3
Tutorial4Activity.java
...l/src/org/opencv/samples/tutorial4/Tutorial4Activity.java
+7
-2
No files found.
samples/android/tutorial-4-opencl/res/layout/activity.xml
View file @
9ab291ea
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
"${relativePackage}.${activityClass}"
>
android:layout_height=
"match_parent"
>
<org.opencv.samples.tutorial4.MyGLSurfaceView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:id=
"@+id/my_gl_surface_view"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/app_name"
/>
android:id=
"@+id/fps_text_view"
android:text=
"FPS:"
/>
</
Relativ
eLayout>
</
Fram
eLayout>
samples/android/tutorial-4-opencl/src/org/opencv/samples/tutorial4/MyGLRendererBase.java
View file @
9ab291ea
...
...
@@ -6,7 +6,11 @@ import javax.microedition.khronos.opengles.GL10;
import
android.graphics.SurfaceTexture
;
import
android.opengl.GLES20
;
import
android.opengl.GLSurfaceView
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.TextView
;
public
abstract
class
MyGLRendererBase
implements
GLSurfaceView
.
Renderer
,
SurfaceTexture
.
OnFrameAvailableListener
{
protected
final
String
LOGTAG
=
"MyGLRendererBase"
;
...
...
@@ -15,6 +19,7 @@ public abstract class MyGLRendererBase implements GLSurfaceView.Renderer, Surfac
protected
SurfaceTexture
mSTex
;
protected
MyGLSurfaceView
mView
;
protected
TextView
mFpsText
;
protected
boolean
mGLInit
=
false
;
protected
boolean
mTexUpdate
=
false
;
...
...
@@ -27,6 +32,11 @@ public abstract class MyGLRendererBase implements GLSurfaceView.Renderer, Surfac
protected
abstract
void
closeCamera
();
protected
abstract
void
setCameraPreviewSize
(
int
width
,
int
height
);
public
void
setFpsTextView
(
TextView
fpsTV
)
{
mFpsText
=
fpsTV
;
}
public
void
onResume
()
{
Log
.
i
(
LOGTAG
,
"onResume"
);
frameCounter
=
0
;
...
...
@@ -70,8 +80,16 @@ public abstract class MyGLRendererBase implements GLSurfaceView.Renderer, Surfac
frameCounter
++;
if
(
frameCounter
>=
10
)
{
int
fps
=
(
int
)
(
frameCounter
*
1
e9
/
(
System
.
nanoTime
()
-
lastNanoTime
));
final
int
fps
=
(
int
)
(
frameCounter
*
1
e9
/
(
System
.
nanoTime
()
-
lastNanoTime
));
Log
.
i
(
LOGTAG
,
"drawFrame() FPS: "
+
fps
);
if
(
mFpsText
!=
null
)
{
Runnable
fpsUpdater
=
new
Runnable
()
{
public
void
run
()
{
mFpsText
.
setText
(
"FPS: "
+
fps
);
}
};
new
Handler
(
Looper
.
getMainLooper
()).
post
(
fpsUpdater
);
}
frameCounter
=
0
;
lastNanoTime
=
System
.
nanoTime
();
}
...
...
samples/android/tutorial-4-opencl/src/org/opencv/samples/tutorial4/MyGLSurfaceView.java
View file @
9ab291ea
...
...
@@ -2,14 +2,16 @@ package org.opencv.samples.tutorial4;
import
android.content.Context
;
import
android.opengl.GLSurfaceView
;
import
android.util.AttributeSet
;
import
android.view.SurfaceHolder
;
import
android.widget.TextView
;
class
MyGLSurfaceView
extends
GLSurfaceView
{
public
class
MyGLSurfaceView
extends
GLSurfaceView
{
MyGLRendererBase
mRenderer
;
MyGLSurfaceView
(
Context
context
)
{
super
(
context
);
public
MyGLSurfaceView
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
21
)
mRenderer
=
new
Camera2Renderer
(
this
);
...
...
@@ -21,6 +23,10 @@ class MyGLSurfaceView extends GLSurfaceView {
setRenderMode
(
GLSurfaceView
.
RENDERMODE_WHEN_DIRTY
);
}
public
void
setFpsTextView
(
TextView
tv
)
{
mRenderer
.
setFpsTextView
(
tv
);
}
@Override
public
void
surfaceCreated
(
SurfaceHolder
holder
)
{
super
.
surfaceCreated
(
holder
);
...
...
samples/android/tutorial-4-opencl/src/org/opencv/samples/tutorial4/Tutorial4Activity.java
View file @
9ab291ea
...
...
@@ -5,6 +5,7 @@ import android.content.pm.ActivityInfo;
import
android.os.Bundle
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.TextView
;
public
class
Tutorial4Activity
extends
Activity
{
...
...
@@ -20,8 +21,12 @@ public class Tutorial4Activity extends Activity {
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
setRequestedOrientation
(
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
);
mView
=
new
MyGLSurfaceView
(
this
);
setContentView
(
mView
);
//mView = new MyGLSurfaceView(this, null);
//setContentView(mView);
setContentView
(
R
.
layout
.
activity
);
mView
=
(
MyGLSurfaceView
)
findViewById
(
R
.
id
.
my_gl_surface_view
);
TextView
tv
=
(
TextView
)
findViewById
(
R
.
id
.
fps_text_view
);
mView
.
setFpsTextView
(
tv
);
}
@Override
...
...
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