简体   繁体   English

Android for OpenCV - 错误打开跟踪文件,UnsatisfiedLinkError

[英]Android for OpenCV - error opening trace file, UnsatisfiedLinkError

I'm new to both Android development and OpenCV. 我是Android开发和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. 我从http://sourceforge.net/projects/opencvlibrary/files/opencv-android/下载了适用于Android的OpenCV库,并使用虚拟设备管理器设置了一部手机。 When I try to run "OpenCV Tutorial 0 - Android Camera" in Eclipse, the phone's screen says "Fatal error: can't open camera!" 当我尝试在Eclipse中运行“OpenCV Tutorial 0 - Android 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

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? 另外,/ image.jpg查看项目的父目录,而不是Android虚拟设备上的SD卡,对吧?

Thanks so much. 非常感谢。

If you are developing on a device via usb, try going to the App Manager from the options menu (stack of lines), scrolling down to the OpenCV Manager (assuming you are on OpenCV 2.4.2 or higher) and Force Close it. 如果您正在通过usb在设备上进行开发,请尝试从选项菜单(堆栈行)转到App Manager,向下滚动到OpenCV Manager(假设您使用的是OpenCV 2.4.2或更高版本)并强制关闭它。 Do the same with your Tutorial 0 app. 对您的Tutorial 0应用程序执行相同操作。

I have Tutorial 0 working on my ubuntu machine. 我的教程0在我的ubuntu机器上运行。 However, when I tried to add some OpenCV classes into a pure android project, I got the UnsatisfiedLink error. 但是,当我尝试将一些OpenCV类添加到纯Android项目中时,我得到了UnsatisfiedLink错误。 After that, my Tutorial 0 stopped working for a while with the "camera not found" error you are getting. 在那之后,我的教程0停止工作一段时间,你得到的“找不到相机”错误。 It seems that OpenCV Manager can get messed up, probably having a lock or something on some resources, and needs to restart. 似乎OpenCV管理器可能搞砸了,可能在某些资源上有锁或什么东西,需要重新启动。 My suggestion fixed the Totorial 0 camera problem, but not the unsatisfiedLink for my pure android + openCV project. 我的建议修复了Totorial 0相机的问题,但不是我的纯android + openCV项目的不满意的链接。

After a bunch of searching, I found this solution for the UnsatisfiedLinkError (which came up again after I thought it was fixed - see here ): 一堆搜索之后,我发现这个解决方案的UnsatisfiedLinkError(这又上来后,我还以为是固定的-见这里 ):

"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/." “3.如果您的应用程序项目没有JNI部分,只需将相应的OpenCV本机库从/ sdk / native / libs /复制到项目目录到文件夹libs /。”

So that means copy the \\armeabi, \\armeabi-v7a, and \\x86 folders. 这意味着复制\\ armeabi,\\ armeabi-v7a和\\ x86文件夹。

"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: “4.在您的应用程序中启用OpenCV的最后一步是在调用OpenCV API之前的Java初始化代码。例如,可以在Activity类的静态部分中完成:

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

This code snippet should go right after: 此代码段应该在以下内容之后:

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

Now it works! 现在它有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android错误打开跟踪文件 - Android Error opening trace file Android - 错误打开跟踪文件:没有这样的文件或目录 - Android - error opening trace file: No such file or directory Android E / Trace(627):打开跟踪文件时出错:没有这样的文件或目录(2) - Android E/Trace(627): error opening trace file: No such file or directory (2) 错误打开跟踪文件android权限被拒绝 - Error opening trace file android permission denied 在Android的Traceview中打开跟踪文件时出错 - Error while opening trace file in Traceview in Android Android运行时错误:打开跟踪文件时出错:没有这样的文件或目录(2) - Android runtime error: error opening trace file: No such file or directory (2) Android-错误打开跟踪文件,没有这样的文件或目录 - Android-Error opening trace file no such file or directory Android应用程序错误打开跟踪文件:没有此类文件或目录 - Android application Error Opening Trace File: No such file or directory Android上的JDom:打开跟踪文件时出错:没有这样的文件或目录 - JDom on Android: error opening trace file: No such file or directory Android音乐播放器FC和错误打开跟踪文件 - Android music player fc and error opening trace file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM