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
24c920a3
Commit
24c920a3
authored
Nov 27, 2012
by
Alexander Smorkalov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Base for new sample added.
parent
03f40289
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
251 additions
and
0 deletions
+251
-0
CMakeLists.txt
samples/android/CMakeLists.txt
+1
-0
.classpath
samples/android/tutorial-5-customcamera/.classpath
+8
-0
.project
samples/android/tutorial-5-customcamera/.project
+33
-0
org.eclipse.jdt.core.prefs
...orial-5-customcamera/.settings/org.eclipse.jdt.core.prefs
+4
-0
AndroidManifest.xml
samples/android/tutorial-5-customcamera/AndroidManifest.xml
+38
-0
CMakeLists.txt
samples/android/tutorial-5-customcamera/CMakeLists.txt
+7
-0
icon.png
...les/android/tutorial-5-customcamera/res/drawable/icon.png
+0
-0
tutorial5_surface_view.xml
...rial-5-customcamera/res/layout/tutorial5_surface_view.xml
+12
-0
strings.xml
...es/android/tutorial-5-customcamera/res/values/strings.xml
+4
-0
CustomJavaCameraView.java
...rc/org/opencv/samples/tutorial5/CustomJavaCameraView.java
+19
-0
Sample5CustomCamera.java
...src/org/opencv/samples/tutorial5/Sample5CustomCamera.java
+125
-0
No files found.
samples/android/CMakeLists.txt
View file @
24c920a3
...
...
@@ -16,6 +16,7 @@ add_subdirectory(tutorial-1-addopencv)
add_subdirectory
(
tutorial-2-opencvcamera
)
add_subdirectory
(
tutorial-3-native
)
add_subdirectory
(
tutorial-4-mixed
)
add_subdirectory
(
tutorial-5-customcamera
)
#hello-android sample
if
(
HAVE_opencv_highgui
)
...
...
samples/android/tutorial-5-customcamera/.classpath
0 → 100644
View file @
24c920a3
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"con"
path=
"com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"
/>
<classpathentry
kind=
"con"
path=
"com.android.ide.eclipse.adt.LIBRARIES"
/>
<classpathentry
kind=
"src"
path=
"src"
/>
<classpathentry
kind=
"src"
path=
"gen"
/>
<classpathentry
kind=
"output"
path=
"bin/classes"
/>
</classpath>
samples/android/tutorial-5-customcamera/.project
0 → 100644
View file @
24c920a3
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
OpenCV Tutorial 5 - Custom camera
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
com.android.ide.eclipse.adt.ResourceManagerBuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
com.android.ide.eclipse.adt.PreCompilerBuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
com.android.ide.eclipse.adt.ApkBuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
com.android.ide.eclipse.adt.AndroidNature
</nature>
<nature>
org.eclipse.jdt.core.javanature
</nature>
</natures>
</projectDescription>
samples/android/tutorial-5-customcamera/.settings/org.eclipse.jdt.core.prefs
0 → 100644
View file @
24c920a3
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
samples/android/tutorial-5-customcamera/AndroidManifest.xml
0 → 100644
View file @
24c920a3
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"org.opencv.samples.tutorial5"
android:versionCode=
"21"
android:versionName=
"2.1"
>
<application
android:label=
"@string/app_name"
android:icon=
"@drawable/icon"
android:theme=
"@android:style/Theme.NoTitleBar.Fullscreen"
>
<activity
android:name=
"Sample5CustomCamera"
android:label=
"@string/app_name"
android:screenOrientation=
"landscape"
android:configChanges=
"keyboardHidden|orientation"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
<supports-screens
android:resizeable=
"true"
android:smallScreens=
"true"
android:normalScreens=
"true"
android:largeScreens=
"true"
android:anyDensity=
"true"
/>
<uses-sdk
android:minSdkVersion=
"8"
/>
<uses-permission
android:name=
"android.permission.CAMERA"
/>
<uses-feature
android:name=
"android.hardware.camera"
android:required=
"false"
/>
<uses-feature
android:name=
"android.hardware.camera.autofocus"
android:required=
"false"
/>
<uses-feature
android:name=
"android.hardware.camera.front"
android:required=
"false"
/>
<uses-feature
android:name=
"android.hardware.camera.front.autofocus"
android:required=
"false"
/>
</manifest>
samples/android/tutorial-5-customcamera/CMakeLists.txt
0 → 100644
View file @
24c920a3
set
(
sample example-tutorial-5-customcamera
)
add_android_project
(
${
sample
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
LIBRARY_DEPS
${
OpenCV_BINARY_DIR
}
SDK_TARGET 11
${
ANDROID_SDK_TARGET
}
)
if
(
TARGET
${
sample
}
)
add_dependencies
(
opencv_android_examples
${
sample
}
)
endif
()
samples/android/tutorial-5-customcamera/res/drawable/icon.png
0 → 100644
View file @
24c920a3
1.95 KB
samples/android/tutorial-5-customcamera/res/layout/tutorial5_surface_view.xml
0 → 100644
View file @
24c920a3
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<org.opencv.samples.tutorial5.CustomJavaCameraView
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
android:visibility=
"gone"
android:id=
"@+id/tutorial5_activity_java_surface_view"
/>
</LinearLayout>
samples/android/tutorial-5-customcamera/res/values/strings.xml
0 → 100644
View file @
24c920a3
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string
name=
"app_name"
>
OCV T5 Custom Camera
</string>
</resources>
samples/android/tutorial-5-customcamera/src/org/opencv/samples/tutorial5/CustomJavaCameraView.java
0 → 100644
View file @
24c920a3
package
org
.
opencv
.
samples
.
tutorial5
;
import
org.opencv.android.JavaCameraView
;
import
android.content.Context
;
import
android.util.AttributeSet
;
public
class
CustomJavaCameraView
extends
JavaCameraView
{
public
CustomJavaCameraView
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
@Override
protected
boolean
connectCamera
(
int
width
,
int
height
)
{
boolean
result
=
super
.
connectCamera
(
width
,
height
);
return
result
;
}
}
samples/android/tutorial-5-customcamera/src/org/opencv/samples/tutorial5/Sample5CustomCamera.java
0 → 100644
View file @
24c920a3
package
org
.
opencv
.
samples
.
tutorial5
;
import
org.opencv.android.BaseLoaderCallback
;
import
org.opencv.android.LoaderCallbackInterface
;
import
org.opencv.android.OpenCVLoader
;
import
org.opencv.core.Mat
;
import
org.opencv.android.CameraBridgeViewBase
;
import
org.opencv.android.CameraBridgeViewBase.CvCameraViewListener
;
import
android.app.Activity
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.view.SurfaceView
;
import
android.view.WindowManager
;
import
android.widget.Toast
;
public
class
Sample5CustomCamera
extends
Activity
implements
CvCameraViewListener
{
private
static
final
String
TAG
=
"OCVSample::Activity"
;
private
CameraBridgeViewBase
mOpenCvCameraView
;
private
boolean
mIsJavaCamera
=
true
;
private
MenuItem
mItemSwitchCamera
=
null
;
private
BaseLoaderCallback
mLoaderCallback
=
new
BaseLoaderCallback
(
this
)
{
@Override
public
void
onManagerConnected
(
int
status
)
{
switch
(
status
)
{
case
LoaderCallbackInterface
.
SUCCESS
:
{
Log
.
i
(
TAG
,
"OpenCV loaded successfully"
);
mOpenCvCameraView
.
enableView
();
}
break
;
default
:
{
super
.
onManagerConnected
(
status
);
}
break
;
}
}
};
public
Sample5CustomCamera
()
{
Log
.
i
(
TAG
,
"Instantiated new "
+
this
.
getClass
());
}
/** Called when the activity is first created. */
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
Log
.
i
(
TAG
,
"called onCreate"
);
super
.
onCreate
(
savedInstanceState
);
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
setContentView
(
R
.
layout
.
tutorial5_surface_view
);
if
(
mIsJavaCamera
)
mOpenCvCameraView
=
(
CameraBridgeViewBase
)
findViewById
(
R
.
id
.
tutorial5_activity_java_surface_view
);
mOpenCvCameraView
.
setVisibility
(
SurfaceView
.
VISIBLE
);
mOpenCvCameraView
.
setCvCameraViewListener
(
this
);
}
@Override
public
void
onPause
()
{
if
(
mOpenCvCameraView
!=
null
)
mOpenCvCameraView
.
disableView
();
super
.
onPause
();
}
@Override
public
void
onResume
()
{
super
.
onResume
();
OpenCVLoader
.
initAsync
(
OpenCVLoader
.
OPENCV_VERSION_2_4_3
,
this
,
mLoaderCallback
);
}
public
void
onDestroy
()
{
super
.
onDestroy
();
if
(
mOpenCvCameraView
!=
null
)
mOpenCvCameraView
.
disableView
();
}
@Override
public
boolean
onCreateOptionsMenu
(
Menu
menu
)
{
Log
.
i
(
TAG
,
"called onCreateOptionsMenu"
);
mItemSwitchCamera
=
menu
.
add
(
"Switch camera"
);
return
true
;
}
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
String
toastMesage
=
new
String
();
Log
.
i
(
TAG
,
"called onOptionsItemSelected; selected item: "
+
item
);
if
(
item
==
mItemSwitchCamera
)
{
mOpenCvCameraView
.
setVisibility
(
SurfaceView
.
GONE
);
mIsJavaCamera
=
!
mIsJavaCamera
;
if
(
mIsJavaCamera
)
{
mOpenCvCameraView
=
(
CameraBridgeViewBase
)
findViewById
(
R
.
id
.
tutorial5_activity_java_surface_view
);
toastMesage
=
"Java Camera"
;
}
mOpenCvCameraView
.
setVisibility
(
SurfaceView
.
VISIBLE
);
mOpenCvCameraView
.
setCvCameraViewListener
(
this
);
mOpenCvCameraView
.
enableView
();
Toast
toast
=
Toast
.
makeText
(
this
,
toastMesage
,
Toast
.
LENGTH_LONG
);
toast
.
show
();
}
return
true
;
}
public
void
onCameraViewStarted
(
int
width
,
int
height
)
{
}
public
void
onCameraViewStopped
()
{
}
public
Mat
onCameraFrame
(
Mat
inputFrame
)
{
return
inputFrame
;
}
}
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