/**     * 透视变换     * @param in 原图像     * @param point 定位到的四个点     * @return     */    private  Mat getWarpPersPective(Mat in,Point [] point){        MatOfPoint2f reusltPoint2f=null,srcPoint2f=null;        Mat out=new Mat();        Point []targetPoints=new Point[4];        for (int i=0;i<4;i++){            targetPoints[i]=new Point();        }  //这里拿到倾斜的长度作为宽高 结果可能比真正矫正的图片略小点 但是矫正效果还是很不错的    double rect_width = Math.sqrt(Math.abs(point[0].x - point[1].x)*Math.abs(point[0].x - point[1].x) +            Math.abs(point[0].y - point[1].y)*Math.abs(point[0].y - point[1].y));    double rect_height =  Math.sqrt(Math.abs(point[0].x - point[2].x)*Math.abs(point[0].x - point[2].x) +            Math.abs(point[0].y - point[2].y)*Math.abs(point[0].y - point[2].y));    double moveValueX = 0.0;    double moveValueY = 0.0;    targetPoints[0].x = 0.0 + moveValueX; targetPoints[0].y = 0 + moveValueY;// top_left    targetPoints[2].x = 0.0 + moveValueX; targetPoints[2].y = rect_height + moveValueY;// bottom_Left    targetPoints[1].x = rect_width + moveValueX; targetPoints[1].y = 0.0 + moveValueY;// top_Right    targetPoints[3].x = rect_width + moveValueX; targetPoints[3].y = rect_height + moveValueY;// bottom_Right    reusltPoint2f=new MatOfPoint2f(targetPoints);//这里需要将四个点转换成Mat    srcPoint2f=new MatOfPoint2f(point);    Mat tranform=getPerspectiveTransform(reusltPoint2f,srcPoint2f); // 透视变换    warpPerspective(in,out,tranform,new Size(rect_width,rect_height),INTER_LINEAR | WARP_INVERSE_MAP);    showImage(out);     return out;//变换后的Mat}

 效果图如下 这里只是对原图片进行了黑白处理 只是为了处理更快而已 

原图片 变换后的图片

更多相关文章

  1. Android剪裁图片简单的方法
  2. 使用bitmap缩略图,解决图片大小超过预算的VM的问题
  3. Android(安卓)特殊用法--来自中国移动开发社区
  4. Android(安卓)之 Bitmap 和 File 相互转换
  5. android camera Intent调用
  6. android中实现从一个图片中截取一部分,在翻转,成一个圆形显示
  7. Android(安卓)学习笔记-2011年7月
  8. android-------开发常用框架汇总
  9. Android(安卓)SwitchButton(滑动开关)

随机推荐

  1. Android屏幕待机时间的获取和设置
  2. android活动的生存期
  3. 开发者工程师软件工程师的IOS,WindowsPhon
  4. Android 6.0权限处理问题
  5. Android(安卓)实时采集声音的频率和大小
  6. Android热修复之AndFix
  7. Android及Robotium学习总结【环境变量,真
  8. 关于Android(安卓)popupWindow的位置显示
  9. Android(安卓)Activity的启动过程过程分
  10. 基于Qt for Android联想到调用Android AP