[英]Using Opencv in android for edge detection
Am trying to use opencv in my android project. 我正在尝试在我的android项目中使用opencv。 Here is a complete list of events i did over the past few weeks:
这是我在过去几周内所做的活动的完整列表:
1- I used my mobile phone camera to take a picture stored it as bitmap
2- Ran face detection on it
3- Now i was supposed to use android opencv to highlight the edges in the face detection bitmap
I do not know much about ndk stuff. 我对ndk的东西了解不多。 All I did was downloaded the android opencv sdk imported into my project workspace used this as library project for my application and am using the following code in my android application:
我所做的只是下载了导入到我的项目工作区中的android opencv sdk,并将其用作我的应用程序的库项目,并且正在我的android应用程序中使用以下代码:
Bitmap canny_image = Bitmap.createBitmap(bmFace.getWidth(), bmFace.getHeight(), Config.ARGB_8888);
canny_image = bmFace.copy(Config.ARGB_8888, true);
Mat mImg = new Mat();
Utils.bitmapToMat(canny_image,mImg);
//Converting to grayscale
Mat mGray = new Mat(mImg.rows(), mImg.cols(), CvType.CV_8UC1, new Scalar(0));
Imgproc.cvtColor(mImg , mGray, Imgproc.COLOR_BGRA2GRAY, 4);
//Applying Canny
Imgproc.Canny(mGray, mGray, 80, 90);
//Converting back to 4 channel image
Imgproc.cvtColor(mGray , mImg, Imgproc.COLOR_GRAY2RGBA, 4);
canny_image.recycle();
System.gc();
canny_image = Bitmap.createBitmap(mImg.cols(), mImg.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(mImg, canny_image);
However the logcat is showing unsatisfied link error. 但是,logcat显示不满意的链接错误。 Now using the documentation from here .
现在使用此处的文档。
In this link there is a point: 在此链接中有一点:
If your application project doesn’t have a JNI part, just copy the corresponding OpenCV native libs from <OpenCV-2.4.6-android-sdk>/sdk/native/libs/<target_arch> to your project directory to folder libs/<target_arch>.
In case of the application project with a JNI part, instead of manual libraries copying you need to modify your Android.mk file: add the following two code lines after the "include $(CLEAR_VARS)" and before "include path_to_OpenCV-2.4.6-android-sdk/sdk/native/jni/OpenCV.mk"
I did the same. 我也一样 In my application i made a folder libs and copied all the .so and .h files in the /sdk/native/libs/
在我的应用程序中,我制作了一个文件夹libs并将所有.so和.h文件复制到/ sdk / native / libs /
but then again my library project does not contain the application.mk and android.mk files. 但是我的图书馆项目又一次不包含application.mk和android.mk文件。 Am totally messed up how to use opencv in my android application.
我完全搞砸了如何在我的Android应用程序中使用opencv。 I thought the linking problem was due to the fact that i have not loaded the library in my code but again when i use this code in my application it gives an exception:
我认为链接问题是由于我尚未在代码中加载该库,但是当我在应用程序中使用此代码时,它又给出了一个例外:
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
Log.i(TAG, "OpenCV loaded successfully");
mOpenCvCameraView.enableView();
} break;
default:
{
super.onManagerConnected(status);
} break;
}
}
};
Referenced from the same link as i mentioned above. 从与我上面提到的相同的链接引用。 Please experts help me on this.
请专家对此提供帮助。 I need some serious help.
我需要一些认真的帮助。 Been stuck here for like almost a week.
被困在这里将近一个星期。 How can i successfully use opencv in my android application.
我如何在我的Android应用程序中成功使用opencv。 What am i missing?
我想念什么?
This error is shown when you are calling a library before initializing it. 在初始化库之前调用库时会显示此错误。 Refer here : Android UnsatisfiedLinkError with OpenCV 2.4.2 .
请参阅此处: 带有OpenCV 2.4.2的Android UnsatisfiedLinkError 。 Refer to the comment thread beneath the correct answer.
请参考正确答案下方的评论主题。 So let the library initialise and then add whatever you wish to do beneath "Log.i(TAG, "OpenCV loaded successfully");"
因此,让库进行初始化,然后在“ Log.i(TAG,“ OpenCV成功加载”))下添加您想做的任何事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.