java+对图像进行直线检测_Java调用OpenCV进行Hough变换直线检测

private BitmapHoughTransFormLine(Bitmap bmp){Mat rgbMat = new Mat(); //存储原图像的矩阵Mat grayMat = new Mat(); //存储灰度图像的矩阵Mat lineMat = new Mat(); //存储检测出的直线坐标的矩阵,每个element有4个通道,第1、2个通道为直线的1个端点,第3、4个通道为直线的另...
摘要由CSDN通过智能技术生成

private BitmapHoughTransFormLine(Bitmap bmp)

{

Mat rgbMat = new Mat();  //存储原图像的矩阵

Mat grayMat = new Mat(); //存储灰度图像的矩阵

Mat lineMat = new Mat(); //存储检测出的直线坐标的矩阵,每个element有4个通道,第1、2个通道为直线的1个端点,第3、4个通道为直线的另1个端点

Utils.bitmapToMat(bmp, rgbMat);

Imgproc.cvtColor(rgbMat,grayMat, Imgproc.COLOR_RGB2GRAY); //灰度化

Imgproc.Canny(grayMat, grayMat,50, 200);                  //Canny边缘检测

/* Hough变换标记直线

* public static void HoughLinesP(Matimage, Mat lines, double rho, double theta, int threshold)

*    image - 8-bit, single-channel binary source image. The image may bemodified by the function.

*    lines - Output vector of lines. Each line is represented by a 4-elementvector (x_1, y_1, x_2, y_2),

*                where (x_1,y_1) and (x_2, y_2) arethe ending points of each detected line segment.

*    rho - Distance

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值