当前位置:网站首页>cv2-drawline
cv2-drawline
2022-07-08 01:52: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():
''' Draw a straight 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. '''
# Create a black image
img = np.zeros((512, 512, 3), np.uint8)
# Draw a picture 5px Wide diagonal
cv.line(img, (0, 0), (511, 511), (255, 0, 0), 5)
# display picture
cv.imshow('img', img)
key = cv.waitKey(0)
if key == ord('q'):
cv.destroyAllWindows()
def draw_rectangle():
''' Draw a rectangular 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)
边栏推荐
- C语言-Cmake-CMakeLists.txt教程
- 保姆级教程:Azkaban执行jar包(带测试样例及结果)
- Introduction à l'outil nmap et aux commandes communes
- PHP 计算个人所得税
- [target tracking] |dimp: learning discriminative model prediction for tracking
- About snake equation (5)
- Mysql database (2)
- Js中forEach map无法跳出循环问题以及forEach会不会修改原数组
- metasploit
- ArrayList源码深度剖析,从最基本的扩容原理,到魔幻的迭代器和fast-fail机制,你想要的这都有!!!
猜你喜欢

How to make the conductive slip ring signal better

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

C语言-Cmake-CMakeLists.txt教程

《ClickHouse原理解析与应用实践》读书笔记(7)

MySQL查询为什么没走索引?这篇文章带你全面解析

滑环使用如何固定

C语言-模块化-Clion(静态库,动态库)使用

How to make enterprise recruitment QR code?

QT build with built-in application framework -- Hello World -- use min GW 32bit

神经网络与深度学习-5- 感知机-PyTorch
随机推荐
cv2-drawline
Qml 字体使用pixelSize来自适应界面
ANSI / nema- mw- 1000-2020 magnetic iron wire standard Latest original
跨模态语义关联对齐检索-图像文本匹配(Image-Text Matching)
碳刷滑环在发电机中的作用
Partage d'expériences de contribution à distance
PHP to get information such as audio duration
神经网络与深度学习-5- 感知机-PyTorch
COMSOL - Construction of micro resistance beam model - final temperature distribution and deformation - establishment of geometric model
QT build with built-in application framework -- Hello World -- use min GW 32bit
[SolidWorks] modify the drawing format
nacos-微服务网关Gateway组件 +Swagger2接口生成
Matlab r2021b installing libsvm
软件测试笔试题你会吗?
PB9.0 insert OLE control error repair tool
SQLite3 data storage location created by Android
Urban land use distribution data / urban functional zoning distribution data / urban POI points of interest / vegetation type distribution
pb9.0 insert ole control 错误的修复工具
C语言-模块化-Clion(静态库,动态库)使用
NPDP在国内有认可度吗?看一看就明白了!