opencv for andriod java代码实现霍夫变化(HoughLinesP)

opencv for andriod java代码实现霍夫变化(HoughLinesP)

Mat mCannyMat1=new Mat();           
Mat rgbMat1 = new Mat();  
Mat grayMat1 = new Mat();           
Mat lines=new Mat();

Utils.bitmapToMat(bmp, rgbMat1);

//gray
Imgproc.cvtColor(rgbMat1, grayMat1, Imgproc.COLOR_RGB2GRAY);
//canny
Imgproc.Canny(grayMat1, mCannyMat1, 80, 160);
//houghlinesp
Imgproc.HoughLinesP(mCannyMat1, lines, 1, Math.PI /180, 30,100,30);

editText=(EditText)findViewById(R.id.show_feature_Text);
            editText.setText("lines="+lines.dump());
for (int y=0;y<lines1.rows();y++)
{
    double[] vec = lines1.get(y, 0);

    double  x1 = vec[0], 
    y1 = vec[1],
    x2 = vec[2],
    y2 = vec[3];    

    Point start = new Point(x1, y1);
    Point end = new Point(x2, y2);
    Imgproc.line(mCannyMat2, start, end, new Scalar(255,0,0), 1);
}

Bitmap grayBmp2 = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Config.RGB_565);
Utils.matToBitmap(mCannyMat2, grayBmp2);

imageView.setImageBitmap(grayBmp2);
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值