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
0e5255d4
Commit
0e5255d4
authored
Feb 26, 2013
by
cuda-geek
Committed by
OpenCV Buildbot
Feb 26, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #561 from asmorkalov:android_tutorial_2_4_4_update
parents
2304d536
8458f5c4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
33 deletions
+45
-33
O4A_SDK.rst
...tutorials/introduction/android_binary_package/O4A_SDK.rst
+7
-7
dev_with_OCV_on_Android.rst
...uction/android_binary_package/dev_with_OCV_on_Android.rst
+21
-16
android+CameraBridgeViewBase.java
...java/generator/src/java/android+CameraBridgeViewBase.java
+14
-2
ImageManipulationsActivity.java
...amples/imagemanipulations/ImageManipulationsActivity.java
+3
-8
No files found.
doc/tutorials/introduction/android_binary_package/O4A_SDK.rst
View file @
0e5255d4
...
...
@@ -48,10 +48,10 @@ The structure of package contents looks as follows:
::
OpenCV-2.4.
3
-android-sdk
OpenCV-2.4.
4
-android-sdk
|_ apk
| |_ OpenCV_2.4.
3
_binary_pack_armv7a.apk
| |_ OpenCV_2.4.
3_Manager_2.0
_XXX.apk
| |_ OpenCV_2.4.
4
_binary_pack_armv7a.apk
| |_ OpenCV_2.4.
4_Manager_2.6
_XXX.apk
|
|_ doc
|_ samples
...
...
@@ -157,10 +157,10 @@ Get the OpenCV4Android SDK
.. code-block:: bash
unzip ~/Downloads/OpenCV-2.4.
3
-android-sdk.zip
unzip ~/Downloads/OpenCV-2.4.
4
-android-sdk.zip
.. |opencv_android_bin_pack| replace:: OpenCV-2.4.
3.2
-android-sdk.zip
.. _opencv_android_bin_pack_url: http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.
3/OpenCV-2.4.3.2
-android-sdk.zip/download
.. |opencv_android_bin_pack| replace:: OpenCV-2.4.
4
-android-sdk.zip
.. _opencv_android_bin_pack_url: http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.
4/OpenCV-2.4.4
-android-sdk.zip/download
.. |opencv_android_bin_pack_url| replace:: |opencv_android_bin_pack|
.. |seven_zip| replace:: 7-Zip
.. _seven_zip: http://www.7-zip.org/
...
...
@@ -295,7 +295,7 @@ Well, running samples from Eclipse is very simple:
.. code-block:: sh
:linenos:
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.
3
_Manager_armv7a-neon.apk
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.
4
_Manager_armv7a-neon.apk
.. note:: ``armeabi``, ``armv7a-neon``, ``arm7a-neon-android8``, ``mips`` and ``x86`` stand for
platform targets:
...
...
doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.rst
View file @
0e5255d4
...
...
@@ -55,14 +55,14 @@ Manager to access OpenCV libraries externally installed in the target system.
:guilabel:`File -> Import -> Existing project in your workspace`.
Press :guilabel:`Browse` button and locate OpenCV4Android SDK
(:file:`OpenCV-2.4.
3
-android-sdk/sdk`).
(:file:`OpenCV-2.4.
4
-android-sdk/sdk`).
.. image:: images/eclipse_opencv_dependency0.png
:alt: Add dependency from OpenCV library
:align: center
#. In application project add a reference to the OpenCV Java SDK in
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.
3
``.
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.
4
``.
.. image:: images/eclipse_opencv_dependency1.png
:alt: Add dependency from OpenCV library
...
...
@@ -128,27 +128,27 @@ described above.
#. Add the OpenCV library project to your workspace the same way as for the async initialization
above. Use menu :guilabel:`File -> Import -> Existing project in your workspace`,
press :guilabel:`Browse` button and select OpenCV SDK path
(:file:`OpenCV-2.4.
3
-android-sdk/sdk`).
(:file:`OpenCV-2.4.
4
-android-sdk/sdk`).
.. image:: images/eclipse_opencv_dependency0.png
:alt: Add dependency from OpenCV library
:align: center
#. In the application project add a reference to the OpenCV4Android SDK in
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.
3
``;
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.
4
``;
.. image:: images/eclipse_opencv_dependency1.png
:alt: Add dependency from OpenCV library
:align: center
#. If your application project **doesn't have a JNI part**, just copy the corresponding OpenCV
native libs from :file:`<OpenCV-2.4.
3-android-sdk>/sdk/native/libs/<target_arch>` to your
native libs from :file:`<OpenCV-2.4.
4-android-sdk>/sdk/native/libs/<target_arch>` to your
project directory to folder :file:`libs/<target_arch>`.
In case of the application project **with a JNI part**, instead of manual libraries copying you
need to modify your ``Android.mk`` file:
add the following two code lines after the ``"include $(CLEAR_VARS)"`` and before
``"include path_to_OpenCV-2.4.
3
-android-sdk/sdk/native/jni/OpenCV.mk"``
``"include path_to_OpenCV-2.4.
4
-android-sdk/sdk/native/jni/OpenCV.mk"``
.. code-block:: make
:linenos:
...
...
@@ -221,7 +221,7 @@ taken:
.. code-block:: make
include C:\Work\OpenCV4Android\OpenCV-2.4.
3
-android-sdk\sdk\native\jni\OpenCV.mk
include C:\Work\OpenCV4Android\OpenCV-2.4.
4
-android-sdk\sdk\native\jni\OpenCV.mk
Should be inserted into the :file:`jni/Android.mk` file **after** this line:
...
...
@@ -382,7 +382,7 @@ result.
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
}
#. Defines that your activity implements
CvViewFrameListener
interface and fix activity related
#. Defines that your activity implements
``CvViewFrameListener2``
interface and fix activity related
errors by defining missed methods. For this activity define ``onCreate``, ``onDestroy`` and
``onPause`` and implement them according code snippet bellow. Fix errors by adding requited
imports.
...
...
@@ -423,8 +423,8 @@ result.
public void onCameraViewStopped() {
}
public Mat onCameraFrame(
Mat
inputFrame) {
return inputFrame;
public Mat onCameraFrame(
CvCameraViewFrame
inputFrame) {
return inputFrame
.rgba()
;
}
#. Run your application on device or emulator.
...
...
@@ -432,7 +432,7 @@ result.
Lets discuss some most important steps. Every Android application with UI must implement Activity
and View. By the first steps we create blank activity and default view layout. The simplest
OpenCV-centric application must implement OpenCV initialization, create its own view to show
preview from camera and implements ``CvViewFrameListener`` interface to get frames from camera and
preview from camera and implements ``CvViewFrameListener
2
`` interface to get frames from camera and
process it.
First of all we create our application view using xml layout. Our layout consists of the only
...
...
@@ -448,8 +448,13 @@ After creating layout we need to implement ``Activity`` class. OpenCV initializa
been already discussed above. In this sample we use asynchronous initialization. Implementation of
``CvCameraViewListener`` interface allows you to add processing steps after frame grabbing from
camera and before its rendering on screen. The most important function is ``onCameraFrame``. It is
callback function and it is called on retrieving frame from camera. The callback input is frame
from camera. RGBA format is used by default. You can change this behavior by ``SetCaptureFormat``
method of ``View`` class. ``Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA`` and
``Highgui.CV_CAP_ANDROID_GREY_FRAME`` are supported. It expects that function returns RGBA frame
that will be drawn on the screen.
callback function and it is called on retrieving frame from camera. The callback input is object
of ``CvCameraViewFrame`` class that represents frame from camera.
.. note::
Do not save or use ``CvCameraViewFrame`` object out of ``onCameraFrame`` callback. This object
does not have its own state and its behavior out of callback is unpredictable!
It has ``rgba()`` and ``gray()`` methods that allows to get frame as RGBA and one channel gray scale
``Mat`` respectively. It expects that ``onCameraFrame`` function returns RGBA frame that will be
drawn on the screen.
modules/java/generator/src/java/android+CameraBridgeViewBase.java
View file @
0e5255d4
...
...
@@ -156,9 +156,21 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac
private
CvCameraViewListener
mOldStyleListener
;
};
/**
* This class interface is abstract representation of single frame from camera for onCameraFrame callback
* Attention: Do not use objects, that represents this interface out of onCameraFrame callback!
*/
public
interface
CvCameraViewFrame
{
public
abstract
Mat
rgba
();
public
abstract
Mat
gray
();
/**
* This method returns RGBA Mat with frame
*/
public
Mat
rgba
();
/**
* This method returns single channel gray scale Mat with frame
*/
public
Mat
gray
();
};
public
void
surfaceChanged
(
SurfaceHolder
arg0
,
int
arg1
,
int
arg2
,
int
arg3
)
{
...
...
samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java
View file @
0e5255d4
...
...
@@ -68,7 +68,6 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView
private
float
mBuff
[];
private
Mat
mRgbaInnerWindow
;
private
Mat
mGrayInnerWindow
;
private
Mat
mBlurWindow
;
private
Mat
mZoomWindow
;
private
Mat
mZoomCorner
;
private
Mat
mSepiaKernel
;
...
...
@@ -220,9 +219,6 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView
if
(
mGrayInnerWindow
==
null
&&
!
mGray
.
empty
())
mGrayInnerWindow
=
mGray
.
submat
(
top
,
top
+
height
,
left
,
left
+
width
);
if
(
mBlurWindow
==
null
)
mBlurWindow
=
mRgba
.
submat
(
0
,
rows
,
cols
/
3
,
cols
*
2
/
3
);
if
(
mZoomCorner
==
null
)
mZoomCorner
=
mRgba
.
submat
(
0
,
rows
/
2
-
rows
/
10
,
0
,
cols
/
2
-
cols
/
10
);
...
...
@@ -236,8 +232,6 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView
mZoomWindow
.
release
();
if
(
mZoomCorner
!=
null
)
mZoomCorner
.
release
();
if
(
mBlurWindow
!=
null
)
mBlurWindow
.
release
();
if
(
mGrayInnerWindow
!=
null
)
mGrayInnerWindow
.
release
();
if
(
mRgbaInnerWindow
!=
null
)
...
...
@@ -254,7 +248,6 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView
mIntermediateMat
=
null
;
mRgbaInnerWindow
=
null
;
mGrayInnerWindow
=
null
;
mBlurWindow
=
null
;
mZoomCorner
=
null
;
mZoomWindow
=
null
;
}
...
...
@@ -327,7 +320,9 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView
break
;
case
ImageManipulationsActivity
.
VIEW_MODE_SEPIA
:
Core
.
transform
(
mRgba
,
mRgba
,
mSepiaKernel
);
if
((
mRgbaInnerWindow
==
null
)
||
(
mRgba
.
cols
()
!=
mSizeRgba
.
width
)
||
(
mRgba
.
height
()
!=
mSizeRgba
.
height
))
CreateAuxiliaryMats
();
Core
.
transform
(
mRgbaInnerWindow
,
mRgbaInnerWindow
,
mSepiaKernel
);
break
;
case
ImageManipulationsActivity
.
VIEW_MODE_ZOOM
:
...
...
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