{Android-OpenCV调用CvSmooth实现高斯模糊}
2011-08-04 00:12
459 查看
项目配置很乱,Makefile啥的不写了,直接代码
高斯模糊效果
效果截图:
MainActivity: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //bitmapView=new BitmapView(this); BitmapFactory.Options option = new BitmapFactory.Options(); option.inPreferredConfig = Config.ARGB_8888; setContentView(R.layout.main); bmp = (BitmapFactory.decodeResource(this.getResources(), R.drawable.bitmap1, option)); imageView=(ImageView)this.findViewById(R.id.imageView1); imageView.setImageBitmap(bmp); int width=bmp.getWidth(); int height=bmp.getHeight(); int[] src=new int[width*height]; int[] dst=new int[width*height]; Log.d("图片大小", width+" "+height); bmp.getPixels(src,0, width, 0, 0, width, height); Smooth(src,dst,width,height); bmp.setPixels(dst,0, width,0, 0, width, height); imageView.setImageBitmap(bmp); } static{ System.loadLibrary("ImageProcess"); } public native void Smooth(int[] src,int[] dst,int width,int height);
ImageProcess.c: #include <string.h> #include <jni.h> #include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/features2d/features2d.hpp> #include <cv.h> using namespace std; using namespace cv; extern "C" { JNIEXPORT void Java_com_imageprocess_MainActivity_Smooth(JNIEnv* env, jobject thiz, jintArray javaIntArray0,jintArray dstArray,jint width, jint height) { jint* src = env->GetIntArrayElements(javaIntArray0, 0); jint* dst=env->GetIntArrayElements(dstArray,0); Mat srcMat(Size(width,height),CV_8UC4,(unsigned char*)src); Mat dstMat(Size(width,height),CV_8UC4,(unsigned char*)dst); CvMat cvsrcMat=srcMat; CvMat cvdstMat=dstMat; cvSmooth(&cvsrcMat,&cvdstMat, CV_GAUSSIAN, 11, 0, 0, 0); env->ReleaseIntArrayElements(javaIntArray0, src, 0); env->ReleaseIntArrayElements(dstArray, dst, 0); } }
高斯模糊效果
效果截图:
相关文章推荐
- Android调用OpenCV2.4.10实现二维码区域定位
- Android(安卓)开发通过NDK调用JNI,使用opencv做本地c++代码开发配置方法实现边缘检测代码(2)
- Android上使调用OpenCV 2.4.10 实现二维码区域定位(Z-xing 码)
- Android中实现WebView和JavaScript的互相调用详解
- Android 调用已安装市场,进行软件评分的功能实现
- android调用系统相机实现拍照功能
- Android调用系统相机,相册,并实现图片剪裁功能
- Android调用google地图生成路线图实现代码
- Android jni调用,实现自己的JNI_OnLoad函数
- Android Service 的使用(五)----如何实现AIDL文件中含有对象的调用
- Android使用ksoap2调用C#中的webservice实现图像上传
- Android实现高斯模糊
- Android移动开发-调用方向传感器开发简易指南针的实现
- 关于Python+Opencv实现人脸检测的实验笔记(调用摄像头篇)
- 关于Python+Opencv实现人脸检测的实验笔记(调用图片文件篇)
- Android Studio Jni开发(二)实现Native调用java方法和Native调用Android API
- android中的跨进程通信的实现(一)——远程调用过程和aidl
- Android开发学习之调用系统相机完成拍照的实现
- Android studio JNI NDK 开发(opencv,opencl 调用等等,更新中)
- C#调用GDI+1.1中的函数实现高斯模糊、USM锐化等经典效果。