Sunteți pe pagina 1din 17

22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

BLOG DE CODEONION
Tutoriales visualmente ricos

2 5 D E N OV I E M B R E D E 2 0 1 5 P O R C O D EO N I O N

Crear un nuevo proyecto OpenCV en Android


Studio

Volver a OpenCV para la lista de tutoriales de


Android
Permite hablar en Facebook Messenger
http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 1/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

En este tutorial, crearemos un nuevo proyecto OpenCV en Android Studio. Como ya tiene
todo descargado , estamos listos para seguir adelante. Al nal de este tutorial, tendr una
nueva con guracin del proyecto, que puede usar para construir sus proyectos. As que
vamos a hacer un poco de CV!

Nota: Este tutorial ha sido probado en Android Studio 1.5 y 2.0

En resumen, los pasos son, (2) Crear proyecto simple. (3) Importe OpenCV SDK como un
Mdulo en Android Studio. (4) Establecer la versin de OpenCV. en Project (5) Fix Library
association in project. (6) Hecho! Ahora el cdigo OpenCV real puede escribirse en el
futuro. El tutorial guiado ms largo y detallado se proporciona a continuacin.

1. Te ruego que abras el estudio de Android.


2. Crea un nuevo proyecto
Lo llam "OpenCV_Test". (Podra ser diferente en el siguiente GIF)
El SDK mnimo es "API 19: Android 4.4 (KitKat).
La Actividad predeterminada es "Actividad bsica" (fcilmente modi cable ms
adelante)
El nombre de la actividad es "MainActivity" (es decir, con guracin predeterminada)
He mostrado todo el proceso en este GIF.

Despus de presionar Finish, Gradle realizar algunos procesos y, nalmente, se le


presentar su proyecto de Android.
Ahora, podemos comenzar a importar OpenCV en el proyecto.
3. Importe el mdulo OpenCV para Android SDK en Android Studio.
Permite hablar en Facebook Messenger
http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 2/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

Para importar OpenCV SDK como un mdulo en su proyecto, vaya a F ile> Nuevo>
Importar mdulo .
A continuacin, indique la ruta a su OpenCV como ... \ OpenCV-android-sdk \ sdk \
java
Puede elegir modi car el nombre de su mdulo.
Presione Siguiente y Termine el Dilogo.
Todo el proceso se da aqu:

Tenga en cuenta que, al nal, hay algunos errores en el cdigo y en la consola. Esto se
debe a que necesita corregir el nmero de versin y vincular las bibliotecas con su
propio proyecto. Esto se muestra en los siguientes dos pasos.
4. En este paso, reparar la informacin del SDK de Android Project en el archivo OpenCV
build.gradle .
En el explorador de proyectos, cambie a la vista Proyecto.
Vaya a OpenCVLibrary300> archivo build.gradle y bralo.
He actualizado el contenido del archivo con el siguiente cdigo

1 apply plugin: 'com.android.library'


2
3 android {
4 compileSdkVersion 23
5 buildToolsVersion "23.0.2"
6
7 defaultConfig {
8 minSdkVersion 19
9 targetSdkVersion 23
Permite hablar en Facebook Messenger
http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 3/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

10 }
11
12 buildTypes {
13 release {
14 minifyEnabled false
15 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'progu
16 }
17 }
18 }

Tenga en cuenta que la informacin del SDK del proyecto de Android se puede
obtener a partir del propio archivo build.gradle del proyecto.
Una vez que se actualicen las con guraciones de Android SDK, presione el botn
"Volver a intentarlo".
Todo este proceso se da a continuacin:

Ahora. tenemos que arreglar la asociacin de la biblioteca.


5. Se ve bien hasta ahora! Ahora debemos asegurarnos de que las bibliotecas de OpenCV
para Android estn asociadas a nuestro proyecto Android Studio. Actualmente, Android
Studio no reconocer el cdigo de OpenCV que escribimos en nuestros archivos.
Arreglamos esto de la siguiente manera.
Vaya a F ile> Estructura del proyecto.
Cuando se abre la ventana, en Mdulos, seleccione la aplicacin .
Haga clic en dependencias.
Haga clic en + .
Seleccione dependencias de mdulo .
Permite hablar
(En mi caso) Seleccione : abrirCVLibrary300 . en Facebook Messenger
http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 4/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

Presiona Ok y Ok.
Despus de unos segundos, las bibliotecas se asociarn con su proyecto de Android.
Todo este proceso se muestra aqu:

Ahora puede escribir ms cdigo OpenCV en el futuro en el mismo proyecto.


6. Lo hicimos! El proyecto est listo para el futuro desarrollo de OpenCV.

Esto concluye este tutorial. Ahora est listo para comenzar a crear su propio Android
Studio Project que consiste en funciones de OpenCV SDK limitadas nicamente por su
imaginacin. En el siguiente tutorial, MOSTRAR LA CMARA en la pantalla de la
aplicacin de Android usando OpenCV . Asegrate de leerlo. No se olvide de
COMPARTIR esta publicacin y escribir sus opiniones, ideas y puntos de vista en la
seccin COMENTARIO a continuacin.

Gracias por leer :). Por favor, dale me gusta a mi pgina de Facebook y sigue mi Twitter
para ms tutoriales.

Volver a OpenCV para la lista de tutoriales de


Android
Compartir este:

Permite hablar en Facebook Messenger


http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 5/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio


52 12 13

Relacionado

Use OpenCV para mostrar la OpenCV SDK para la estructura Aprendiendo los paquetes de
cmara en la aplicacin de de archivos de Android OpenCV SDK para Android
Android con la orientacin 15 de noviembre de 2015 17 de noviembre de 2015
correcta En "Android" En "Android"
9 de abril de 2016
En "Android"

Le gust? Toma un segundo para apoyar la codeonion en


Patreon!

ANDROID , OPENCV ,
P R O G R A M AC I N

ANDROID
,
A S O C I AC I N
,
A R R EG LO
,
TIL
,
CMO
,
I N S TA L A C I N
,
J AVA
,
APRENDER
,
Permite hablar en Facebook Messenger
http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 6/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

B I B L I OT ECA S
,
N U E VO
,
OPENCV4ANDROID
,
P R OY EC T O
,
SDK
,
SOLUCIN
,
T U TO R I A L

48 Respuestas a "Crear un nuevo proyecto OpenCV en Android Studio"

Annimo
6 D E S E P T I E M B R E D E 2 0 1 7 A L A S 2 : 5 1 P. M .

Gracias . La forma en que nos guiaste fue muy agradable

Varun
2 8 D E A G O S T O D E 2 0 1 6 A L A S 4 : 1 3 P. M .

Muchas gracias. Me salvaste el da. Publica ms. Por favor, no puedo ejecutar mi emulador.
Dios te bendiga.

Varun
2 8 D E AG O S TO D E 2 0 1 6 A L A S 1 6 : 0 5

Muchas gracias, Rock. Por favor, contina compartiendo tu conocimiento, Dios te bendiga.
Por favor, despeja mis dudas. Funcionar en emulador o directamente tengo que ejecutar en
mi dispositivo. Gracias de antemano

codeonion
Permite hablar en Facebook Messenger
http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 7/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

1 8 D E J U L I O D E 2 0 1 7 A L A S 3 : 2 1 P. M .

Te sugiero que pruebes un dispositivo Android real. Porque, entonces hars todo por el
producto correcto.

Annimo
1 5 D E AG O S TO D E 2 0 1 6 A L A S 8 : 4 4 A . M .

es realmente til Thnak por tu parte!

Annimo
2 9 D E J U L I O D E 2 0 1 6 A L A S 2 : 0 3 P. M .

Thank You SO much. I literally searched the entire web for something like this>

codeonion
A U G U S T 1 0 , 2 0 1 6 AT 5 : 3 6 P M

Thank you very much for your kind words. My happiness level for you in nite.

Santhosh Rangaswamy
J U LY 2 3 , 2 0 1 6 AT 1 : 3 1 P M

this tutorial is one of the best and simplest explanation to run.. thanks a lot mate

codeonion
J U LY 2 4 , 2 0 1 6 AT 1 : 1 2 P M

It was a pleasure for me. I am glad it helps people.

Permite hablar en Facebook Messenger


http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 8/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

Sumeet Batra
J U N E 2 2 , 2 0 1 6 AT 1 : 2 8 A M

When I try to import module I get select modules to import and it will not let me import the
java folder in opencv sdk.

codeonion
J U N E 2 2 , 2 0 1 6 AT 7 : 4 8 A M

Thanks for the comment.

Try to write the path in the eld manually like ..

d:\some_folder\..\OpenCV-android-sdk\sdk\java

I hope it solves the issue and lets you proceed. If not, then let me know.

Anonymous
A U G U S T 5 , 2 0 1 6 AT 3 : 2 0 A M

had the same error: check if your sdk folder is sane. Download again if its not

Anonymous
J U N E 1 0 , 2 0 1 6 AT 1 0 : 4 6 P M

Thank you ! it was very helpfull

karthi
J U N E 6 , 2 0 1 6 AT 4 : 5 4 P M

It as really use full post. Thank you.

Permite hablar en Facebook Messenger


http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 9/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

sundi
M AY 3 1 , 2 0 1 6 AT 1 0 : 4 8 P M

i followed your tutorial but when i perform the last step that is project structure and add
module. no errors are removed. please tell me what to do

codeonion
J U N E 2 , 2 0 1 6 AT 9 : 4 7 P M

Thanks for the comment!

I know when that happens. I myself was making a new project and it was missing something.

See, it can be missing libraries or gradle or something I cant know.

Try to redo the entire process. It will work ne

If there was any unclear point in the tutorial, then let me know. I will update and make it more
clear to understand

Patrycja
M AY 2 6 , 2 0 1 6 AT 3 : 5 8 A M

Hi! Thats a good article! Ive been looking for something like this sometime ago. And I found
this one: http://blog.zaven.co/opencv-in-android-studio-project/ It is really good and it was so
helpful. Maybe it can be useful for you or other users as well.

Coldus
M AY 2 3 , 2 0 1 6 AT 9 : 1 8 P M

Hello!
Followed your tutorial, but when i got to run my program i got an exception once again which
says:
java.lang.Unsatis edLinkError: Couldnt load opencv_java310 from loader
dalvik.system.PathClassLoader[]
Permite hablar en Facebook Messenger
http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 10/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

This is the exception i always seem to run into, ive tried to install opencv with all methods i
could nd on the net, but this exception keeps popping up, and i dont know why, since
opencv is where it is supposed to be and arrrghh

Any help would be appriciated!


Thanks

codeonion
M AY 2 3 , 2 0 1 6 AT 1 1 : 0 8 P M

Are you using NDK?

Coldus
M AY 2 4 , 2 0 1 6 AT 1 2 : 0 0 A M

I wasnt, now I installed it through the android studio, but it didnt seem to x the problem,
maybe this is part of the reason why my app doesnt seem to work, i wonder how many of
these obvious, and stupid mistakes i made.

Thanks for the answer though!

Coldus
M AY 2 4 , 2 0 1 6 AT 9 : 2 0 P M

Welll. Guess what, Ive had these lines in my code: static{


OpenCVLoader.initDebug();
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}
since i had these in my original le, but it seems , that they caused these issues, without
them my app runs just ne

Thanks once again!


Btw awesome tutorial, really like how you made gifs for well not-so-clever-people like me

Permite hablar en Facebook Messenger


http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 11/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

Shawn
M AY 1 7 , 2 0 1 6 AT 6 : 4 4 P M

Thank you for posting this. I have a lot experience with OpenCv with python wrappings but
trying to move over to making a simple android app was driving me insane. All the tutorials,
even on the OpenCV site still show how to do start working with Eclipse IDE. The even
without the animated gifs this tutorial was a god send. The animated gifs was just added
butter.

codeonion
M AY 1 9 , 2 0 1 6 AT 1 1 : 1 2 P M

Thank you very much. I am very happy to read this. So much positive energy that I cant
comprehend.

Labib
A P R I L 2 0 , 2 0 1 6 AT 7 : 0 4 P M

Hello,
I need to put the minSdkVersion 9 is this a problem does it affect the openCV
functionalities??

codeonion
A P R I L 2 0 , 2 0 1 6 AT 7 : 2 8 P M

Thanks for the comment Labib

It will prevent you from using latest android functions. OpenCV will still be providing you the
latest functionalities. You can go ahead and try it.

Just make sure that version numbers match in both gradle and downloaded version.

Be sure to check out the next tutorial to show camera on your phone.

Thanks for the comment.


Permite hablar en Facebook Messenger
http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 12/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

Chi
A P R I L 1 2 , 2 0 1 6 AT 2 : 5 2 P M

I followed these steps in Android Studio 2 and OpenCV 3, it worked. The only thing that I
have done differently is the buildToolsVersion in build.gradle(Module: app). I downgraded to:
buildToolsVersion 23.0.2
This is so that build errors are xed. Thanks for this good posting.

codeonion
A P R I L 1 2 , 2 0 1 6 AT 6 : 2 0 P M

Thanks for reading. I am glad you xed it

Teresa
A P R I L 5 , 2 0 1 6 AT 4 : 1 6 P M

Thank you! I nally after two days of struggling managed to install it. When will you publish
new articles?

codeonion
A P R I L 5 , 2 0 1 6 AT 4 : 5 3 P M

Teresa, I am glad that it worked. I will be writing more on OpenCV for Android tutorials very
soon. Let me know what you wish to see and I will see what I can write about it

Teresa
A P R I L 6 , 2 0 1 6 AT 2 : 3 3 P M

Well, I have a question- after following your tutorial I tried to import some samples to a
project and encountered some dif culties Did you try out samples from openCV or you
started with your own programs?

Permite hablar en Facebook Messenger


http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 13/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

codeonion
A P R I L 1 0 , 2 0 1 6 AT 5 : 2 1 P M

I just wrote the next tutorial in the series, it is about implementing the sample into the same
project.

You can nd it HERE

Now that you have mentioned about the dif culties, I will now implement every sample one
by one.

Thanks for reading

Alexander
M A R C H 3 1 , 2 0 1 6 AT 1 1 : 5 5 A M

When will your camera app be ready?

codeonion
M A R C H 3 1 , 2 0 1 6 AT 1 1 : 5 6 P M

I have moved it up my list. You will nd it soon. Subscribe, like and follow

Anonymous
M A R C H 3 0 , 2 0 1 6 AT 1 1 : 2 2 P M

Thanks for this tutorial, you helped a lot seriously speaking

codeonion
M A R C H 3 1 , 2 0 1 6 AT 5 : 1 6 P M

Thanks for your kind words, they mean a lot to me


Permite hablar en Facebook Messenger
http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 14/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

Piero
M A R C H 2 6 , 2 0 1 6 AT 1 1 : 1 1 P M

good evening,

Ive a problem at the point 5, after I click ok.


The grandle not sink because Ive the error

Error:Con guration with name default not found.

How do I resolve it?

thank,

Piero

Rashmi
M A R C H 1 5 , 2 0 1 6 AT 1 2 : 5 8 P M

Amazing tutorial that worked!! Many thanks!!

codeonion
M A R C H 1 5 , 2 0 1 6 AT 6 : 4 1 P M

I am happy that it is useful to you :). May you be successful!

Anonymous
M A R C H 1 3 , 2 0 1 6 AT 1 : 2 4 P M

good tutorial, it saved my day

codeonion
M A R C H 1 3 , 2 0 1 6 AT 2 : 5 4 P M Permite hablar en Facebook Messenger
http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 15/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

I am so glad that it helped. Thanks!

Anonymous
M A R C H 1 1 , 2 0 1 6 AT 3 : 0 7 A M

right on the mark very uid tutorial

codeonion
M A R C H 1 1 , 2 0 1 6 AT 1 1 : 4 5 P M

Thank you for the kind words, it means a lot to me

The next tutorials will cover more concepts of OpenCV on Android

Anonymous
M A R C H 4 , 2 0 1 6 AT 1 : 3 0 A M

Gracias, Thanks for writing so clearly.

codeonion
M A R C H 4 , 2 0 1 6 AT 1 2 : 3 9 P M

Thank you! It meant a lot!

Anonymous
J A N U A R Y 2 8 , 2 0 1 6 AT 1 1 : 4 8 A M

Thanks,

i guess you saved me from a few painful hours!


Permite hablar en Facebook Messenger
http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 16/17
22/10/2017 Crear un nuevo proyecto OpenCV en Android Studio

codeonion
J A N U A R Y 2 8 , 2 0 1 6 AT 9 : 2 2 P M

As somebody once saved mine

Anonymous
J A N U A R Y 2 5 , 2 0 1 6 AT 1 1 : 2 4 A M

Mejor tutorial Por favor sigue haciendo ms

codeonion
28 DE ENERO DE 2016 A LAS 11:44 A.M.

Gracias por las palabras amables. Har ms

Permite hablar en Facebook Messenger


http://blog.codeonion.com/2015/11/25/creating-a-new-opencv-project-in-android-studio/ 17/17

S-ar putea să vă placă și