openCV python语言入门2|更新中
2022/2/20 17:26:56
本文主要是介绍openCV python语言入门2|更新中,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
- HSV颜色过滤
HSV颜色模型,共色调、饱和度、值三个参数
H是色调,S是饱和度, S = 0时,只有灰度,V是明度
import cv2 as cv import numpy as np cap = cv.VideoCapture(0) while(1): # Take each frame _, frame = cap.read() # Convert BGR to HSV hsv = cv.cvtColor(frame, cv.COLOR_BGR2HSV) # define range of blue color in HSV lower_blue = np.array([110,50,50]) upper_blue = np.array([130,255,255]) # Threshold the HSV image to get only blue colors mask = cv.inRange(hsv, lower_blue, upper_blue) # Bitwise-AND mask and original image res = cv.bitwise_and(frame,frame, mask= mask) cv.imshow('frame',frame) cv.imshow('mask',mask) cv.imshow('res',res) k = cv.waitKey(5) & 0xFF if k == 27:#ESC键退出 break cv.destroyAllWindows()View Code
inRange() 将保留范围内的颜色通道,其余均置0
将RGB转为HSV
>>> green = np.uint8([[[0,255,0 ]]]) >>> hsv_green = cv.cvtColor(green,cv.COLOR_BGR2HSV) >>> print( hsv_green ) [[[ 60 255 255]]]
[H-10, 100,100] and [H+10, 255, 255] 作为the lower bound和 upper bound
imread的参数
plt xticks用法
这篇关于openCV python语言入门2|更新中的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-21Python编程基础教程
- 2024-11-20Python编程基础与实践
- 2024-11-20Python编程基础与高级应用
- 2024-11-19Python 基础编程教程
- 2024-11-19Python基础入门教程
- 2024-11-17在FastAPI项目中添加一个生产级别的数据库——本地环境搭建指南
- 2024-11-16`PyMuPDF4LLM`:提取PDF数据的神器
- 2024-11-16四种数据科学Web界面框架快速对比:Rio、Reflex、Streamlit和Plotly Dash
- 2024-11-14获取参数学习:Python编程入门教程
- 2024-11-14Python编程基础入门