mirror of
https://github.com/opencv/opencv.git
synced 2024-12-02 07:39:57 +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 {
|
||||
text-align: justify;
|
||||
line-height: 130%;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
div.body h1,
|
||||
@ -327,9 +329,9 @@ table.field-list {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
ul.simple {
|
||||
/*ul.simple {
|
||||
list-style: none;
|
||||
}
|
||||
}*/
|
||||
|
||||
em.menuselection, em.guilabel {
|
||||
font-family: {{ theme_guifont }};
|
||||
@ -384,3 +386,8 @@ margin-top: 0px;
|
||||
div.body ul.search li {
|
||||
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.
|
||||
You can do it using Google Play Market or manually with ``adb`` tool:
|
||||
|
||||
.. code-block:: sh
|
||||
.. code-block:: sh
|
||||
:linenos:
|
||||
|
||||
<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.
|
||||
|
||||
#. Create a new class (*File -> New -> Class*). Name it for example: *HelloOpenCVView*.
|
||||
|
||||
.. image:: images/dev_OCV_new_class.png
|
||||
:alt: Add a new class.
|
||||
:align: center
|
||||
|
||||
* It should extend *SurfaceView* class.
|
||||
|
||||
* It also should implement *SurfaceHolder.Callback*, *Runnable*.
|
||||
|
||||
#. 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*.
|
||||
|
||||
* Modify autogenerated stubs: *HelloOpenCVView*, *surfaceCreated*, *surfaceDestroyed* and *surfaceChanged*.
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
|
||||
package com.hello.opencv.test;
|
||||
|
||||
@ -300,16 +302,18 @@ It will be capable of accessing camera output, processing it and displaying the
|
||||
cameraRelease();
|
||||
}
|
||||
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width,
|
||||
int height) {
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
cameraSetup(width, height);
|
||||
}
|
||||
|
||||
//...
|
||||
|
||||
* Add *cameraOpen*, *cameraRelease* and *cameraSetup* voids as shown below.
|
||||
|
||||
* Also, don't forget to add the public void *run()* as follows:
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
|
||||
public void run() {
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
..
|
||||
|
||||
#. 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
|
||||
:linenos:
|
||||
|
||||
public void onCreate (Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -359,11 +362,12 @@ It will be capable of accessing camera output, processing it and displaying the
|
||||
});
|
||||
ad.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#. Add the following permissions to the AndroidManifest.xml file:
|
||||
|
||||
.. code-block:: xml
|
||||
:linenos:
|
||||
|
||||
</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" />
|
||||
|
||||
#. Reference OpenCV library within your project properties.
|
||||
|
||||
.. image:: images/dev_OCV_reference.png
|
||||
:alt: Reference OpenCV library.
|
||||
:align: center
|
||||
|
||||
#. We now need some code to handle the camera. Update the *HelloOpenCVView* class as follows:
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
|
||||
private VideoCapture mCamera;
|
||||
|
||||
@ -394,6 +401,7 @@ It will be capable of accessing camera output, processing it and displaying the
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void cameraRelease() {
|
||||
synchronized(this) {
|
||||
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) {
|
||||
synchronized (this) {
|
||||
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:
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
@ -465,5 +476,3 @@ It will be capable of accessing camera output, processing it and displaying the
|
||||
}
|
||||
return bmp;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user