mirror of
https://github.com/opencv/opencv.git
synced 2024-12-03 16:35:09 +08:00
Fixed layout in third Android tutorial
This commit is contained in:
parent
3c8e151c73
commit
62f9c0e140
11
doc/_themes/blue/static/default.css_t
vendored
11
doc/_themes/blue/static/default.css_t
vendored
@ -175,6 +175,8 @@ a:hover {
|
|||||||
div.body p, div.body dd, div.body li {
|
div.body p, div.body dd, div.body li {
|
||||||
text-align: justify;
|
text-align: justify;
|
||||||
line-height: 130%;
|
line-height: 130%;
|
||||||
|
margin-top: 1em;
|
||||||
|
margin-bottom: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.body h1,
|
div.body h1,
|
||||||
@ -327,9 +329,9 @@ table.field-list {
|
|||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.simple {
|
/*ul.simple {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
em.menuselection, em.guilabel {
|
em.menuselection, em.guilabel {
|
||||||
font-family: {{ theme_guifont }};
|
font-family: {{ theme_guifont }};
|
||||||
@ -384,3 +386,8 @@ margin-top: 0px;
|
|||||||
div.body ul.search li {
|
div.body ul.search li {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.linenodiv {
|
||||||
|
min-width: 1em;
|
||||||
|
text-align: right;
|
||||||
|
}
|
@ -57,7 +57,7 @@ Using async initialization is a **recommended** way for application development.
|
|||||||
To run OpenCV Manager-based application the first time you need to install packages with the `OpenCV Manager` and `OpenCV binary pack` for you platform.
|
To run OpenCV Manager-based application the first time you need to install packages with the `OpenCV Manager` and `OpenCV binary pack` for you platform.
|
||||||
You can do it using Google Play Market or manually with ``adb`` tool:
|
You can do it using Google Play Market or manually with ``adb`` tool:
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.2_Manager.apk
|
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.2_Manager.apk
|
||||||
@ -266,12 +266,12 @@ It will be capable of accessing camera output, processing it and displaying the
|
|||||||
#. Set name, target, package and minSDKVersion accordingly.
|
#. Set name, target, package and minSDKVersion accordingly.
|
||||||
|
|
||||||
#. Create a new class (*File -> New -> Class*). Name it for example: *HelloOpenCVView*.
|
#. Create a new class (*File -> New -> Class*). Name it for example: *HelloOpenCVView*.
|
||||||
|
|
||||||
.. image:: images/dev_OCV_new_class.png
|
.. image:: images/dev_OCV_new_class.png
|
||||||
:alt: Add a new class.
|
:alt: Add a new class.
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
* It should extend *SurfaceView* class.
|
* It should extend *SurfaceView* class.
|
||||||
|
|
||||||
* It also should implement *SurfaceHolder.Callback*, *Runnable*.
|
* It also should implement *SurfaceHolder.Callback*, *Runnable*.
|
||||||
|
|
||||||
#. Edit *HelloOpenCVView* class.
|
#. Edit *HelloOpenCVView* class.
|
||||||
@ -279,7 +279,9 @@ It will be capable of accessing camera output, processing it and displaying the
|
|||||||
* Add an *import* line for *android.content.context*.
|
* Add an *import* line for *android.content.context*.
|
||||||
|
|
||||||
* Modify autogenerated stubs: *HelloOpenCVView*, *surfaceCreated*, *surfaceDestroyed* and *surfaceChanged*.
|
* Modify autogenerated stubs: *HelloOpenCVView*, *surfaceCreated*, *surfaceDestroyed* and *surfaceChanged*.
|
||||||
|
|
||||||
.. code-block:: java
|
.. code-block:: java
|
||||||
|
:linenos:
|
||||||
|
|
||||||
package com.hello.opencv.test;
|
package com.hello.opencv.test;
|
||||||
|
|
||||||
@ -300,16 +302,18 @@ It will be capable of accessing camera output, processing it and displaying the
|
|||||||
cameraRelease();
|
cameraRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void surfaceChanged(SurfaceHolder holder, int format, int width,
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||||
int height) {
|
|
||||||
cameraSetup(width, height);
|
cameraSetup(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//...
|
||||||
|
|
||||||
* Add *cameraOpen*, *cameraRelease* and *cameraSetup* voids as shown below.
|
* Add *cameraOpen*, *cameraRelease* and *cameraSetup* voids as shown below.
|
||||||
|
|
||||||
* Also, don't forget to add the public void *run()* as follows:
|
* Also, don't forget to add the public void *run()* as follows:
|
||||||
|
|
||||||
.. code-block:: java
|
.. code-block:: java
|
||||||
|
:linenos:
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
// TODO: loop { getFrame(), processFrame(), drawFrame() }
|
// TODO: loop { getFrame(), processFrame(), drawFrame() }
|
||||||
@ -327,11 +331,10 @@ It will be capable of accessing camera output, processing it and displaying the
|
|||||||
// TODO setup camera
|
// TODO setup camera
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
..
|
|
||||||
|
|
||||||
#. Create a new *Activity* (*New -> Other -> Android -> Android Activity*) and name it, for example: *HelloOpenCVActivity*. For this activity define *onCreate*, *onResume* and *onPause* voids.
|
#. Create a new *Activity* (*New -> Other -> Android -> Android Activity*) and name it, for example: *HelloOpenCVActivity*. For this activity define *onCreate*, *onResume* and *onPause* voids.
|
||||||
|
|
||||||
.. code-block:: java
|
.. code-block:: java
|
||||||
|
:linenos:
|
||||||
|
|
||||||
public void onCreate (Bundle savedInstanceState) {
|
public void onCreate (Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -359,11 +362,12 @@ It will be capable of accessing camera output, processing it and displaying the
|
|||||||
});
|
});
|
||||||
ad.show();
|
ad.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#. Add the following permissions to the AndroidManifest.xml file:
|
#. Add the following permissions to the AndroidManifest.xml file:
|
||||||
|
|
||||||
.. code-block:: xml
|
.. code-block:: xml
|
||||||
|
:linenos:
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
@ -372,12 +376,15 @@ It will be capable of accessing camera output, processing it and displaying the
|
|||||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||||
|
|
||||||
#. Reference OpenCV library within your project properties.
|
#. Reference OpenCV library within your project properties.
|
||||||
|
|
||||||
.. image:: images/dev_OCV_reference.png
|
.. image:: images/dev_OCV_reference.png
|
||||||
:alt: Reference OpenCV library.
|
:alt: Reference OpenCV library.
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
#. We now need some code to handle the camera. Update the *HelloOpenCVView* class as follows:
|
#. We now need some code to handle the camera. Update the *HelloOpenCVView* class as follows:
|
||||||
|
|
||||||
.. code-block:: java
|
.. code-block:: java
|
||||||
|
:linenos:
|
||||||
|
|
||||||
private VideoCapture mCamera;
|
private VideoCapture mCamera;
|
||||||
|
|
||||||
@ -394,6 +401,7 @@ It will be capable of accessing camera output, processing it and displaying the
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cameraRelease() {
|
public void cameraRelease() {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if (mCamera != null) {
|
if (mCamera != null) {
|
||||||
@ -402,6 +410,7 @@ It will be capable of accessing camera output, processing it and displaying the
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cameraSetup(int width, int height) {
|
private void cameraSetup(int width, int height) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (mCamera != null && mCamera.isOpened()) {
|
if (mCamera != null && mCamera.isOpened()) {
|
||||||
@ -425,7 +434,9 @@ It will be capable of accessing camera output, processing it and displaying the
|
|||||||
}
|
}
|
||||||
|
|
||||||
#. The last step would be to update the *run()* void in *HelloOpenCVView* class as follows:
|
#. The last step would be to update the *run()* void in *HelloOpenCVView* class as follows:
|
||||||
|
|
||||||
.. code-block:: java
|
.. code-block:: java
|
||||||
|
:linenos:
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -465,5 +476,3 @@ It will be capable of accessing camera output, processing it and displaying the
|
|||||||
}
|
}
|
||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user