opencv-api draw

img=cv.arrowedLine(img, pt1, pt2, color[, thickness[, line_type[, shift[, tipLength]]]])
参数描述
img返回值,绘制完的图片
img绘制之前的图片
pt1直线箭头开始的位置
pt2直线箭头结束的位置
color直线箭头的颜色
thickness直线箭头的宽度
line_type直线间的样式
img=cv.circle(img, center, radius, color[, thickness[, lineType[, shift]]])
参数描述
img返回值,绘制完的图片
img绘制之前的图片
center圆心所在的位置
radius圆的半径
color圆的颜色
thickness圆的宽度
line_type圆的样式
img=cv.drawMarker(img, position, color[, markerType[, markerSize[, thickness[, line_type]]]])
参数描述
img返回值,绘制完的图片
img绘制之前的图片
position记号所在的位置
color记号的颜色
markerType记号的样式
thickness记号外围线的宽度
line_type记号的类型
markerSize记号的大小
img	=	cv.ellipse(	img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]	)
img	=	cv.ellipse(	img, box, color[, thickness[, lineType]]	)

画简单的椭圆

参数描述
img返回值,绘制椭圆之后的图像
img绘画的图片
center椭圆的中心
axes椭圆的两个半径
angle椭圆旋转角度
startAngle开始做圆的角度
endAngle结束做圆的角度
color椭圆的颜色
thickness椭圆边缘厚度
lineType椭圆线的样式
	img	=	cv.line(	img, pt1, pt2, color[, thickness[, lineType[, shift]]]	)
参数描述
img返回值,绘制完直线的图片
img原始图片
pt1直线开始的坐标
pt2直线结束的坐标
color直线的颜色
img	=	cv.putText(	img, text, org, fontFace, fontScale, color[, thickness[, lineType[, bottomLeftOrigin]]]	)
参数描述
img返回值,绘制完文字的图片
img原始图片
org文字的坐标
fontFace文字的样式
fontScale文字的大小
color文字的颜色
thickness文字边缘的大小
lineType线的样式
bottomLeftOrigin为真是以文字的左下角作为文字的坐标,否则则是以文字的左上角作为文字的坐标

img = cv.rectangle( img, pt1, pt2, color[, thickness[, lineType[, shift]]] )

参数描述
img返回值,绘制完矩形的图片
pt1顶点坐标
pt2顶点对角坐标
color矩形的颜色
thickness矩形边线的粗细
lineType线的类型

参考文献:
/d6/d6e/group__imgproc__draw.html#gaf10604b069374903dbd0f0488cb43670

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用OpenCV的Java API中的findContours方法可以找到轮廓。要找到内轮廓,需要先找到所有外部轮廓,然后在这些轮廓中找到子轮廓。 以下是一个示例代码,它将在图像中找到所有外部和内部轮廓,并将其绘制在输出图像上: ``` import org.opencv.core.*; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; import java.util.ArrayList; import java.util.List; public class FindContours { public static void main(String[] args) { System.loadLibrary(Core.NATIVE_LIBRARY_NAME); // Load image Mat image = Imgcodecs.imread("input.jpg"); // Convert to grayscale Mat gray = new Mat(); Imgproc.cvtColor(image, gray, Imgproc.COLOR_BGR2GRAY); // Threshold image Mat thresh = new Mat(); Imgproc.threshold(gray, thresh, 100, 255, Imgproc.THRESH_BINARY_INV); // Find contours List<MatOfPoint> contours = new ArrayList<>(); Mat hierarchy = new Mat(); Imgproc.findContours(thresh, contours, hierarchy, Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_SIMPLE); // Draw contours Mat output = new Mat(); image.copyTo(output); for (int i = 0; i < contours.size(); i++) { Imgproc.drawContours(output, contours, i, new Scalar(0, 0, 255), 2); // Find inner contours MatOfInt hull = new MatOfInt(); Imgproc.convexHull(contours.get(i), hull, false); List<MatOfPoint> innerContours = new ArrayList<>(); if (hierarchy.get(0, i)[2] != -1) { int inner = (int) hierarchy.get(0, i)[2]; while (inner != -1) { innerContours.add(contours.get(inner)); inner = (int) hierarchy.get(0, inner)[0]; } Imgproc.drawContours(output, innerContours, -1, new Scalar(0, 255, 0), 2); } } // Save output image Imgcodecs.imwrite("output.jpg", output); } } ``` 在这个示例中,我们首先将输入图像转换为灰度图像,然后对其进行二值化处理,以便找到轮廓。我们使用findContours方法来找到所有轮廓,并将它们绘制在输出图像上。然后,我们迭代所有轮廓,查找每个轮廓的内部轮廓,并将它们绘制为绿色。最后,我们将输出图像保存为文件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值