python配置opencv的方法_python配置opencv的方法

python配置opencv的方法

发布时间:2020-08-21 11:09:31

来源:亿速云

阅读:68

作者:小新

这篇文章将为大家详细讲解有关python配置opencv的方法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

在python中配置opencv库,使用pycharm环境

1.官网下载:点击打开链接,官网上有所有的openCV版本,找到你想要的版本和系统,点击之后,会弹出一个新的页面,不需要任何操作,便会自动下载。注明:这里没有32位和64位区别,安装程序会根据你的电脑系统自动选择安装32位还是64位的版本。如图中所示:

20423.jpg

2.双击运行openCV_xxx.exe执行程序

选择你要安装文件目录,然后点击extract,一路安装下去,就可以了。如图所示:

20424.jpg

3 .配置openCV环境变量

第一步,依次选择“计算机”,右键选择“属性”,"高级系统设置"->“环境变量”。找到环境变量下的“系统变量” ->"path"值,然后选择“编辑”如图所示:

20425.jpg

接着就是添加openCV的"bin"文件夹位置,这个"bin"就是你刚才openCV程序安装的目录下,如我的安装的位置是"F:\chengxin\openCV2.4.9\opencv\build\x64\vc11\bin"。注明:这里的"X64"表示我的电脑是64位的系统,如果你的电脑是32位,你应该在"x86"下面找,"VC11"表示我的电脑安装的是vs2012,如果你电脑上安装的是VS2010你应该在"vc10"文件夹下,如果是VS2013应该在"vc12"文件夹下,如图所示:

20426.jpg

在弹出的窗口中,“变量值”后面添加“;”和刚才的目录,也就是添加这个字符串";F:\chengxin\openCV2.4.9\opencv\build\x64\vc11\bin"。如图所示:

20427.jpg

openCV的安装和配置就到这里结束了。

配置python的openCV引用。

安装好了python和openCV,怎么让他们关联起来呢?首先找到你的openCV安装目录下的“cv2.pyd”文件,我的64位系统目录是“F:\chengxin\openCV2.4.9\opencv\build\python\2.7\x64”。如果你是32位系统,那么你应该是在“x86”下面。如图所示:

20429.jpg

将此文件复制后粘贴到python安装目录的“Python27\Lib\site-packages”下,我的是“C:\Python27\Lib\site-packages”。如图所示:

20430.jpg

OK,这个时候已经算是安装完毕了。通过cmd控制台,我们可以尝试一下运行openCV自带的一些python写的example。这些example在“opencv\sources\samples\python”下面可以看到。

输出一个彩色图像的直方图:import cv2import numpy as npfrom matplotlib import pyplot as plt

img = cv2.imread('/home/aobo/Pictures/IMG_4137.JPG')color = ('b','g','r')# enumerate():python里的一个新函数

# 它的作用:同时遍历索引(i)和元素(col)for i,col in enumerate(color):

histr = cv2.calcHist([img], [i], None, [256], [0, 256])

plt.plot(histr, color = col)

plt.xlim([0, 256])plt.show()

关于python配置opencv的方法就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Computer vision is found everywhere in modern technology. OpenCV for Python enables us to run computer vision algorithms in real time. With the advent of powerful machines, we are getting more processing power to work with. Using this technology, we can seamlessly integrate our computer vision applications into the cloud. Web developers can develop complex applications without having to reinvent the wheel. This book is a practical tutorial that covers various examples at different levels, teaching you about the different functions of OpenCV and their actual implementations. Who this book is for This book is intended for Python developers who are new to OpenCV and want to develop computer vision applications with OpenCV and Python. This book is also useful for generic software developers who want to deploy computer vision applications on the cloud. It would be helpful to have some familiarity with basic mathematical concepts such as vectors and matrices. What this book covers Chapter 1, Applying Geometric Transformations to Images, explains how to apply geometric transformations to images. In this chapter, we will discuss affine and projective transformations and see how we can use them to apply cool geometric effects to photos. The chapter will begin with the procedure of installing OpenCV-Python on multiple platforms, such as Mac OS X, Linux, and Windows. You will also learn how to manipulate an image in various ways, such as resizing and changing color spaces. Chapter 2, Detecting Edges and Applying Image Filters, shows how to use fundamental image- processing operators and how we can use them to build bigger projects. We will discuss why we need edge detection and how it can be used in various different ways in computer vision applications. We will discuss image filtering and how we can use it to apply various visual effects to photos. Chapter 3, Cartoonizing an Image, shows how to cartoonize a given image using image filters and other transformations. We will see how to use the webcam to capture a live video stream. We will discuss how to build a real-time application, where we extract information from each frame in the stream and display the result. Preface Chapter 4, Detecting and Tracking Different Body Parts, shows how to detect and track faces in a live video stream. We will discuss the face detection pipeline and see how we can use it to detect and track different parts of the face, such as eyes, ears, mouth, and nose. Chapter 5, Extracting Features from an Image, is about detecting the salient points (called keypoints) in an image. We will discuss why these salient points are important and how we can use them to understand the image's content. We will talk about the different techniques that can be used to detect salient points and extract features from an image. Chapter 6, Seam Carving, shows how to do content-aware image resizing. We will discuss how to detect interesting parts of an image and see how we can resize a given image without deteriorating those interesting parts. Chapter 8, Detecting Shapes and Segmenting an Image, shows how to perform image segmentation. We will discuss how to partition a given image into its constituent parts in the best possible way. You will also learn how to separate the foreground from the background in an image. Chapter 8, Object Tracking, shows you how to track different objects in a live video stream. At the end of this chapter, you will be able to track any object in a live video stream that is captured through the webcam. Chapter 9, Object Recognition, shows how to build an object recognition system. We will discuss how to use this knowledge to build a visual search engine. Chapter 10, Augmented Reality, shows how to build an augmented reality application. By the end of this chapter, you will be able to build a fun augmented reality project using the webcam. Chapter 11, Machine Learning by Artificial Neural Network, shows how to build advanced image classifiers and object recognition using the latest OpenCV implementations. By the end of this chapter, you will be able to understand how neural networks work and how to apply them to machine learning to build advance images tools.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值