当前位置:网站首页>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)
边栏推荐
- Version 2.0 of tapdata, the open source live data platform, has been released
- 能力贡献 GBASE三大解决方案入选“金融信创生态实验室-金融信创解决方案(第一批)”
- Qml 字体使用pixelSize来自适应界面
- Break algorithm --- map
- COMSOL - Construction of micro resistance beam model - final temperature distribution and deformation - establishment of geometric model
- How to make the conductive slip ring signal better
- 项目经理有必要考NPDP吗?我告诉你答案
- npm 内部拆分模块
- qt-使用自带的应用框架建立--hello world--使用min GW 32bit
- Guojingxin center "APEC education +" Shanghai Jiaotong University Japan Cooperation Center x Fudan philosophy class "Zhe Yi" 2022 New Year greetings
猜你喜欢

快速熟知XML解析

qt-使用自带的应用框架建立--hello world--使用min GW 32bit

About how USRP sets the sampling frequency below the minimum sampling frequency reached by the hardware

3. Multi agent reinforcement learning

LeetCode 练习——剑指 Offer 36. 二叉搜索树与双向链表

Gnuradio transmits video and displays it in real time using VLC

Capability contribution three solutions of gbase were selected into the "financial information innovation ecological laboratory - financial information innovation solutions (the first batch)"

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

Redis cluster

How to fix the slip ring
随机推荐
common commands
AttributeError: ‘str‘ object has no attribute ‘strftime‘
Codeforces Round #643 (Div. 2)——B. Young Explorers
ROS problems (topic types do not match, topic datatype/md5sum not match, MSG XXX have changed. rerun cmake)
The beauty of Mathematics -- the principle of fine Fourier transform
[SolidWorks] modify the drawing format
Usage of hydraulic rotary joint
3、多智能体强化学习
Anaconda3 download address Tsinghua University open source software mirror station
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
Understanding of maximum likelihood estimation
COMSOL----微阻梁模型的搭建---最终的温度分布和变形情况----几何模型的建立
Mysql database (2)
滑环在直驱电机转子的应用领域
Mat file usage
pb9.0 insert ole control 错误的修复工具
【目标跟踪】|atom
What kind of MES system is a good system
3. Multi agent reinforcement learning
Usage of xcolor color in latex