@@ -55,14 +55,14 @@ Manager to access OpenCV libraries externally installed in the target system.
55
55
:guilabel: `File -> Import -> Existing project in your workspace `.
56
56
57
57
Press :guilabel: `Browse ` button and locate OpenCV4Android SDK
58
- (:file: `OpenCV-2.4.3 -android-sdk/sdk `).
58
+ (:file: `OpenCV-2.4.4 -android-sdk/sdk `).
59
59
60
60
.. image :: images/eclipse_opencv_dependency0.png
61
61
:alt: Add dependency from OpenCV library
62
62
:align: center
63
63
64
64
#. In application project add a reference to the OpenCV Java SDK in
65
- :guilabel: `Project -> Properties -> Android -> Library -> Add ` select ``OpenCV Library - 2.4.3 ``.
65
+ :guilabel: `Project -> Properties -> Android -> Library -> Add ` select ``OpenCV Library - 2.4.4 ``.
66
66
67
67
.. image :: images/eclipse_opencv_dependency1.png
68
68
:alt: Add dependency from OpenCV library
@@ -128,27 +128,27 @@ described above.
128
128
#. Add the OpenCV library project to your workspace the same way as for the async initialization
129
129
above. Use menu :guilabel: `File -> Import -> Existing project in your workspace `,
130
130
press :guilabel: `Browse ` button and select OpenCV SDK path
131
- (:file: `OpenCV-2.4.3 -android-sdk/sdk `).
131
+ (:file: `OpenCV-2.4.4 -android-sdk/sdk `).
132
132
133
133
.. image :: images/eclipse_opencv_dependency0.png
134
134
:alt: Add dependency from OpenCV library
135
135
:align: center
136
136
137
137
#. In the application project add a reference to the OpenCV4Android SDK in
138
- :guilabel: `Project -> Properties -> Android -> Library -> Add ` select ``OpenCV Library - 2.4.3 ``;
138
+ :guilabel: `Project -> Properties -> Android -> Library -> Add ` select ``OpenCV Library - 2.4.4 ``;
139
139
140
140
.. image :: images/eclipse_opencv_dependency1.png
141
141
:alt: Add dependency from OpenCV library
142
142
:align: center
143
143
144
144
#. If your application project **doesn't have a JNI part **, just copy the corresponding OpenCV
145
- native libs from :file: `<OpenCV-2.4.3 -android-sdk>/sdk/native/libs/<target_arch> ` to your
145
+ native libs from :file: `<OpenCV-2.4.4 -android-sdk>/sdk/native/libs/<target_arch> ` to your
146
146
project directory to folder :file: `libs/<target_arch> `.
147
147
148
148
In case of the application project **with a JNI part **, instead of manual libraries copying you
149
149
need to modify your ``Android.mk `` file:
150
150
add the following two code lines after the ``"include $(CLEAR_VARS)" `` and before
151
- ``"include path_to_OpenCV-2.4.3 -android-sdk/sdk/native/jni/OpenCV.mk" ``
151
+ ``"include path_to_OpenCV-2.4.4 -android-sdk/sdk/native/jni/OpenCV.mk" ``
152
152
153
153
.. code-block :: make
154
154
:linenos:
@@ -221,7 +221,7 @@ taken:
221
221
222
222
.. code-block :: make
223
223
224
- include C:\Work\OpenCV4Android\OpenCV-2.4.3 -android-sdk\sdk\native\jni\OpenCV.mk
224
+ include C:\Work\OpenCV4Android\OpenCV-2.4.4 -android-sdk\sdk\native\jni\OpenCV.mk
225
225
226
226
Should be inserted into the :file: `jni/Android.mk ` file **after ** this line:
227
227
@@ -382,7 +382,7 @@ result.
382
382
OpenCVLoader . initAsync(OpenCVLoader . OPENCV_VERSION_2_4_3 , this , mLoaderCallback);
383
383
}
384
384
385
- #. Defines that your activity implements CvViewFrameListener interface and fix activity related
385
+ #. Defines that your activity implements `` CvViewFrameListener2 `` interface and fix activity related
386
386
errors by defining missed methods. For this activity define ``onCreate ``, ``onDestroy `` and
387
387
``onPause `` and implement them according code snippet bellow. Fix errors by adding requited
388
388
imports.
@@ -423,16 +423,16 @@ result.
423
423
public void onCameraViewStopped() {
424
424
}
425
425
426
- public Mat onCameraFrame(Mat inputFrame) {
427
- return inputFrame;
426
+ public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
427
+ return inputFrame. rgba() ;
428
428
}
429
429
430
430
#. Run your application on device or emulator.
431
431
432
432
Lets discuss some most important steps. Every Android application with UI must implement Activity
433
433
and View. By the first steps we create blank activity and default view layout. The simplest
434
434
OpenCV-centric application must implement OpenCV initialization, create its own view to show
435
- preview from camera and implements ``CvViewFrameListener `` interface to get frames from camera and
435
+ preview from camera and implements ``CvViewFrameListener2 `` interface to get frames from camera and
436
436
process it.
437
437
438
438
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
448
448
been already discussed above. In this sample we use asynchronous initialization. Implementation of
449
449
``CvCameraViewListener `` interface allows you to add processing steps after frame grabbing from
450
450
camera and before its rendering on screen. The most important function is ``onCameraFrame ``. It is
451
- callback function and it is called on retrieving frame from camera. The callback input is frame
452
- from camera. RGBA format is used by default. You can change this behavior by ``SetCaptureFormat ``
453
- method of ``View `` class. ``Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA `` and
454
- ``Highgui.CV_CAP_ANDROID_GREY_FRAME `` are supported. It expects that function returns RGBA frame
455
- that will be drawn on the screen.
451
+ callback function and it is called on retrieving frame from camera. The callback input is object
452
+ of ``CvCameraViewFrame `` class that represents frame from camera.
453
+
454
+ .. note ::
455
+ Do not save or use ``CvCameraViewFrame `` object out of ``onCameraFrame `` callback. This object
456
+ does not have its own state and its behavior out of callback is unpredictable!
457
+
458
+ It has ``rgba() `` and ``gray() `` methods that allows to get frame as RGBA and one channel gray scale
459
+ ``Mat `` respectively. It expects that ``onCameraFrame `` function returns RGBA frame that will be
460
+ drawn on the screen.
0 commit comments