使用OpenCV Android移植

发布于 2024-08-31 14:45:38 字数 1632 浏览 4 评论 0原文

我想使用 OpenCV Android 移植,您可以在此处找到该移植,以进行一些图像转换用于增强现实应用程序。我发现配置和构建库没有问题,没有收到任何错误,并且成功通过 JNI 进程将其放入我的 Android 应用程序中:库 libopencv.so 位于我的项目目录下的正确目录“\libs\armeabi\”中。 现在的问题是:

1)首先我想了解这个移植源自原始 openCV 库的哪个版本。对我来说很重要的是知道它是从版本 1.5、2.0 还是 2.1 派生的,因为相同的功能非常不同并且其他功能不存在。

2)在开始实时视频操作之前,我会尝试对单个图像或保存的视频进行一些简单的操作:


JNIEXPORT
jstring
JNICALL
Java_org_examples_testOpenCV_OpenCV_LoadImage(JNIEnv* env, jobject thiz)
{
    IplImage* imgIn = cvLoadImage("/sdcard/testimage.jpg", -1);

if (!imgIn) return env->NewStringUTF("Error");

cvReleaseImage( &imgIn );

return env->NewStringUTF("Ok");

}


JNIEXPORT
jstring
JNICALL
Java_balmas_examples_testOpenCV_OpenCV_manageVideo(JNIEnv* env, jobject thiz)
{
     CvCapture* capture = cvCaptureFromFile("/sdcard/video_galaxyspica_352x288_15fps.3gp");

    if (!capture) return env->NewStringUTF("Error");

    return env->NewStringUTF("Ok");

}

在这两种情况下我都会收到“错误”。 SD卡上的文件没有问题,因为我尝试这样做:


FILE* file = fopen("/sdcard/video_galaxyspica_352x288_15fps.3gp","w+");

//FILE* file = fopen("/sdcard/testimage.jpg","w+");

if (!file) return env->NewStringUTF("Error");
else {
    fflush(file);
    fclose(file);
    return env->NewStringUTF("OK");
}

我收到“确定”。 我意识到 highgui 库中存在一些问题,但我不明白我应该做什么以及应该做什么来避免该问题。 一些建议!!!

谢谢大家

I want to use the OpenCV Android porting, that you can find HERE, to make some image transformations for an Augmented Reality application. I've found no problem configuring and building the library, I receive no error and I succed put it within my Android application throght JNI process: the library libopencv.so is in the correct directory "\libs\armeabi\" under my project's directory.
And now the problems:

1) First I want to understand what version of the original openCV library this porting derive from. Is important for me know if it derive from version 1.5, 2.0 or 2.1 because same functions are very different and others are absent.

2) Before starting with real time video manipulation, I'd try make some simple operations on a single image or saved video:


JNIEXPORT
jstring
JNICALL
Java_org_examples_testOpenCV_OpenCV_LoadImage(JNIEnv* env, jobject thiz)
{
    IplImage* imgIn = cvLoadImage("/sdcard/testimage.jpg", -1);

if (!imgIn) return env->NewStringUTF("Error");

cvReleaseImage( &imgIn );

return env->NewStringUTF("Ok");

}


JNIEXPORT
jstring
JNICALL
Java_balmas_examples_testOpenCV_OpenCV_manageVideo(JNIEnv* env, jobject thiz)
{
     CvCapture* capture = cvCaptureFromFile("/sdcard/video_galaxyspica_352x288_15fps.3gp");

    if (!capture) return env->NewStringUTF("Error");

    return env->NewStringUTF("Ok");

}

In both cases I receive "Error". There are no problems with files on the sdcard becouse I try to make this:


FILE* file = fopen("/sdcard/video_galaxyspica_352x288_15fps.3gp","w+");

//FILE* file = fopen("/sdcard/testimage.jpg","w+");

if (!file) return env->NewStringUTF("Error");
else {
    fflush(file);
    fclose(file);
    return env->NewStringUTF("OK");
}

and I receive "OK".
I realize that there is some problem within highgui library but I don't understand what and wath I should make to avoid the problem.
Some suggestions!!!

Thank you everyone

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美人骨 2024-09-07 14:45:38

伙计们-您可能想尝试这个链接,它将 C++“现代”接口移植到 opencv。 IplImage 的东西已被弃用,但如果您需要支持遗留代码,新版本会留下包装器。

http://code.google.com/p/android-opencv/

有在示例相机校准应用程序中,您单击“捕捉”几次,它将求解 K 矩阵。

注意:您需要 STL 类的crystax ndk,http://www.crystax .net/android/ndk-r4.php

guys- you may want to try this link, it ports the C++ 'modern' interface to opencv. The IplImage stuff is deprecated, but new versions leave wrappers if you need to support legacy code.

http://code.google.com/p/android-opencv/

There's a sample camera-calibration app, you click snap a few times and it will solve for the K matrix.

Note: you'll need the crystax ndk for STL classes, http://www.crystax.net/android/ndk-r4.php

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文