当前位置:网站首页>cv2-drawline
cv2-drawline
2022-07-08 00:23:00 【step step】
title: cv2 drawline
date: 2022-07-02 21:23:50
tags: opencv
cv2 drawline
import numpy as np
import cv2 as cv
def draw_line():
''' 画直线 cv.line(img, pt1, pt2, color, thickness) Parameters: img Image. pt1 First point of the line segment. pt2 Second point of the line segment. color Line color. thickness Line thickness. lineType Type of the line. See LineTypes. shift Number of fractional bits in the point coordinates. '''
#创建一个黑色的图像
img = np.zeros((512, 512, 3), np.uint8)
#画一条5px宽的对角线
cv.line(img, (0, 0), (511, 511), (255, 0, 0), 5)
#显示图片
cv.imshow('img', img)
key = cv.waitKey(0)
if key == ord('q'):
cv.destroyAllWindows()
def draw_rectangle():
''' 画矩形 cv.rectangle(img, pt1, pt2, color, thickness) Parameters img Image. pt1 Vertex of the rectangle. pt2 Vertex of the rectangle opposite to pt1 . color Rectangle color or brightness (grayscale image). thickness Thickness of lines that make up the rectangle. Negative values, like FILLED, mean that the function has to draw a filled rectangle. lineType Type of the line. See LineTypes shift Number of fractional bits in the point coordinates. '''
img = np.zeros((512, 512, 3), np.uint8)
cv.rectangle(img, (384, 0), (510, 128), (0, 256, 0), 3)
cv.imshow('img', img)
key = cv.waitKey(0)
if key == ord('q'):
cv.destroyAllWindows()
def draw_circle():
''' '''
img = np.zeros((512, 512), np.uint8)
cv.circle(img,(447,63), 63, (0,0,255), -1)
# cv.circle(img, (200, 63), 63, (0, 255, 0), 3)
cv.imshow('img', img)
key = cv.waitKey(0)
if key == ord('q'):
cv.destroyAllWindows()
def draw_polylines():
img = np.zeros((512, 512, 3), np.uint8)
pts = np.array([[10,5],[20,30],[70,20],[50,10]], np.int32)
pts = pts.reshape((-1, 1, 2))
cv.polylines(img, [pts], True, (0, 255, 255))
cv.imshow('img', img)
key = cv.waitKey(0)
if key == ord('q'):
cv.destroyAllWindows()
print(pts.shape)
边栏推荐
- Codeforces Round #643 (Div. 2)——B. Young Explorers
- Redis集群
- 不算不知道,花呗分期的真实利率居然这么高
- AttributeError: ‘str‘ object has no attribute ‘strftime‘
- 由排行榜实时更新想到的数状数值
- pb9.0 insert ole control 错误的修复工具
- 如何让导电滑环信号更好
- 【SolidWorks】修改工程图格式
- Kindle operation: transfer downloaded books and change book cover
- NPM Internal Split module
猜你喜欢

Graphic network: uncover the principle behind TCP's four waves, combined with the example of boyfriend and girlfriend breaking up, which is easy to understand

3. Multi agent reinforcement learning

Js中forEach map无法跳出循环问题以及forEach会不会修改原数组

Gnuradio3.9.4 create OOT module instances

为什么更新了 DNS 记录不生效?

Scalar / vector / matrix derivation method

ArrayList源码深度剖析,从最基本的扩容原理,到魔幻的迭代器和fast-fail机制,你想要的这都有!!!

Optimization of ecological | Lake Warehouse Integration: gbase 8A MPP + xeos

pb9.0 insert ole control 错误的修复工具

About snake equation (2)
随机推荐
Apache多个组件漏洞公开(CVE-2022-32533/CVE-2022-33980/CVE-2021-37839)
break net
Why does the updated DNS record not take effect?
How to make the conductive slip ring signal better
pb9.0 insert ole control 错误的修复工具
About snake equation (3)
用户之声 | 对于GBase 8a数据库学习的感悟
Codeforces Round #643 (Div. 2)——B. Young Explorers
body有8px的神秘边距
为什么更新了 DNS 记录不生效?
The beauty of Mathematics -- the principle of fine Fourier transform
项目经理有必要考NPDP吗?我告诉你答案
Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
Remote sensing contribution experience sharing
Urban land use distribution data / urban functional zoning distribution data / urban POI points of interest / vegetation type distribution
Chapter 7 behavior level modeling
液压旋转接头的使用事项
powerbuilder 中使用线程的方法
Gbase observation | how to protect the security of information system with frequent data leakage
MySQL数据库(2)