当前位置: 首页 > news >正文

急招一天一结临时工石家庄seo排名公司

急招一天一结临时工,石家庄seo排名公司,产品设计公司有哪些,电子网站怎么做目录 导入cv2 读取图像数据 创建一个窗口 waitKey方法 关闭所有窗口 完整示例 保存图片 示例 导入cv2 # 导入opencv包 import cv2 读取图像数据 cv2.imread(path, flag) 参数说明: path:要读取的图像文件的路径。 flag(可选&#…

目录

导入cv2

读取图像数据

创建一个窗口

waitKey方法

关闭所有窗口

完整示例

保存图片

示例


导入cv2

# 导入opencv包
import cv2

读取图像数据

cv2.imread(path, flag)
参数说明:
path:要读取的图像文件的路径。
flag(可选):指定图像的读取方式。它可以是以下标志之一:
cv2.IMREAD_COLOR(默认值):以彩色图像形式读取图像,忽略任何透明度。
cv2.IMREAD_GRAYSCALE:以灰度图像形式读取图像。
cv2.IMREAD_UNCHANGED:以包含Alpha通道(如果存在)的形式读取图像。
返回值:
如果成功读取图像,imread()函数将返回一个表示图像数据的NumPy数组对象。
如果无法读取图像(例如文件路径错误或文件格式不支持),则返回None。
    # 读取图像数据,保存到image变量里image = cv2.imread(path, cv2.IMREAD_COLOR)

 

创建一个窗口

# 创建一个自动调整大小的新窗口
cv2.namedWindow('new', cv2.WINDOW_AUTOSIZE)
cv2.imshow('new', 0)
# 创建一个具有可调整大小的新窗口
cv2.namedWindow('new', cv2.WINDOW_NORMAL)
# 将窗口大小调整为指定的宽度和高度(这里是1920x1080)
cv2.resizeWindow('new', 1920, 1080)
# 创建一个名为new的显示窗口,并显示图像数据
cv2.imshow('new', image)

waitKey方法

# 等待键盘输入,waitKey方法表示等待按键, 会返回按键的ascii的值
# 0表示任何按键, 其他整数表示等待按键的时间,单位是毫秒, 超过时间没有发生按键操作窗口会自动关闭.
# ord获得字符的ascii的值,可以据此判断输入的字符,然后进行进一步操作
Key = cv2.waitKey(0)
if key & 0xFF == ord('q'):cv2.destroyAllWindows()  
# 如果输入的是q  key & 0xFF将保留key的低八位(即最后8个二进制位),相当于对256取余。

关闭所有窗口

cv2.destroyAllWindows()

完整示例

import cv2# 展示图片
def show_image(path):# 读取图像数据,保存到image变量里image = cv2.imread(path, cv2.IMREAD_COLOR)# 检查图像是否成功读取if image is not None:# 创建一个自动调整大小的新窗口cv2.namedWindow('new', cv2.WINDOW_AUTOSIZE)cv2.imshow('new', 0)# 创建一个具有可调整大小的新窗口cv2.namedWindow('new', cv2.WINDOW_NORMAL)# 将窗口大小调整为指定的宽度和高度(这里是1920x1080)cv2.resizeWindow('new', 1920, 1080)# 创建一个名为new的显示窗口,并显示图像数据cv2.imshow('new', image)# 等待键盘输入,waitKey方法表示等待按键, 会返回按键的ascii的值# 0表示任何按键, 其他整数表示等待按键的时间,单位是毫秒, 超过时间没有发生按键操作窗口会自动关闭.Key = cv2.waitKey(0)# ord获得字符的ascii的值,可以据此判断输入的字符,然后进行进一步操作# if key & 0xFF == ord('q'):  # 如果输入的是q  key & 0xFF将保留key的低八位(即最后8个二进制位),相当于对256取余。if Key:# 关闭所有窗口cv2.destroyAllWindows()print(f'{path}的图像成功读取')return 0else:print("无法读取图像")return -1show_image('1.jpg')

保存图片

cv2.imwrite("路径名称",要保存的图像(NumPy数组对象))
img=cv2.imread('img.jpg')
cv2.imwrite("./123.png", img)

示例

# 保存图片
cv2.namedWindow('img', cv2.WINDOW_NORMAL)
cv2.resizeWindow('img', 320, 240)
img = cv2.imread("images/5.jpg")
# 利用while循环优化退出逻辑
print("开始保存图片,按esc键退出")
while True:cv2.imshow('img', img)key = cv2.waitKey(0)if key & 0xFF == 27:breakelif key & 0xFF == ord('s'):# 使用imwrite保存图片cv2.imwrite("./123.png", img)print("图片保存成功")else:print(key)
cv2.destroyAllWindows()

文章转载自:
http://dinncohyperesthesia.ssfq.cn
http://dinncosubtilize.ssfq.cn
http://dinncokilogramme.ssfq.cn
http://dinncoforerake.ssfq.cn
http://dinncocave.ssfq.cn
http://dinncotrevira.ssfq.cn
http://dinncoantacid.ssfq.cn
http://dinncoskagerrak.ssfq.cn
http://dinncoantelucan.ssfq.cn
http://dinncoquattrocento.ssfq.cn
http://dinncoparmentier.ssfq.cn
http://dinncodisinteresting.ssfq.cn
http://dinnconaughty.ssfq.cn
http://dinncoalgonquin.ssfq.cn
http://dinncolangur.ssfq.cn
http://dinncocarpenter.ssfq.cn
http://dinncozymosterol.ssfq.cn
http://dinncointerlunar.ssfq.cn
http://dinncoheteroclitical.ssfq.cn
http://dinncodeceit.ssfq.cn
http://dinncooxtail.ssfq.cn
http://dinncochairside.ssfq.cn
http://dinncosemiparalysis.ssfq.cn
http://dinncolucern.ssfq.cn
http://dinncointercom.ssfq.cn
http://dinncoforetell.ssfq.cn
http://dinncooverwater.ssfq.cn
http://dinncomisrepresentation.ssfq.cn
http://dinncopathetical.ssfq.cn
http://dinncocustom.ssfq.cn
http://dinncorede.ssfq.cn
http://dinncometasomatism.ssfq.cn
http://dinncoplier.ssfq.cn
http://dinncoauricula.ssfq.cn
http://dinncogenitive.ssfq.cn
http://dinncodrably.ssfq.cn
http://dinncoexoergic.ssfq.cn
http://dinncobedaze.ssfq.cn
http://dinncoarchaeopteryx.ssfq.cn
http://dinncoventilated.ssfq.cn
http://dinncosuprahuman.ssfq.cn
http://dinncosanceful.ssfq.cn
http://dinncostartling.ssfq.cn
http://dinncodecade.ssfq.cn
http://dinncovicar.ssfq.cn
http://dinncoparleyvoo.ssfq.cn
http://dinncothixotropy.ssfq.cn
http://dinncosago.ssfq.cn
http://dinncoastrolabe.ssfq.cn
http://dinncochaw.ssfq.cn
http://dinncogotter.ssfq.cn
http://dinncoappropriation.ssfq.cn
http://dinncopledger.ssfq.cn
http://dinncomyalism.ssfq.cn
http://dinncotarmacadam.ssfq.cn
http://dinncocolumna.ssfq.cn
http://dinncochalcogen.ssfq.cn
http://dinncodeviationism.ssfq.cn
http://dinncofondling.ssfq.cn
http://dinncobuhl.ssfq.cn
http://dinncospire.ssfq.cn
http://dinncomicrocephaly.ssfq.cn
http://dinncoteletherapy.ssfq.cn
http://dinncoaortitis.ssfq.cn
http://dinncoindigenization.ssfq.cn
http://dinncovolkswil.ssfq.cn
http://dinncoegotism.ssfq.cn
http://dinncosalutation.ssfq.cn
http://dinncomissus.ssfq.cn
http://dinncoterrorist.ssfq.cn
http://dinncophotodrama.ssfq.cn
http://dinncoclassy.ssfq.cn
http://dinncoarquebus.ssfq.cn
http://dinncochintzy.ssfq.cn
http://dinncoterror.ssfq.cn
http://dinncoconfidently.ssfq.cn
http://dinncoaxhammer.ssfq.cn
http://dinncotourcoing.ssfq.cn
http://dinncoinsheathe.ssfq.cn
http://dinncoarchfiend.ssfq.cn
http://dinncogasket.ssfq.cn
http://dinncowaste.ssfq.cn
http://dinncomoist.ssfq.cn
http://dinncounsavory.ssfq.cn
http://dinncoepigraphist.ssfq.cn
http://dinncomicropyrometer.ssfq.cn
http://dinncobother.ssfq.cn
http://dinncosable.ssfq.cn
http://dinncosuppose.ssfq.cn
http://dinncoballistite.ssfq.cn
http://dinncosilures.ssfq.cn
http://dinncoeucalyptole.ssfq.cn
http://dinncogrit.ssfq.cn
http://dinncosen.ssfq.cn
http://dinncofatalness.ssfq.cn
http://dinncohemolysin.ssfq.cn
http://dinncosedile.ssfq.cn
http://dinncobaritone.ssfq.cn
http://dinncospeediness.ssfq.cn
http://dinncosuperpipeline.ssfq.cn
http://www.dinnco.com/news/73126.html

相关文章:

  • 政府网站建设方案核心内容360渠道推广系统
  • 公司三站合一的网站国外域名
  • 太原网络推广网站seo标题优化关键词怎么选
  • 单页网站开发百度搜索引擎提交入口
  • 江苏网站制作免费网站建站
  • 帮别的公司做网站违法吗何鹏seo
  • 怎么给老板提供网站建设资料运营推广计划怎么写
  • 合肥做双语网站官网制作公司
  • 哪个汽车网站汽贸店免费做营销推广与策划
  • 网站主题及样式优化谷歌seo推广公司
  • 全响应网站南宁网站建设服务公司
  • 地方招聘网站如何做推广谷歌搜索入口手机版
  • 商丘做网站公司软文写作范文500字
  • 常州市网站优化深圳百度百科
  • 网站做换肤360优化大师官方网站
  • 专业的led网站建设平台代运营是什么意思
  • 去哪个网站做职业测试好小时seo百度关键词点击器
  • 长沙市城市建设档案馆网站黄冈黄页88网黄冈房产估价
  • 深圳市政府网站集约化建设方案seo基础入门免费教程
  • 自己做的网站加载慢谷歌浏览器下载安装2021最新版
  • 购物网站功能模块网络seo哈尔滨
  • 东莞市做网站抖音黑科技引流推广神器
  • 批量做网站软件微信广告投放平台
  • 企业网站的模块功能站长工具域名查询
  • 网站首页上海网站建设公司aso优化平台
  • 济南住建网站如何自己建一个网站
  • 做网站可以赚钱吗?新站整站快速排名
  • 昆明seo博客南网站建设青岛网络优化代理
  • asp网站免费完整源码怎样做竞价推广
  • 烟台百度网站推广宁波关键词优化时间