opencv计算机视觉

什么是计算机视觉? (What is Computer Vision?)

Computer Vision is like imparting human intelligence and instincts to acomputer. In other words it is a field of computer science that works onenabling computers to see, identify and process images in the same waythat the human eye does.Let us say you and your family went on a vacation and you uploaded a fewpictures on Facebook. However, it takes time to find your parents’ facesand tag them in each picture, Facebook is intelligent enough to tag peoplefor you.But, how do you think this auto-tag feature works? It works throughcomputer vision.

计算机视觉就像赋予计算机以人类智慧和本能。 换句话说,这是计算机科学领域,它使计算机能够以与人眼相同的方式查看,识别和处理图像。让我们说您和您的家人去度假了,您在Facebook上上传了一些图片。 但是,查找父母的脸并在每张照片中标记它们需要花费时间,Facebook足够智能为您标记人物,但是您如何看待这种自动标记功能呢? 它通过计算机视觉起作用。

什么是OpenCV? (What is OpenCV?)

OpenCV was built to provide a common infrastructure for computer visionapplications and to accelerate the use of machine perception in commercialproducts. This library has more than 2500 algorithms used to detect andrecognize human faces, identify images, track moving objects, extract 3Dmodels of objects.

OpenCV构建旨在为计算机视觉应用程序提供通用的基础结构,并加速在商业产品中使用机器感知。 该库具有2500多种算法,可用于检测和识别人脸,识别图像,跟踪运动对象,提取对象的3D模型。

安装OpenCV (Installation of OpenCV)

To install OpenCV for python use the following code in terminal:

要在python中安装OpenCV,请在终端中使用以下代码:

$ python3 -m pip install opencv-python$ python3 -m pip install opencv-contrib-python

$ python3 -m pip安装opencv-python $ python3 -m pip安装opencv-contrib-python

计算机如何读取图像? (How does a computer read an image?)

Click from New York Square
从纽约广场点击

We can look at this image and figure it out that it belongs to New YorkSquare. But, computers cannot analyze it. It doesn’t have any intelligence.For any color image, there are 3 primary channels — red, green and blue.A matrix is formed for every primary color, and later, these matricescombine to provide a pixel value for the individual R, G, and B colors. Eachelement of the matrices provides data pertaining to the intensity of brightness of the pixel. It reads any image as a range of values between 0and 255.

我们可以查看一下这张图,并弄清楚它属于New YorkSquare。 但是,计算机无法对其进行分析。 它没有任何智能。对于任何彩色图像,都有3个原色通道-红色,绿色和蓝色。每种原色均形成一个矩阵,然后,这些矩阵组合起来为各个R,G提供像素值和B颜色。 矩阵的每个元素提供与像素的亮度强度有关的数据。 它读取任何图像作为0到255之间的值范围。

如何通过相机捕获图像和视频? (How to capture images and videos through a camera?)

import cv2

导入cv2

cap = cv2.VideoCapture(0)

上限= cv2.VideoCapture(0)

while True:

而True:

ret, frame = cap.read()

ret,frame = cap.read()

cv2.imshow(“Capturing”,frame)

cv2.imshow(“捕获”,帧)

if cv2.waitKey(1) & 0xFF == ord(‘q’):

如果cv2.waitKey(1)和0xFF == ord('q'):

break

打破

cap.release()

cap.release()

cv2.destroyAllWindows()

cv2.destroyAllWindows()

As seen in the above piece of code, we need to import the OpenCV library, cv2.VideoCapture() triggers the camera, cv2.imshow shows what the camera is capturing by opening a new window. cv2.waitKey makes the window static until the user presses a key.

如上面的代码所示,我们需要导入OpenCV库, cv2.VideoCapture() 触发摄像机, cv2.imshow 通过打开新窗口显示摄像机正在捕获的内容。 cv2.waitKey 使窗口保持静态,直到用户按下一个键。

OpenCV基本功能 (Basic functions of OpenCV)

Loading images using OpenCV and converting it into GrayScale:

使用OpenCV加载图像并将其转换为GrayScale:

import numpy as np

将numpy导入为np

import cv2

导入cv2

img = cv2.imread(‘Image123.png’,0) #write the name of an image

img = cv2.imread('Image123.png',0)#写入图片名称

cv2.imshow(‘image’,img)

cv2.imshow('image',img)

k = cv2.waitKey(0) & 0xFF

k = cv2.waitKey(0)和0xFF

if k == 27: # wait for ESC key to exit

如果k == 27:#等待ESC键退出

cv2.destroyAllWindows()

cv2.destroyAllWindows()

elif k == ord(‘s’): # wait for ‘s’ key to save and exit

elif k == ord('s'):#等待's'键保存并退出

cv2.imwrite(‘Firefox_wallpapergray.png’,img)

cv2.imwrite('Firefox_wallpapergray.png',img)

cv2.destroyAllWindows()

cv2.destroyAllWindows()

cv2.imread reads the selected image and the 0 parameter turns the image into grayscale, cv2.imshow shows the converted image.

cv2.imread 读取所选图像, 0 参数将图像变为灰度, cv2.imshow 显示转换后的图像。

Drawing and writing on an Image:

在图像上绘图和书写:

import numpy as np

将numpy导入为np

import cv2

导入cv2

img = cv2.imread(‘black.jpg’,cv2.IMREAD_COLOR)

img = cv2.imread('black.jpg',cv2.IMREAD_COLOR)

cv2.line(img,(0,0),(511,511),(255,0,0),5)

cv2.line(img,(0,0),(511,511),(255,0,0),5)

cv2.rectangle(img,(384,0),(510,128),(0,255,0),3)

cv2.rectangle(img,(384,0),(510,128),(0,255,0),3)

cv2.circle(img,(447,63), 63, (0,0,255), -1)

cv2.circle(img,(447,63),63,(0,0,255),-1)

font = cv2.FONT_HERSHEY_SIMPLEX

字体= cv2.FONT_HERSHEY_SIMPLEX

cv2.putText(img,’OpenCV’,(10,500), font, 4,(255,255,255),2,cv2.LINE_AA)

cv2.putText(img,'OpenCV',(10,500),字体,4,(255,255,255),2,cv2.LINE_AA)

cv2.imshow(‘image’,img)

cv2.imshow('image',img)

cv2.waitKey(0)

cv2.waitKey(0)

cv2.destroyAllWindows()

cv2.destroyAllWindows()

cv2.line draws the line with given coordinates on the image, cv2.rectangle, cv2.circle draws a rectangle and circle respectively and cv2.putText writes the given text, here we have used Hershey Simpex font.

cv2.line 在图像上绘制具有给定坐标的线, cv2.rectangle cv2.circle 分别绘制矩形和圆形, cv2.putText 编写给定的文本,这里我们使用了Hershey Simpex字体。

Output:

输出:

Output after drawing and writing on an image.
在图像上绘制和写入后输出。

Feature and Template Matching:

功能和模板匹配:

Template matching is basically the portion of one image matching another image.

模板匹配基本上是一个图像与另一个图像匹配的部分。

import cv2

导入cv2

import numpy as np

将numpy导入为np

img_bgr=cv2.imread(‘sc1.png’)

img_bgr = cv2.imread('sc1.png')

img_gray=cv2.cvtColor(img_bgr, cv2.COLOR_BGR2GRAY)

img_gray = cv2.cvtColor(img_bgr,cv2.COLOR_BGR2GRAY)

template=cv2.imread(‘sc2.png’,0)

template = cv2.imread('sc2.png',0)

w,h=template.shape[::-1]

w,h = template.shape [::-1]

res=cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)

res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)

threshold=0.8

阈值= 0.8

loc=np.where(res>=threshold)

loc = np.where(res> =阈值)

for pt in zip(*loc[::-1]):

用于zip(* loc [::-1])中的pt:

cv2.rectangle(img_bgr, pt, (pt[0]+w, pt[1]+h), (0,255,255),2)

cv2.rectangle(img_bgr,pt,(pt [0] + w,pt [1] + h),(0,255,255),2)

cv2.imshow(‘detected’,img_bgr)

cv2.imshow('检测到',img_bgr)

cv2.waitKey()

cv2.waitKey()

cv2.imread reads the selected image, cv2.cvtColor converts the image into Grayscale, w and h variables are the positions of x and y-axis, cv2.matchTemplate helps to match the common area of two images with threshold 80%, cv2.rectangle marks the area which is matching in the image.

cv2.imread 读取选定的图像, cv2.cvtColor 将图像转换为灰度,w和h变量是x和y轴的位置, cv2.matchTemplate 有助于将阈值80% cv2 的两个图像的公共区域进行匹配 。矩形 标记图像中匹配的区域。

Output:

输出:

Output of Template matching.
输出模板匹配。

Gradients and Edge Detection:

渐变和边缘检测:

import cv2

导入cv2

import numpy as np

将numpy导入为np

cap=cv2.VideoCapture(0)

cap = cv2.VideoCapture(0)

while True:

而True:

_, frame=cap.read()

_,frame = cap.read()

a= cv2.Laplacian(frame,cv2.CV_64F)

a = cv2.Laplacian(frame,cv2.CV_64F)

x= cv2.Sobel(frame,cv2.CV_64F,1 ,0, ksize=5)

x = cv2.Sobel(frame,cv2.CV_64F,1,0,ksize = 5)

y= cv2.Sobel(frame,cv2.CV_64F,0 ,1, ksize=5)

y = cv2.Sobel(frame,cv2.CV_64F,0,1,ksize = 5)

edge= cv2.Canny(frame, 100, 200)

edge = cv2.Canny(frame,100,200)

cv2.imshow(‘original’,frame)

cv2.imshow('原始',帧)

cv2.imshow(‘laplacian’,a)

cv2.imshow('laplacian',a)

cv2.imshow(‘sobelx’,x)

cv2.imshow('sobelx',x)

cv2.imshow(‘sobely’,y)

cv2.imshow('sobely',y)

cv2.imshow(‘edge’,edge)

cv2.imshow('edge',edge)

k=cv2.waitKey(5) & 0xFF

k = cv2.waitKey(5)和0xFF

if k == 27:

如果k == 27:

break

打破

cv2.destroyAllWindows()

cv2.destroyAllWindows()

cap.release()

cap.release()

cv2.Laplacian converts the image into the gradient, we use cv2.CV_64F as a standard label, cv2.Sobel converts into a horizontal and vertical gradient.

cv2.Laplacian 将图像转换为渐变,我们使用 cv2.CV_64F 作为标准标签 cv2.Sobel 转换为水平和垂直渐变。

Output:

输出:

Laplacian拉普拉斯人
Vertical Gradient垂直渐变
Edge Detection边缘检测
Horizontal Gradient水平渐变
Fingerprint matching and Edge detection of embryo from mother’s womb.
母亲子宫中的胚胎的指纹匹配和边缘检测。

Edge detection is pervasive in many applications such as fingerprint matching, medical diagnosis & license plate detection. These applications basically highlight the areas where image intensity changes drastically and ignore everything else.

边缘检测在许多应用中非常普遍,例如指纹匹配,医学诊断和车牌检测。 这些应用程序基本上突出了图像强度急剧变化的区域,而忽略了其他所有内容。

Edge Detection is also used in Self Driving Cars for lane detection:

边缘检测还用于自动驾驶汽车的车道检测:

Land detection of roads using OpenCV.
使用OpenCV对道路进行土地检测。

Other features of OpenCV: Motion Detection, Intrusion Detection, Haar Cascades, MOG background reduction, Homography, Corner Detection, Color Filtering, Thresholding, Image Arithmetics etc..

OpenCV其他功能:运动检测,入侵检测,Haar级联,MOG背景减少,单应性,角点检测,颜色过滤,阈值处理,图像算法等。

Statistical machine learning libraries used by OpenCV: Naive Bayes classifier, K-nearest neighbour algorithm, Decision tree learning, Meta- Algorithm, Random forest, Support vector machine, Deep & Convolutional neural networks.

OpenCV使用的统计机器学习库:朴素贝叶斯分类器,K近邻算法,决策树学习,元算法,随机森林,支持向量机,深度和卷积神经网络。

Some popular applications of OpenCV:

OpenCV一些流行应用程序:

Driver drowsiness detection (using a camera in a car) alerts the car driver through buzz or alarm.

驾驶员睡意检测(在汽车中使用摄像头)通过嗡嗡声或警报提醒汽车驾驶员。

Vehicle counting on highways (can be segregated into buses, cars, trucks) along with their speeds.

指望公路上的车辆(可以分为公共汽车,小汽车,卡车)及其速度。

Anomaly detection in the manufacturing process (the odd defective products).

生产过程中的异常检测(奇数次品)。

The ANPR called automatic number plate recognition is used to control vehicle tracing and counting number of people.

ANPR被称为自动车牌识别,用于控制车辆追踪和人数统计。

OpenCV is also used in imaging the data and provides better prediction and treatment to diseases like blood flow, x-ray images that are interpreted by humans.

OpenCV还用于对数据进行成像,并为人类解释的诸如血流,X射线图像等疾病提供更好的预测和治疗。

翻译自: https://medium.com/the-art-of-data/opencv-a-supreme-tool-for-computer-vision-f9c1b488bb81

opencv计算机视觉


http://www.taodudu.cc/news/show-4773377.html

相关文章:

  • 红米k30 允许调用gpu调试层_2499元的红米K30S至尊纪念版,会是性价比最高的865神机吗?...
  • k30最小宽度380不管用了_K30系列最强机,Redmi K30S至尊纪念版评测
  • 随手拍好片如何炼成?用完小米10至尊纪念版我就明白了
  • 小米10至尊纪念版和realmeX7pro玩家版 的区别
  • k30s刷鸿蒙系统,红米K40和K30S至尊纪念版哪个好?
  • 穿越洪荒之鸿蒙紫气系统,洪荒:吾乃鸿蒙至尊
  • xshell连接centos vi编辑器不能使用小键盘
  • Ubuntu20数字键盘(小键盘)输入无响应或变方向键
  • 戴戴戴师兄-数据分析课程笔记(第二讲)
  • 餐饮数据分析
  • 离线数据仓库
  • 数据分析实战项目-用户行为分析(Python)
  • 考拉电子公司—GMV异常分析及RFM用户价值分析
  • 初级会计难吗,用不用报班,自学可以吗?速看!
  • 会计本科转计算机,会计专业转行干设计工作,这些宝贵经验和感悟,对你有用(一)...
  • 计算机对会计有什么好处,会计专业转行干过设计工作,这些宝贵经验和感悟,对你有用(三)...
  • python与会计的论文_甭管前浪后浪,写完论文的先浪!
  • 携职教育:初级会计考试明明不难,为什么通过率这么低?
  • 全民一起玩python求分享_全民一起玩Python 基础篇+提高篇
  • 西南财经大学跨考计算机,我的跨考会计经历-给2011年朋友的一点建议
  • 用python玩转数据第一周答案_用Python玩转数据_答案
  • 四大会计师事务所python数据分析_用Python玩转数据分析4
  • 老婆饼就是老婆,会计就是财务
  • 高级会计师评审需要职称计算机哪种考试级别,会计高级职称考哪些科目 评审条件是什么...
  • 中级会计还考职称计算机吗,如何应对中级会计职称考试全面实行无纸化
  • 你准备会计初级并通过考试用了多久?
  • 学会计软件测试,会计专业毕业生1个月转行软件测试,她是怎么做到的?
  • 会计初级可以自己报名吗_初级会计考试可以自学吗?我刚完成报名
  • 会计计算机敲打大赛,2017上半年会计实操技能竞赛“荣耀对决”总决赛!
  • 会计初级可以自己报名吗_初级会计考试可以自学吗?

opencv计算机视觉_opencv是计算机视觉的至尊工具相关推荐

  1. OpenCV开发团队开源计算机视觉标注工具CVAT

    OpenCV开发团队开源计算机视觉标注工具Computer Vision Annotation Tool (CVAT) 同时支持图像和视频的标注,最大特点是专业!专业团队做的专业水准的工具! (关注& ...

  2. 视频教程-OpenCV图像分割实战视频教程-计算机视觉

    OpenCV图像分割实战视频教程 贾志刚 2004毕业于山东大学齐鲁软件学院,软件工程专业.专注于图像处理算法学习与研究,计算机视觉OpenCV开发应用,深度学习在计算机视觉领域应用.书籍<Ja ...

  3. opencv 星空_opencv随笔1

    图像处理技术一般包括图像压缩,增强和复原,匹配 描述和l识别 3 个部分. 图像处理一般指数字图像处理 ( Digitallmage Processing). 其中,数字图像是指用工业相机.摄像机.扫 ...

  4. 用计算机视觉描述机器人,计算机视觉和机器人视觉概述

    1. 计算机视觉的概念    计算机视觉就是用各种成像系统代替视觉器官作为输入敏感手段,由计算机来代替大脑完成处理和解释.计算机视觉的最终研究目标就是使计算机能像人那样通过视觉观察和理解世界,具有自主 ...

  5. Paper之CVPRICCVECCV:2009年~2019年CVPRICCVECCV(国际计算机视觉与模式识别会议国际计算机视觉大会欧洲计算机视觉会议)历年最佳论文简介及其解读

    Paper之CVPR&ICCV&ECCV:2009年~2019年CVPR&ICCV&ECCV(国际计算机视觉与模式识别会议&国际计算机视觉大会&欧洲计算 ...

  6. 计算机视觉包含计算机图形学,[计算机视觉与图像识别]计算机视觉,计算机图形学和数字图像处理,三者之间的联系和区别.doc...

    [计算机视觉与图像识别]计算机视觉,计算机图形学和数字图像处理,三者之间的联系和区别.doc [计算机视觉与图像识别]计算机视觉,计算机图形学和数字图像处理,三者之间的联系和区别 篇一 : 计算机视觉 ...

  7. 不知道这 7 大 OpenCV 函数怎么向计算机视觉专家进阶?

    作者 | Lazar Gugleta 译者 | Arvin,责编 | 夕颜 头图 | CSDN付费下载自视觉中国 出品 | CSDN(ID:CSDNnews) 计算机视觉和计算机图形学现在非常流行,因 ...

  8. imread函数_不知道这 7 大 OpenCV 函数怎么向计算机视觉专家进阶?

    作者 | Lazar Gugleta译者 | Arvin,责编 | 夕颜头图 | CSDN付费下载自视觉中国出品 | CSDN(ID:CSDNnews)计算机视觉和计算机图形学现在非常流行,因为它们与 ...

  9. Opencv学习笔记_计算机视觉是什么?Opencv的起源

    从0开始学习"OPENCV"第一天-概述 在学习任何一门新的语言或者框架时都应该了解这个行业的背景知识,正所谓工欲善其事,必先利其器! 一.Opencv概述 1.      什么是 ...

最新文章

  1. 94.二叉树的中序遍历
  2. 10个 我经常逛的国外技术社区,真的受益匪浅!
  3. CCF - 201403-1 - 相反数
  4. Python进阶10-标准库介绍01
  5. JAVA——操场跑步路径定位模拟解决方案
  6. Ozone SCM HA设计浅谈
  7. cmos和ttl_TTL与CMOS电路怎么区分
  8. MQL5 编程基础: 文件
  9. Python+matplotlib绘制地图
  10. push rejected by remote
  11. Ubuntu Install Zhengma
  12. 自己动手搭建公司Git服务器
  13. Chromium网页Layer Tree绘制过程分析
  14. 【无标题】JAVA解压ZIP文件并解析Excel(easyExcel)
  15. sunxi:[0]全志SoC启动过程
  16. 一文读懂Java封装实例
  17. uniapp - 微信小程序端引入 Echarts 图表及使用详细教程,简单快速的解决方案(拒绝复杂的过程,附带详细的使用示例保姆级教程)
  18. 【Mybatis】Mybatis将String类型的0存到数据库中的number类型字段中,变成了空;
  19. 专业显卡深度学习_学习深度学习,如何选购显卡?
  20. 极光推送 使用实例 (一)服务端

热门文章

  1. Java计算机毕业设计水果商城源码+系统+数据库+lw文档
  2. CSS学习(三)—— 浮动与定位
  3. 工作交接_java后端
  4. self.font = core.getfont(font, size, index, encoding, layout_engine=layout_engine) OSError: cannot o
  5. VMware ESXi网络配置
  6. 前端Bootstrap框架
  7. Python+Office:轻松实现python自动化办公
  8. 【用VBA实现Word自动打印序列号】
  9. youtube-dl 命令
  10. 案例分享 | 如何实践 4 个用户体验设计原则