当前位置:网站首页>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)
边栏推荐
- How to make the conductive slip ring signal better
- 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
- 项目经理有必要考NPDP吗?我告诉你答案
- The usage of rand function in MATLAB
- Sword finger offer II 041 Average value of sliding window
- The numerical value of the number of figures thought of by the real-time update of the ranking list
- 腾讯游戏客户端开发面试 (Unity + Cocos) 双重轰炸 社招6轮面试
- NPM internal split module
- The function of carbon brush slip ring in generator
- In depth analysis of ArrayList source code, from the most basic capacity expansion principle, to the magic iterator and fast fail mechanism, you have everything you want!!!
猜你喜欢
Guojingxin center "APEC education +" Shanghai Jiaotong University Japan Cooperation Center x Fudan philosophy class "Zhe Yi" 2022 New Year greetings
Remote Sensing投稿經驗分享
COMSOL----微阻梁模型的搭建---最终的温度分布和变形情况---材料的添加
Get familiar with XML parsing quickly
从cmath文件看名字是怎样被添加到命名空间std中的
nacos-微服务网关Gateway组件 +Swagger2接口生成
【目标跟踪】|DiMP: Learning Discriminative Model Prediction for Tracking
MATLAB R2021b 安装libsvm
The persistence mode of redis - RDB and AOF persistence mechanisms
从Starfish OS持续对SFO的通缩消耗,长远看SFO的价值
随机推荐
regular expression
能力贡献 GBASE三大解决方案入选“金融信创生态实验室-金融信创解决方案(第一批)”
腾讯游戏客户端开发面试 (Unity + Cocos) 双重轰炸 社招6轮面试
Introduction to grpc for cloud native application development
STM32GPIO口的工作原理
About snake equation (1)
uniapp一键复制功能效果demo(整理)
Kindle operation: transfer downloaded books and change book cover
Understanding of expectation, variance, covariance and correlation coefficient
nacos-微服务网关Gateway组件 +Swagger2接口生成
Understanding of prior probability, posterior probability and Bayesian formula
pb9.0 insert ole control 错误的修复工具
Redis集群
The foreach map in JS cannot jump out of the loop problem and whether foreach will modify the original array
Codeforces Round #633 (Div. 2) B. Sorted Adjacent Differences
The difference between distribution function and probability density function of random variables
Mat file usage
Leetcode exercise - Sword finger offer 36 Binary search tree and bidirectional linked list
云原生应用开发之 gRPC 入门
After modifying the background of jupyter notebook and adding jupyterthemes, enter 'JT -l' and the error 'JT' is not an internal or external command, nor a runnable program