为的Andr​​oid OpenCV的 - 错误打开跟踪文件,的UnsatisfiedLinkError [英] Android for OpenCV - error opening trace file, UnsatisfiedLinkError

查看:293
本文介绍了为的Andr​​oid OpenCV的 - 错误打开跟踪文件,的UnsatisfiedLinkError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的两个Android开发和OpenCV。我下载了OpenCV库为Android从 http://sourceforge.net/projects/opencvlibrary/文件/ OpenCV的-的Andr​​oid / ,并成立了一个手机采用了虚拟设备管理器。当我尝试运行的OpenCV教程0 - Android摄像头在Eclipse中,手机的屏幕说:致命错误:无法打开摄像头!我在日志中得到这些错误:

I'm new to both Android development and OpenCV. I downloaded the OpenCV library for Android from http://sourceforge.net/projects/opencvlibrary/files/opencv-android/ and set up a phone using the Virtual Device Manager. When I try to run "OpenCV Tutorial 0 - Android Camera" in Eclipse, the phone's screen says "Fatal error: can't open camera!" and I get these errors in the log:

08-07 15:02:57.322: E/Trace(708): error opening trace file: No such file or directory (2)
08-07 15:02:57.772: E/Sample::SurfaceView(708): Can't open camera!

我也试着运行一个简单的项目:

I also tried running a simple project:

package com.example;

import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;

    public class Test{
        public static void main(String[] args) {
            Mat example = Highgui.imread("/image.jpg");
        return;
    }
}

这给我的错误

which gives me the error

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.highgui.Highgui.imread_1(Ljava/lang/String;)J

我该如何解决这些错误?在一个侧面说明,/image.jpg看项目,而不是虚拟的Andr​​oid设备上的SD卡的父目录,对不对?

How can I fix these errors? On a side note, /image.jpg looks in the parent directory of the project, not the SD card on the Android virtual device, right?

非常感谢。

推荐答案

一堆搜索后,我发现<一href="http://docs.opencv.org/trunk/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html"相对=nofollow>为的UnsatisfiedLinkError本解决方案(其中又上来后,我还以为它是固定的 - 见这里):

After a bunch of searching, I found this solution for the UnsatisfiedLinkError (which came up again after I thought it was fixed - see here):

3。如果你的应用程序项目没有一个JNI的一部分,只需复制相应的OpenCV的本地库从/ SDK /本地/库/项目目录到文件夹库/."

"3. If your application project doesn’t have a JNI part, just copy the corresponding OpenCV native libs from /sdk/native/libs/ to your project directory to folder libs/."

因此​​,这意味着复制\ armeabi,\ armeabi-V7A和\ x86的文件夹中。

So that means copy the \armeabi, \armeabi-v7a, and \x86 folders.

4启用OpenCV的应用程序中的最后一步是调用OpenCV的API之前,Java的初始code可以做到的,例如,在活动类的静态部分:

"4. The last step of enabling OpenCV in your application is Java initialization code before call to OpenCV API. It can be done, for example, in the static section of the Activity class:

static {
    if (!OpenCVLoader.initDebug()) {
        // Handle initialization error
    }
}

这code段应向右走之后:

This code snippet should go right after:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_load_image);

现在它的作品!

这篇关于为的Andr​​oid OpenCV的 - 错误打开跟踪文件,的UnsatisfiedLinkError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆