android中怎样导入openCV?导入后提示程序中有错误!
我想实现android的边缘检测,想调用opencv里面的函数。但是按照网上的教程下载了opencv后导入,最后在src文件夹中没看到opencv。虽然引用opencv库的内容画曲线消失了,但是运行后出现“You project contains errors.Please fix them before running your application."附上代码:
package com.test_opencv;
import java.io.File;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.highgui.Highgui;
import org.opencv.imgproc.Imgproc;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
public class Test_Opencv extends Activity {
@SuppressWarnings("unused")
private Button deal_button, recall_button;
private ImageView imageview;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
double scale = 0.1;
imageview = (ImageView)this.findViewById(R.id.imageView1);
Bitmap bm1=BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getPath()+"/0.jpg");
imageview.setImageBitmap(bm1);
Mat img = Highgui.imread(Environment.getExternalStorageDirectory().getPath()+"/0.jpg",0);
Size dsize = new Size(img.width()*scale,img.height()*scale);
Mat img2 = new Mat(dsize,CvType.CV_8SC1);
Mat img3 = new Mat();
img.convertTo(img2, CvType.CV_8SC1);
Imgproc.Canny(img, img3, 123, 250);
boolean flag=Highgui.imwrite(Environment.getExternalStorageDirectory().getPath()+"/0.jpg", img3);
if(flag)
{
File f = new File(Environment.getExternalStorageDirectory().getPath()+"/0.jpg");
if(f.exists())
{
Bitmap bm=BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getPath()+"/0.jpg");
imageview.setImageBitmap(bm);
}
}//end if
else{
Toast.makeText(Test_Opencv.this, "===========图片写入失败!============!!", 3).show();
}
}
}
顺便问问android的边缘检测算法怎么实现?谢谢!! android opencv 边缘检测 图像编程
补充:移动开发 , Android