有人能告诉我我做错了吗?这些是我遵循的步骤:
将所有* .so文件从javacv-android-arm.jar,opencv-2.4.3-android-arm.zip和ffmpeg-1.0-android-arm.zip直接提取到新创建的“ libs / armeabi“文件夹,不创建任何新的子目录。
(我不明白的部分是“从javacv-android-arm.jar中提取所有* .so文件”,我只是插入了javacv-android-arm.jar文件在libs / armeabi文件夹中)
之后我从here下载了OpenCV2.4.3,从here下载了ffmpeg,并从我的C:/ root中提取了文件。 最后在设置我的系统路径后......,
C:\opencv\build\x64\vc10\bin;C:\ffmpeg-64\bin;C:\Program Files\Java\jdk1.7.0_10\bin
...如果我尝试在Android应用程序中使用简单的FrameGrabber ......
import com.googlecode.javacv.FFmpegFrameGrabber;
import com.googlecode.javacpp.Loader;
import com.googlecode.javacv.*;
import com.googlecode.javacv.cpp.*;
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_calib3d.*;
import static com.googlecode.javacv.cpp.opencv_objdetect.*;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FFmpegFrameGrabber i = new FFmpegFrameGrabber("/mnt/sdcard/SinglePerson.avi");
}
...我收到以下错误:
01-29 17:59:26.976: E/AndroidRuntime(30656): FATAL EXCEPTION: main
01-29 17:59:26.976: E/AndroidRuntime(30656): java.lang.NoClassDefFoundError: com.googlecode.javacv.FFmpegFrameGrabber
01-29 17:59:26.976: E/AndroidRuntime(30656): at com.example.xxxxxxxxx.MainActivity.onCreate(MainActivity.java:23)
01-29 17:59:26.976: E/AndroidRuntime(30656): at android.app.Activity.performCreate(Activity.java:4465)
01-29 17:59:26.976: E/AndroidRuntime(30656): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
01-29 17:59:26.976: E/AndroidRuntime(30656): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
01-29 17:59:26.976: E/AndroidRuntime(30656): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-29 17:59:26.976: E/AndroidRuntime(30656): at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-29 17:59:26.976: E/AndroidRuntime(30656): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-29 17:59:26.976: E/AndroidRuntime(30656): at android.os.Handler.dispatchMessage(Handler.java:99)
01-29 17:59:26.976: E/AndroidRuntime(30656): at android.os.Looper.loop(Looper.java:137)
01-29 17:59:26.976: E/AndroidRuntime(30656): at android.app.ActivityThread.main(ActivityThread.java:4424)
01-29 17:59:26.976: E/AndroidRuntime(30656): at java.lang.reflect.Method.invokeNative(Native Method)
01-29 17:59:26.976: E/AndroidRuntime(30656): at java.lang.reflect.Method.invoke(Method.java:511)
01-29 17:59:26.976: E/AndroidRuntime(30656): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-29 17:59:26.976: E/AndroidRuntime(30656): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-29 17:59:26.976: E/AndroidRuntime(30656): at dalvik.system.NativeStart.main(Native Method)
有人可以帮我吗?
答案 0 :(得分:12)
因此,jar文件基本上是一个zip文件,如果将扩展名更改为“.zip”,则可以像使用OpenCV和FFMPEG一样提取它包含的文件。
因此,将“javacv-android-arm.jar”重命名为“javacv-android-arm.zip”,从中提取.so文件并将其复制到libs / armeabi。
祝你好运!答案 1 :(得分:2)
Gradle:
compile 'org.bytedeco:javacv:1.0'
compile 'org.bytedeco.javacpp-presets:opencv:2.4.11-0.11:android-x86'
compile 'org.bytedeco.javacpp-presets:ffmpeg:2.6.1-0.11:android-x86'
compile 'org.bytedeco.javacpp-presets:opencv:2.4.11-0.11:android-arm'
compile 'org.bytedeco.javacpp-presets:ffmpeg:2.6.1-0.11:android-arm'
这会将javacv整合到android
答案 2 :(得分:0)
使用此示例:
http://javacv4android.blogspot.com.br/2014/02/how-to-import-javacv-libraries-to.html
稍后在OnCreate中:
try {
FrameGrabber grabber2 = new FFmpegFrameGrabber(Environment
.getExternalStorageDirectory().getAbsolutePath()
+ "/TESTE/spell.mp3");
String t = "!";
grabber2 = null;
} catch (Exception e) {
e.printStackTrace();
}
如果不存在错误,那就OK =)
抱歉我的英文
答案 3 :(得分:0)
最新版本。
在build.gradle
:
repositories {
...
mavenCentral()
}
dependencies {
...
compile group: 'org.bytedeco', name: 'javacv', version: '1.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.1.0-1.2', classifier: 'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '3.1.2-1.2', classifier: 'android-arm'
}
configurations {
all*.exclude group: 'org.bytedeco', module: 'javacpp-presets'
}