Skip to content

Commit 891d7da

Browse files
author
Andrey Kamaev
committed
Merge branch '2.4'
2 parents c5e979c + 2be893a commit 891d7da

File tree

39 files changed

+6900
-388
lines changed

39 files changed

+6900
-388
lines changed

.gitattributes

+38-30
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
.git* export-ignore
22

3-
* text=auto
4-
* whitespace=!indent,trail,space
5-
6-
*.py text whitespace=tab-in-indent,trail,space,fix
7-
*.cpp text whitespace=tab-in-indent,trail,space,fix
8-
*.hpp text whitespace=tab-in-indent,trail,space,fix
9-
*.cxx text whitespace=tab-in-indent,trail,space,fix
10-
*.hxx text whitespace=tab-in-indent,trail,space,fix
11-
*.mm text whitespace=tab-in-indent,trail,space,fix
12-
*.c text whitespace=tab-in-indent,trail,space,fix
13-
*.h text whitespace=tab-in-indent,trail,space,fix
14-
*.i text whitespace=tab-in-indent,trail,space,fix
15-
*.java text whitespace=tab-in-indent,trail,space,fix
16-
*.cu text whitespace=tab-in-indent,trail,space,fix
17-
*.cl text whitespace=tab-in-indent,trail,space,fix
18-
19-
*.cmake text whitespace=tab-in-indent,trail,space,fix
20-
*.cmakein text whitespace=tab-in-indent,trail,space,fix
21-
*.in text whitespace=tab-in-indent,trail,space,fix
22-
CMakeLists.txt text whitespace=tab-in-indent,trail,space,fix
23-
24-
*.rst text whitespace=tab-in-indent,trail,space,fix
3+
* text=auto whitespace=trailing-space,space-before-tab,-indent-with-non-tab,tab-in-indent,tabwidth=4
4+
5+
*.py text
6+
*.cpp text
7+
*.hpp text
8+
*.cxx text
9+
*.hxx text
10+
*.mm text
11+
*.c text
12+
*.h text
13+
*.i text
14+
*.js text
15+
*.java text
16+
*.scala text
17+
*.cu text
18+
*.cl text
19+
*.css_t text
20+
*.qrc text
21+
*.qss text
22+
*.S text
23+
*.rst text
24+
*.tex text
25+
*.sty text
26+
27+
*.aidl text
28+
*.mk text
29+
30+
*.cmake text whitespace=tabwidth=2
31+
*.cmakein text whitespace=tabwidth=2
32+
*.in text whitespace=tabwidth=2
33+
CMakeLists.txt text whitespace=tabwidth=2
2534

2635
*.png binary
2736
*.jepg binary
@@ -32,22 +41,21 @@ CMakeLists.txt text whitespace=tab-in-indent,trail,space,fix
3241
*.a binary
3342
*.so binary
3443
*.dll binary
44+
*.jar binary
3545

3646
*.pdf binary
3747
*.pbxproj binary
3848
*.vec binary
3949
*.doc binary
4050

41-
*.css_t text
42-
*.qrc text
43-
*.qss text
44-
*.S text
45-
46-
*.xml -text
47-
*.yml -text
51+
*.xml -text whitespace=cr-at-eol
52+
*.yml -text whitespace=cr-at-eol
53+
.project -text whitespace=cr-at-eol merge=union
54+
.classpath -text whitespace=cr-at-eol merge=union
55+
.cproject -text whitespace=cr-at-eol merge=union
56+
org.eclipse.jdt.core.prefs -text whitespace=cr-at-eol merge=union
4857

4958
*.vcproj text eol=crlf merge=union
50-
*.cproject text eol=crlf merge=union
5159
*.bat text eol=crlf
5260
*.cmd text eol=crlf
5361
*.cmd.tmpl text eol=crlf

android/service/engine/jni/BinderComponent/OpenCVEngine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using namespace android;
1515

1616
const int OpenCVEngine::Platform = DetectKnownPlatforms();
1717
const int OpenCVEngine::CpuID = GetCpuID();
18-
const int OpenCVEngine::KnownVersions[] = {2040000, 2040100, 2040200, 2040300, 2040301, 2040302};
18+
const int OpenCVEngine::KnownVersions[] = {2040000, 2040100, 2040200, 2040300, 2040301, 2040302, 2040400};
1919

2020
bool OpenCVEngine::ValidateVersion(int version)
2121
{

android/service/engine/jni/Tests/OpenCVEngineTest.cpp

+60
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,66 @@ TEST(OpenCVEngineTest, InstallAndGetVersion)
218218
#endif
219219
#endif
220220
}
221+
222+
TEST(OpenCVEngineTest, GetPathFor2_4_2)
223+
{
224+
sp<IOpenCVEngine> Engine = InitConnect();
225+
Starter.PackageManager->InstalledPackages.clear();
226+
Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_ARMv7);
227+
EXPECT_FALSE(NULL == Engine.get());
228+
String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
229+
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
230+
}
231+
232+
TEST(OpenCVEngineTest, GetPathFor2_4_3)
233+
{
234+
sp<IOpenCVEngine> Engine = InitConnect();
235+
Starter.PackageManager->InstalledPackages.clear();
236+
Starter.PackageManager->InstallVersion(2040300, PLATFORM_UNKNOWN, ARCH_ARMv7);
237+
EXPECT_FALSE(NULL == Engine.get());
238+
String16 result = Engine->GetLibPathByVersion(String16("2.4.3"));
239+
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
240+
}
241+
242+
TEST(OpenCVEngineTest, GetPathFor2_4_3_1)
243+
{
244+
sp<IOpenCVEngine> Engine = InitConnect();
245+
Starter.PackageManager->InstalledPackages.clear();
246+
Starter.PackageManager->InstallVersion(2040301, PLATFORM_UNKNOWN, ARCH_ARMv7);
247+
EXPECT_FALSE(NULL == Engine.get());
248+
String16 result = Engine->GetLibPathByVersion(String16("2.4.3.1"));
249+
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
250+
}
251+
252+
TEST(OpenCVEngineTest, GetPathFor2_4_3_2)
253+
{
254+
sp<IOpenCVEngine> Engine = InitConnect();
255+
Starter.PackageManager->InstalledPackages.clear();
256+
Starter.PackageManager->InstallVersion(2040302, PLATFORM_UNKNOWN, ARCH_ARMv7);
257+
EXPECT_FALSE(NULL == Engine.get());
258+
String16 result = Engine->GetLibPathByVersion(String16("2.4.3.2"));
259+
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
260+
}
261+
262+
TEST(OpenCVEngineTest, GetPathFor2_4_4)
263+
{
264+
sp<IOpenCVEngine> Engine = InitConnect();
265+
Starter.PackageManager->InstalledPackages.clear();
266+
Starter.PackageManager->InstallVersion(2040400, PLATFORM_UNKNOWN, ARCH_ARMv7);
267+
EXPECT_FALSE(NULL == Engine.get());
268+
String16 result = Engine->GetLibPathByVersion(String16("2.4.4"));
269+
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
270+
}
271+
272+
TEST(OpenCVEngineTest, GetPathFor2_4_5)
273+
{
274+
sp<IOpenCVEngine> Engine = InitConnect();
275+
Starter.PackageManager->InstalledPackages.clear();
276+
Starter.PackageManager->InstallVersion(2040500, PLATFORM_UNKNOWN, ARCH_ARMv7);
277+
EXPECT_FALSE(NULL == Engine.get());
278+
String16 result = Engine->GetLibPathByVersion(String16("2.4.5"));
279+
EXPECT_EQ(0, result.size()); // 2.4.5 is not published yet
280+
}
221281
#endif
222282

223283
#ifndef __i386__

cmake/OpenCVDetectCUDA.cmake

+42-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,48 @@ if(CUDA_FOUND)
3333

3434
message(STATUS "CUDA detected: " ${CUDA_VERSION})
3535

36-
set(CUDA_ARCH_BIN "1.1 1.2 1.3 2.0 2.1(2.0) 3.0" CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported")
37-
set(CUDA_ARCH_PTX "2.0 3.0" CACHE STRING "Specify 'virtual' PTX architectures to build PTX intermediate code for")
36+
set(_generations "Fermi" "Kepler")
37+
if(NOT CMAKE_CROSSCOMPILING)
38+
list(APPEND _generations "Auto")
39+
endif()
40+
set(CUDA_GENERATION "" CACHE STRING "Build CUDA device code only for specific GPU architecture. Leave empty to build for all architectures.")
41+
if( CMAKE_VERSION VERSION_GREATER "2.8" )
42+
set_property( CACHE CUDA_GENERATION PROPERTY STRINGS "" ${_generations} )
43+
endif()
44+
45+
if(CUDA_GENERATION)
46+
if(NOT ";${_generations};" MATCHES ";${CUDA_GENERATION};")
47+
string(REPLACE ";" ", " _generations "${_generations}")
48+
message(FATAL_ERROR "ERROR: ${_generations} Generations are suppered.")
49+
endif()
50+
unset(CUDA_ARCH_BIN CACHE)
51+
unset(CUDA_ARCH_PTX CACHE)
52+
endif()
53+
54+
set(__cuda_arch_ptx "")
55+
if(CUDA_GENERATION STREQUAL "Fermi")
56+
set(__cuda_arch_bin "2.0 2.1(2.0)")
57+
elseif(CUDA_GENERATION STREQUAL "Kepler")
58+
set(__cuda_arch_bin "3.0")
59+
elseif(CUDA_GENERATION STREQUAL "Auto")
60+
execute_process( COMMAND "${CUDA_NVCC_EXECUTABLE}" "${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCudaArch.cu" "--run"
61+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
62+
RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out
63+
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
64+
if(NOT _nvcc_res EQUAL 0)
65+
message(STATUS "Automatic detection of CUDA generation failed. Going to build for all known architectures.")
66+
else()
67+
set(__cuda_arch_bin "${_nvcc_out}")
68+
endif()
69+
endif()
70+
71+
if(NOT DEFINED __cuda_arch_bin)
72+
set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0")
73+
set(__cuda_arch_ptx "2.0 3.0")
74+
endif()
75+
76+
set(CUDA_ARCH_BIN ${__cuda_arch_bin} CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported")
77+
set(CUDA_ARCH_PTX ${__cuda_arch_ptx} CACHE STRING "Specify 'virtual' PTX architectures to build PTX intermediate code for")
3878

3979
string(REGEX REPLACE "\\." "" ARCH_BIN_NO_POINTS "${CUDA_ARCH_BIN}")
4080
string(REGEX REPLACE "\\." "" ARCH_PTX_NO_POINTS "${CUDA_ARCH_PTX}")

cmake/OpenCVDetectCudaArch.cu

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdio.h>
2+
int main()
3+
{
4+
int count = 0;
5+
if (cudaSuccess != cudaGetDeviceCount(&count)){return -1;}
6+
if (count == 0) {return -1;}
7+
for (int device = 0; device < count; ++device)
8+
{
9+
cudaDeviceProp prop;
10+
if (cudaSuccess != cudaGetDeviceProperties(&prop, device)){ continue;}
11+
printf("%d.%d ", prop.major, prop.minor);
12+
}
13+
return 0;
14+
}

cmake/templates/OpenCV.mk.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ else
4242
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
4343
endif
4444
ifeq ($(TARGET_ARCH_ABI),mips)
45-
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB@
45+
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE@
4646
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
4747
endif
4848
endif

doc/tutorials/introduction/android_binary_package/O4A_SDK.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ The structure of package contents looks as follows:
4848

4949
::
5050

51-
OpenCV-2.4.3-android-sdk
51+
OpenCV-2.4.4-android-sdk
5252
|_ apk
53-
| |_ OpenCV_2.4.3_binary_pack_armv7a.apk
54-
| |_ OpenCV_2.4.3_Manager_2.0_XXX.apk
53+
| |_ OpenCV_2.4.4_binary_pack_armv7a.apk
54+
| |_ OpenCV_2.4.4_Manager_2.6_XXX.apk
5555
|
5656
|_ doc
5757
|_ samples
@@ -157,10 +157,10 @@ Get the OpenCV4Android SDK
157157

158158
.. code-block:: bash
159159
160-
unzip ~/Downloads/OpenCV-2.4.3-android-sdk.zip
160+
unzip ~/Downloads/OpenCV-2.4.4-android-sdk.zip
161161
162-
.. |opencv_android_bin_pack| replace:: OpenCV-2.4.3.2-android-sdk.zip
163-
.. _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
162+
.. |opencv_android_bin_pack| replace:: OpenCV-2.4.4-android-sdk.zip
163+
.. _opencv_android_bin_pack_url: http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.4/OpenCV-2.4.4-android-sdk.zip/download
164164
.. |opencv_android_bin_pack_url| replace:: |opencv_android_bin_pack|
165165
.. |seven_zip| replace:: 7-Zip
166166
.. _seven_zip: http://www.7-zip.org/
@@ -295,7 +295,7 @@ Well, running samples from Eclipse is very simple:
295295
.. code-block:: sh
296296
:linenos:
297297
298-
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.3_Manager_armv7a-neon.apk
298+
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.4_Manager_armv7a-neon.apk
299299
300300
.. note:: ``armeabi``, ``armv7a-neon``, ``arm7a-neon-android8``, ``mips`` and ``x86`` stand for
301301
platform targets:

doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.rst

+21-16
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ Manager to access OpenCV libraries externally installed in the target system.
5555
:guilabel:`File -> Import -> Existing project in your workspace`.
5656

5757
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`).
5959

6060
.. image:: images/eclipse_opencv_dependency0.png
6161
:alt: Add dependency from OpenCV library
6262
:align: center
6363

6464
#. 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``.
6666

6767
.. image:: images/eclipse_opencv_dependency1.png
6868
:alt: Add dependency from OpenCV library
@@ -128,27 +128,27 @@ described above.
128128
#. Add the OpenCV library project to your workspace the same way as for the async initialization
129129
above. Use menu :guilabel:`File -> Import -> Existing project in your workspace`,
130130
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`).
132132

133133
.. image:: images/eclipse_opencv_dependency0.png
134134
:alt: Add dependency from OpenCV library
135135
:align: center
136136

137137
#. 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``;
139139

140140
.. image:: images/eclipse_opencv_dependency1.png
141141
:alt: Add dependency from OpenCV library
142142
:align: center
143143

144144
#. 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
146146
project directory to folder :file:`libs/<target_arch>`.
147147

148148
In case of the application project **with a JNI part**, instead of manual libraries copying you
149149
need to modify your ``Android.mk`` file:
150150
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"``
152152

153153
.. code-block:: make
154154
:linenos:
@@ -221,7 +221,7 @@ taken:
221221

222222
.. code-block:: make
223223
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
225225
226226
Should be inserted into the :file:`jni/Android.mk` file **after** this line:
227227

@@ -382,7 +382,7 @@ result.
382382
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
383383
}
384384
385-
#. Defines that your activity implements CvViewFrameListener interface and fix activity related
385+
#. Defines that your activity implements ``CvViewFrameListener2`` interface and fix activity related
386386
errors by defining missed methods. For this activity define ``onCreate``, ``onDestroy`` and
387387
``onPause`` and implement them according code snippet bellow. Fix errors by adding requited
388388
imports.
@@ -423,16 +423,16 @@ result.
423423
public void onCameraViewStopped() {
424424
}
425425
426-
public Mat onCameraFrame(Mat inputFrame) {
427-
return inputFrame;
426+
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
427+
return inputFrame.rgba();
428428
}
429429
430430
#. Run your application on device or emulator.
431431

432432
Lets discuss some most important steps. Every Android application with UI must implement Activity
433433
and View. By the first steps we create blank activity and default view layout. The simplest
434434
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
436436
process it.
437437

438438
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
448448
been already discussed above. In this sample we use asynchronous initialization. Implementation of
449449
``CvCameraViewListener`` interface allows you to add processing steps after frame grabbing from
450450
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

Comments
 (0)