openCV使用说明
- 格式:pdf
- 大小:878.83 KB
- 文档页数:9
opencv4函数手册
OpenCV(Open Source Computer Vision Library)是一个开源的计算机视觉库,提供了丰富的图像处理和计算机视觉算法。
它支
持多种编程语言,包括C++、Python等,并且可以在多个操作系统
上运行。
关于OpenCV 4的函数手册,它包含了OpenCV库中各个函数的
详细说明和用法。
这些函数涵盖了图像处理、特征提取、物体识别、摄像机标定、图像变换等多个领域。
在OpenCV 4函数手册中,你可以找到以下内容:
1. 函数概述,对OpenCV库中的各个函数进行分类和概述,方
便用户快速了解函数的用途和功能。
2. 函数参数,详细说明每个函数的参数列表,包括输入参数、
输出参数和可选参数。
这些参数描述了函数的输入和输出数据类型、大小、格式等信息。
3. 函数返回值,说明函数的返回值类型和含义,帮助用户理解
函数的执行结果。
4. 函数示例,提供函数的使用示例代码,展示如何调用函数以及函数的具体用法。
示例代码通常包含了图像加载、处理、保存等步骤,帮助用户更好地理解函数的实际应用。
5. 相关函数,介绍与当前函数相关的其他函数,帮助用户了解函数之间的关联和依赖关系。
6. 注意事项,列出函数的一些注意事项和限制,帮助用户正确使用函数并避免常见错误。
通过OpenCV 4函数手册,你可以学习和了解OpenCV库中各个函数的功能和用法,从而在图像处理和计算机视觉任务中更加高效地使用OpenCV。
你可以通过OpenCV官方网站或者在线文档获取OpenCV 4函数手册的详细内容。
opencv repeat 花式用法-概述说明以及解释1.引言1.1 概述概述OpenCV(开源计算机视觉库)是一个广泛使用的计算机视觉库,提供了丰富的图像处理和计算机视觉算法。
其中,repeat函数是OpenCV 中一个非常有用的函数,可以用于将图像或数组在水平和垂直方向上进行复制扩展。
本文将重点介绍opencv repeat的花式用法。
在第二部分中,我们将讨论repeat函数的基本用法,包括如何使用该函数复制图像或数组,并设置复制的次数。
然后,我们将进一步探讨repeat函数的高级用法,例如如何在复制过程中对图像或数组进行变换和操作。
最后,我们将介绍repeat函数的创新用法,包括如何利用它来生成特殊效果的图像、创建图像平铺效果等。
通过学习这些花式用法,我们可以充分发挥repeat函数在图像处理和计算机视觉领域的潜力。
它能够帮助我们快速生成多样化的图像效果,提高图像处理和计算机视觉算法的效率和准确性。
本文的目的是通过详细介绍repeat函数的多种用法,帮助读者更好地理解和掌握这个强大的函数,为他们在实际项目中的图像处理和计算机视觉任务提供有力的支持。
在下一节中,我们将首先介绍repeat函数的基本用法,以便读者对其有一个初步的了解。
接下来,我们将深入探讨repeat函数的高级用法和创新用法。
最后,在结论部分,我们将总结opnecv repeat的多样化用法,并展望其未来发展的方向。
让我们开始我们的旅程吧!1.2 文章结构文章结构文章的结构具体分为引言、正文和结论三个部分。
引言部分主要会介绍本文要讨论的主题以及文章的背景和意义。
首先,我们会简要概述一下本文要讨论的主题,即opencv repeat的花式用法。
随后,我们会介绍一下整篇文章的结构,即各个部分的内容和组织方式。
最后,我们还会明确本文的目的,即希望通过本文的内容让读者了解并掌握opencv repeat的多样化用法。
正文部分是文章的核心部分,主要介绍opencv repeat的基本用法、高级用法和创新用法。
Python中的OpenCV是一个强大的计算机视觉库,而imshow函数则是OpenCV中用于显示图像的重要函数之一。
本文将从imshow函数的基本用法、参数说明、常见问题及解决方法等方面进行详细介绍,希望能够帮助读者更好地理解和使用这一函数。
1. imshow函数的基本用法在使用imshow函数之前,首先需要导入OpenCV库,并加载需要显示的图像。
加载图像的代码通常为:```pythonimport cv2image = cv2.imread('image.jpg')```加载完成图像后,就可以使用imshow函数显示图像了。
imshow函数的基本用法如下:```pythoncv2.imshow('image', image)cv2.waitKey(0)cv2.destroyAllWindows()```其中,'image'是窗口的名称,可以自定义。
image是需要显示的图像。
cv2.waitKey(0)是一个键盘绑定函数,参数为0表示无限等待用户的键盘输入。
cv2.destroyAllWindows()可以用来关闭所有的窗口。
通过以上代码,就可以在屏幕上显示加载的图像了。
2. imshow函数的参数说明imshow函数有两个参数,第一个参数是窗口的名称,第二个参数是需要显示的图像。
在使用imshow函数时,还可以使用一些附加参数进行进一步的设置,如调整窗口的大小、窗口的位置等。
具体的参数说明可以参考OpenCV官方文档。
3. 常见问题及解决方法在使用imshow函数时,可能会遇到一些常见的问题,下面罗列了一些常见问题及对应的解决方法:1) 图像无法显示:这个问题通常是由于图像路径错误或图像加载失败所致。
可以通过检查图像路径是否正确、确认图像是否加载成功来解决。
2) 窗口无响应:有时候在显示图像的窗口中会出现无响应的情况,这可能是因为程序在等待键盘输入而导致的。
About the T utorialOpenCV is a cross-platform library using which we can develop real-time computer vision applications. It mainly focuses on image processing, video capture and analysis including features like face detection and object detection. In this tutorial, we explain how you can use OpenCV in your applications.AudienceThis tutorial has been prepared for beginners to make them understand the basics of OpenCV library. We have used the Java programming language in all the examples, therefore you should have a basic exposure to Java in order to benefit from this tutorial. PrerequisitesFor this tutorial, it is assumed that the readers have a prior knowledge of Java programming language. In some of the programs of this tutorial, we have used JavaFX for GUI purpose. So, it is recommended that you go through our JavaFX tutorial before proceeding further - /javafx/.Copyright & Disclaimer© Copyright 2017 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher.We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at **************************T able of ContentsAbout the Tutorial (1)Audience (1)Prerequisites (1)Copyright & Disclaimer (1)Table of Contents (2)1.OpenCV – Overview (5)Computer Vision (5)Applications of Computer Vision (5)Features of OpenCV Library (6)OpenCV Library Modules (7)A Brief History of OpenCV (8)2.OpenCV – Environment (9)Installing OpenCV (9)Eclipse Installation (11)Setting the Path for Native Libraries (18)3.OpenCV — Storing Images (21)The Mat Class (21)Creating and Displaying the Matrix (23)Loading Image using JavaSE API (25)4.OpenCV – Reading Images (27)5.OpenCV ─ Writing an Image (29)6.OpenCV— GUI (31)Converting Mat to Buffered Image (31)Displaying Image using AWT/Swings (32)Displaying Image using JavaFX (34)TYPES OF IMAGES (38)7.OpenCV — The IMREAD_XXX Flag (39)8.OpenCV ─ Reading an Image as Grayscale (41)9.OpenCV ─ Reading Image as BGR (45)IMAGE CONVERSION (49)10.OpenCV ─ Colored Images to GrayScale (50)11.OpenCV ─ Colored Image to Binary (54)12.OpenCV ─ Grayscale to Binary (58)DRAWING FUNCTIONS (62)13.OpenCV – Drawing a Circle (63)14.OpenCV – Drawing a Line (67)15.OpenCV ─ Drawing a Rectangle (71)16.OpenCV – Drawing an Ellipse (75)17.OpenCV – Drawing Polylines (79)18.OpenCV – Drawing Convex Polylines (84)19.OpenCV—Drawing Arrowed Lines (88)20.OpenCV – Adding Text (92)BLUR OPERATIONS (96)21.OpenCV – Blur (Averaging) (97)22.OpenCV – Gaussian Blur (100)23.OpenCV – Median Blur (103)FILTERING (106)24.OpenCV – Bilateral Filter (107)25.OpenCV – Box Filter (110)26.OpenCV – SQRBox Filter (113)27.OpenCV – Filter2D (116)28.OpenCV—Dilation (119)29.OpenCV – Erosion (122)30.OpenCV ─ Morphological Operations (125)31.OpenCV ─ Image Pyramids (131)Pyramid Up (131)Pyramid Down (133)Mean Shift Filtering (136)THRESHOLDING (139)32.OpenCV – Simple Threshold (140)33.OpenCV – Adaptive Threshold (144)Other Types of Adaptive Thresholding (147)34.OpenCV ─ Adding Borders (148)SOBEL DERIVATIVES (153)35.OpenCV – Sobel Operator (154)36.OpenCV – Scharr Operator (157)More Scharr Derivatives (159)TRANSFORMATION OPERATIONS (160)37.OpenCV – Laplacian Transformation (161)38.OpenCV – Distance Transformation (164)CAMERA & FACE DETECTION (169)39.OpenCV – Using Camera (170)40.OpenCV ─ Face Detection in a Picture (175)41.OpenCV ─ Face Detection using Camera (179)GEOMETRIC TRANSFORMATIONS (184)42.OpenCV ─ Affine Translation (185)43.OpenCV – Rotation (188)44.OpenCV – Scaling (191)45.OpenCV – Color Maps (194)MISCELLANEOUS CONCEPTS (202)46.OpenCV – Canny Edge Detection (203)47.OpenCV – Hough Line Transform (206)48.OpenCV – Histogram Equalization (210)1.OpenCVOpenCV is a cross-platform library using which we can develop real-time computer vision applications. It mainly focuses on image processing, video capture and analysis including features like face detection and object detection.Let’s start the chapter by defining the term "Computer Vision".Computer VisionComputer Vision can be defined as a discipline that explains how to reconstruct, interrupt, and understand a 3D scene from its 2D images, in terms of the properties of the structure present in the scene. It deals with modeling and replicating human vision using computer software and hardware.Computer Vision overlaps significantly with the following fields:∙Image Processing: It focuses on image manipulation.∙Pattern Recognition: It explains various techniques to classify patterns.∙Photogrammetry:It is concerned with obtaining accurate measurements from images.Computer Vision Vs Image ProcessingImage processing deals with image-to-image transformation. The input and output of image processing are both images.Computer vision is the construction of explicit, meaningful descriptions of physical objects from their image. The output of computer vision is a description or an interpretation of structures in 3D scene.Applications of Computer VisionHere we have listed down some of major domains where Computer Vision is heavily used. Robotics Application∙Localization ─ Determine robot location automatically∙Navigation∙Obstacles avoidance∙Assembly (peg-in-hole, welding, painting)∙Manipulation (e.g. PUMA robot manipulator)∙Human Robot Interaction (HRI): Intelligent robotics to interact with and serve peopleMedicine Application∙Classification and detection (e.g. lesion or cells classification and tumor detection)∙2D/3D segmentation∙3D human organ reconstruction (MRI or ultrasound)∙Vision-guided robotics surgeryIndustrial Automation Application∙Industrial inspection (defect detection)∙Assembly∙Barcode and package label reading∙Object sorting∙Document understanding (e.g. OCR)Security Application∙Biometrics (iris, finger print, face recognition)∙Surveillance ─ Detecting certain suspicious activities or behaviorsTransportation Application∙Autonomous vehicle∙Safety, e.g., driver vigilance monitoringFeatures of OpenCV LibraryUsing OpenCV library, you can –∙Read and write images∙Capture and save videos∙Process images (filter, transform)∙Perform feature detection∙Detect specific objects such as faces, eyes, cars, in the videos or images.∙Analyze the video, i.e., estimate the motion in it, subtract the background, and track objects in it.OpenCV was originally developed in C++. In addition to it, Python and Java bindings were provided. OpenCV runs on various Operating Systems such as windows, Linux, OSx, FreeBSD, Net BSD, Open BSD, etc.This tutorial explains the concepts of OpenCV with examples using Java bindings.OpenCV Library ModulesFollowing are the main library modules of the OpenCV library.Core FunctionalityThis module covers the basic data structures such as Scalar, Point, Range, etc., that are used to build OpenCV applications. In addition to these, it also includes the multidimensional array Mat, which is used to store the images. In the Java library of OpenCV, this module is included as a package with the name org.opencv.core.Image ProcessingThis module covers various image processing operations such as image filtering, geometrical image transformations, color space conversion, histograms, etc. In the Java library of OpenCV, this module is included as a package with the name org.opencv.imgproc.VideoThis module covers the video analysis concepts such as motion estimation, background subtraction, and object tracking. In the Java library of OpenCV, this module is included as a package with the name org.opencv.video.Video I/OThis module explains the video capturing and video codecs using OpenCV library. In the Java library of OpenCV, this module is included as a package with the name org.opencv.videoio.calib3dThis module includes algorithms regarding basic multiple-view geometry algorithms, single and stereo camera calibration, object pose estimation, stereo correspondence and elements of 3D reconstruction. In the Java library of OpenCV, this module is included as a package with the name org.opencv.calib3d.features2dThis module includes the concepts of feature detection and description. In the Java library of OpenCV, this module is included as a package with the name org.opencv.features2d. ObjdetectThis module includes the detection of objects and instances of the predefined classes such as faces, eyes, mugs, people, cars, etc. In the Java library of OpenCV, this module is included as a package with the name org.opencv.objdetect.HighguiThis is an easy-to-use interface with simple UI capabilities. In the Java library of OpenCV, the features of this module is included in two different packages namely, org.opencv.imgcodecs and org.opencv.videoio.A Brief History of OpenCVOpenCV was initially an Intel research initiative to advise CPU-intensive applications. It was officially launched in 1999.∙In the year 2006, its first major version, OpenCV 1.0 was released.∙In October 2009, the second major version, OpenCV 2 was released.∙In August 2012, OpenCV was taken by a nonprofit organization .OpenCV In this chapter, you will learn how to install OpenCV and set up its environment in your system.First of all, you need to download OpenCV onto your system. Follow the steps given below. Step 1: Open the homepage of OpenCV by clicking the following link: / On clicking, you will see its homepage as shown below.2.Step 2: Now, click the Downloads link highlighted in the above screenshot. On clicking, you will be directed to the downloads page of OpenCV.Step 3: On clicking the highlighted link in the above screenshot, a file named opencv-3.1.0.exe will be downloaded. Extract this file to generate a folder opencv in your system, as shown in the following screenshot.Step 4:Open the folder OpenCV-> build ->java. Here you will find the jar file of OpenCV named opencv-310.jar. Save this file in a separate folder for further use.Eclipse InstallationAfter downloading the required JAR files, you have to embed these JAR files to your Eclipse environment. You can do this by setting the Build Path to these JAR files and by using pom.xml.Setting Build PathFollowing are the steps to set up OpenCV in Eclipse:Step 1: Ensure that you have installed Eclipse in your system. If not, download and install Eclipse in your system.Step 2: Open Eclipse, click on File, New, and Open a new project as shown in the following screenshot.Step 3: On selecting the project, you will get the New Project wizard. In this wizard, select Java project and proceed by clicking the Next button, as shown in the following screenshot.Step 4: On proceeding forward, you will be directed to the New Java Project wizard. Create a new project and click Next, as shown in the following screenshot.Step 5:After creating a new project, right-click on it. Select Build Path and click Configure Build Path… as shown in the following screenshot.Step 6: On clicking the Build Path option,you will be directed to the Java Build Path wizard.Click the Add External JARs button,as shown in the following screenshot.Step 7: Select the path where you have saved the file opencv-310.jar.Step 8: On clicking the Open button in the above screenshot, those files will be added to your library.Step 9: On clicking OK, you will successfully add the required JAR files to the current project and you can verify these added libraries by expanding the Referenced Libraries.Setting the Path for Native LibrariesIn addition to the JAR files, you need to set path for the native libraries (DLL files) of OpenCV.Location of DLL files: Open the installation folder of OpenCV and go to the sub-folder build -> java. Here you will find the two folders x64 (64 bit) and x86 (32 bit) which contain the dll files of OpenCV.Open the respective folder suitable for your operating system, then you can see the dll file, as shown in the following screenshot.Now, set the path for this file too by following the steps given below—Step 1: Once again, open the JavaBuildPath window. Here you can observe the added JAR file and the JRE System Library.Step 2: On expanding it, you will get the system libraries and Native library location, as highlighted in the following screenshot.OpenCV Step 3:Double-click on the Native library location. Here, you can see the Native Library Folder Configuration window as shown below—Here, click the button External Folder…and select the location of the dll file in your system.3.OpenCVTo capture an image, we use devices like cameras and scanners. These devices record numerical values of the image (Ex: pixel values). OpenCV is a library which processes the digital images, therefore we need to store these images for processing.The Mat class of OpenCV library is used to store the values of an image. It represents an n-dimensional array and is used to store image data of grayscale or color images, voxel volumes, vector fields, point clouds, tensors, histograms, etc.This class comprises of two data parts: the header and a pointer∙Header: Contains information like size, method used for storing, and the address of the matrix (constant in size).∙Pointer: Stores the pixel values of the image (Keeps on varying).The Mat ClassThe OpenCV Java library provides this class with the same name (Mat) within the package org.opencv.core.ConstructorsThe Mat class of OpenCV Java library has various constructors, using which you can construct the Mat object.Note:∙Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.∙The type of the matrices were represented by various fields of the class CvType which belongs to the package org.opencv.core.Methods and DescriptionFollowing are some of the methods provided by the Mat class.In this section, we are going to discuss our first OpenCV example. We will see how to create and display a simple OpenCV matrix.Given below are the steps to be followed to create and display a matrix in OpenCV.Step 1: Load the OpenCV native libraryWhile writing Java code using OpenCV library, the first step you need to do is to load the native library of OpenCV using the loadLibrary(). Load the OpenCV native library as shown below.Step 2: Instantiate the Mat classInstantiate the Mat class using any of the functions mentioned in this chapter earlier.Step 3: Fill the matrix using the methodsYou can retrieve particular rows/columns of a matrix by passing index values to the methods row()/col().And, you can set values to these using any of the variants of the setTo() methods.ExampleYou can use the following program code to create and display a simple matrix in Java using OpenCV library.On executing the above program, you will get the following output.Loading Image using JavaSE APIThe BufferedImage class of the java.awt.image.BufferedImage package is used to store an image and the ImageIO class of the package import javax.imageio provides methods to read and write Images.ExampleYou can use the following program code to load and save images using JavaSE library.On executing the above program, you will get the following output.If you open the specified path, you can observe the saved image as follows—End of ebook previewIf you liked what you saw…Buy it from our store @ https://。
opencv mat 向量转mat矩阵-概述说明以及解释1.引言1.1 概述在撰写这篇长文之前,我们首先来了解一下概述部分的内容。
本文旨在介绍如何使用OpenCV实现将向量转化为Mat矩阵的方法。
在计算机视觉和图像处理中,OpenCV是一个广泛应用的开源库。
它提供了一系列图像处理和计算机视觉的功能,其中包括矩阵的操作和转换。
而Mat是OpenCV中用于表示多维数组的矩阵类。
本文主要讨论的问题是,当我们需要将一个向量(例如一维数组)转化为一个Mat矩阵时,我们应该如何进行操作。
这个问题在很多图像处理和机器学习算法中都是常见的操作。
通过本文的介绍,读者将了解到OpenCV中的Mat矩阵的基本知识以及如何使用OpenCV中的函数来进行向量到Mat矩阵的转换。
我们将详细讨论OpenCV中相关的函数和方法,并给出一些实际代码示例来帮助读者更好地理解。
除了介绍向量到Mat矩阵的转换方法外,本文还将讨论一些在这个过程中可能遇到的常见问题以及相应的解决方案。
通过这些内容的学习和实践,读者可以掌握将向量转化为Mat矩阵的基本技巧,并能够灵活应用于自己的实际项目中。
总之,本文将以OpenCV为基础,详细介绍如何将向量转化为Mat 矩阵的方法和技巧,并帮助读者理解相关的原理和操作。
通过阅读本文,读者将能够更好地应用OpenCV进行图像处理和计算机视觉的相关工作。
1.2文章结构文章结构部分的内容可以编写如下:在本篇文章中,将通过以下几个部分来详细介绍opencv中mat向量转mat矩阵的原理及相关操作方法。
第一部分是引言,将对本文的概述进行说明。
首先介绍mat向量和mat矩阵在计算机视觉中的应用和重要性,以及为什么需要进行向量转矩阵的操作。
随后,本文将简要阐述文章的整体结构,以及各个部分所涵盖的内容。
最后,明确本文的目的,即通过深入了解mat向量转mat矩阵的原理和操作方法,帮助读者更好地掌握和应用这一技术。
第二部分是正文,将重点介绍opencv中mat向量转mat矩阵的原理和方法。
Java+OpenCV3.0的配置和使用说明1、第一步,下载OpenCV3.0.0,下载地址为:/projects/opencvlibrary/files/opencv-win/3.0.0/opencv-3.0.0.exe/down load/releases.htmlJava相对OpenCV的技术文档:/java/3.0.0/下载完毕之后,双击文件,解压到:C:\OpenCV3.0,解压完毕之后,这时我们看到下图目录(C:\OpenCV3.0\opencv\build\java)中,有个.jar包,这个包就是我们需要的Java OpenCV库。
(注意可以现在C盘创建一个文件夹:OpenCV3.0)2、第二步,下载Eclipse/3、第三步,打开eclipse,并找到Window –> Preferences,按照如下操作轨迹:4、第四步:点击右侧的Add External JARs,找到.jar包的位置,本人电脑是:C:\OpenCV3.0\opencv\build\java点击上图中的打开,然后可以看到下面的图片。
选择Native library location,点击右侧的Edit 按钮,对其进行编辑点击External Folder...选择目录到:C:\OpenCV3.0\opencv\build\java\x64,然后点击ok,如果你使用的32位系统则选择x86文件夹,如下图所示配置完成,应该是这样的好了,上面的配置完成了,现在我们写2个简单的例子来测试一下。
实验一Java+OpenCV实现图片显示1、第一步,打开eclipse创建一个叫Image的工程。
2、然后在项目上右键,BuildPath ---->ConfigureBuildPath ,点击Libraries选项卡,点击下面的Add Library,弹出来的对话框中选择“UserLibrary”。
点击next,勾选OpenCV3.0,点击完成。
captureProperty是OpenCV 中的一个函数,用于获取视频捕获对象的属性值。
这个函数主要用于获取视频文件的帧率、像素格式、宽度和高度等参数。
下面是captureProperty函数的基本语法:int captureProperty(int propId)参数propId指定要获取的属性,可以是以下值之一:cv::CAP_PROP_POS_FRAMES: 视频的当前帧号。
cv::CAP_PROP_POS_AVI_RATIO: 视频的当前播放位置(相对于视频总长度的比例)。
cv::CAP_PROP_FRAME_WIDTH: 视频帧的宽度。
cv::CAP_PROP_FRAME_HEIGHT: 视频帧的高度。
cv::CAP_PROP_FPS: 视频的帧率。
cv::CAP_PROP_FOURCC: 视频的像素格式(使用四个字符的代码表示)。
cv::CAP_PROP_FRAME_COUNT: 视频的总帧数。
cv::CAP_PROP_FORMAT: 视频的像素格式。
cv::CAP_PROP_MODE: 视频捕获模式(例如,连续或单帧模式)。
cv::CAP_PROP_BRIGHTNESS: 摄像头的亮度设置。
cv::CAP_PROP_CONTRAST: 摄像头的对比度设置。
cv::CAP_PROP_SATURATION: 摄像头的饱和度设置。
cv::CAP_PROP_HUE: 摄像头的色调设置。
cv::CAP_PROP_GAIN: 摄像头的增益设置。
cv::CAP_PROP_EXPOSURE: 摄像头的曝光设置。
cv::CAP_PROP_CONVERT_RGB: 是否将图像从BGR 转换为RGB。
cv::CAP_PROP_WHITE_BALANCE: 白平衡设置。
cv::CAP_PROP_TEMPERATURE: 摄像头的温度设置。
cv::CAP_PROP_BACKLIGHT: 后照式摄像头的后照式优化设置。
opencv方差计算OpenCV方差计算一、引言方差是统计学中常用的概念,用于衡量数据的离散程度。
在计算机视觉领域中,方差也是一项重要的指标。
OpenCV作为一个强大的计算机视觉库,提供了方差计算的函数,方便我们在图像处理和分析中应用。
二、方差的定义方差是描述数据分散程度的指标,即数据与其均值之间的差异程度。
在数学上,方差的计算公式为每个数据与均值的差的平方的平均值。
三、OpenCV中的方差计算函数OpenCV提供了函数cv::meanStdDev()来计算图像或矩阵的方差。
该函数可以计算图像的均值和标准差,通过标准差的平方即可得到方差。
四、方差计算的步骤1. 加载图像或创建矩阵在进行方差计算之前,需要加载图像或创建一个矩阵作为输入数据。
2. 计算均值和标准差使用cv::meanStdDev()函数,传入输入数据和输出参数,即可计算得到图像的均值和标准差。
3. 计算方差通过标准差的平方即可得到图像的方差。
五、示例代码下面是一个简单的示例代码,演示了如何使用OpenCV计算图像的方差:```cpp#include <opencv2/opencv.hpp>#include <iostream>using namespace cv;using namespace std;int main(){Mat image = imread("image.jpg", IMREAD_GRAYSCALE);if (image.empty()){cout << "Failed to load image!" << endl;return -1;}Scalar mean, stddev;meanStdDev(image, mean, stddev);double variance = pow(stddev.val[0], 2);cout << "Variance: " << variance << endl;return 0;}```六、方差计算的应用方差在图像处理和分析中有着广泛的应用。
OPENCV库函数使用说明
一、cv::Mat类介绍
cv::Mat类是OpenCV中最核心的基本数据结构,抽象代表一个n维矩阵,矩阵元素的矩阵可以是单通道浮点数,向量,多通道,可以是无符号字节,单精度浮点数以及双精度浮点数,并且支持多通道数据。
Mat类通过长度和宽度确定矩阵的大小,通过depth(函数可以得到它的深度,深度表示分量的类型。
Mat矩阵分为三种:关键的类型,普通的类型,宽字节类型,关键类型是由C++11语言提供的,主要用于简化mat 和其他类型的交互,它的性能比普通类型更好,但不支持所有类型;普通类型可以实现所有的功能,但是性能比关键类型要差;宽字节类型是在普通类型的基础上,支持访问1(uchar),2(ushort),4(uint)个字节长度的数据,它的性能比普通类型好。
二、cv::Mat函数使用
1.Mat类结构函数
一般来说,Mat类的结构函数主要有两种,分别是Mat()和Mat ({}),当我们只想创建一个空的Mat类时,可以使用Mat(),当想要创建一个8位单通道矩阵时,可以使用Mat({})。
2.Mat常用成员函数
(1)ptr():返回一个指向矩阵数据的指针;
(2)row():返回行数;
(3)cols():返回列数;。
目录1引言 (1)2 OpenCV的结构 (1)3 VC 6下的安装与配置 (2)3.1安装OpenCV(略) (2)3.2 配置Windows环境变量 (2)4 VC++的环境设置 (4)5如何创建一个项目来开始OpenCV 编程 (5)6如何读入和显示图像 (7)7如何访问图像像素 (10)8如何访问矩阵元素 (11)9如何在OpenCV 中处理我自己的数据 (12)10. 例程 (13)10.1 Kalman滤波进行旋转点的跟踪 (13)10.2 背景建模 (16)10.3 视频I/O (21)10.4 矩阵操作 (23)10.5 轮廓检测 (27)1引言OpenCV(Intel® Open Source Computer Vision Library) 是Intel 公司面向应用程序开发者开发的计算机视觉库,其中包含大量的函数用来处理计算机视觉领域中常见的问题,例如运动分析和跟踪、人脸识别、3D 重建和目标识别等。
目前该函数库的最新版本是OpenCV 4.0,可以通过访问/projects/opencvlibrary免费获得OpenCV 库以及相关的资料。
另外,还可以通过访问/group/OpenCV,对于OpenCV使用中的一些问题与经验进行讨论。
相对于其它图像函数库,OpenCV是一种源码开放式的函数库,开发者可以自由地调用函数库中的相关处理函数。
OpenCV中包含500多个处理函数,具备强大的图像和矩阵运算能力,可以大大减少开发者的编程工作量,有效提高开发效率和程序运行的可靠性。
另外,由于OpenCV具有很好的移植性,开发者可以根据需要在MS-Windows和Linux两种平台进行开发,速度快,使用方便。
2 OpenCV的结构目前OpenCV包含如下几个部分:Cxcore: 一些基本函数(各种数据类型的基本运算等)Cv: 图像处理和计算机视觉功能(图像处理,结构分析,运动分析,物体跟踪,模式识别,摄像定标)Highgui: 用户交互部分(GUI, 图像视频I/O, 系统调用函数)Cvaux: 一些实验性的函数(ViewMorphing, 三维跟踪,PCA,HMM)另外还有cvcam, 不过linux版本中已经抛弃。
opencv drawline函数的用法OpenCV中的`drawLine()`函数用于在图像上绘制一条直线。
函数声明如下:```cppvoid cv::line(InputOutputArray img, //输入图像,可以是灰度图像或彩色图像Point pt1, //直线的起始点Point pt2, //直线的终止点const Scalar& color, //直线的颜色,可以是BGR格式或灰度值int thickness = 1, //直线的粗细,默认为1int lineType = LINE_8, //直线的类型,默认为8-connected int shift = 0 //坐标点的小数位数,默认为0);```参数说明:- `img`:输入图像。
可以是灰度图像(单通道)或彩色图像(3通道)。
- `pt1`:直线的起始点,使用`Point`类表示,可以通过坐标`(x, y)`来初始化。
- `pt2`:直线的终止点,同样使用`Point`类表示。
- `color`:直线的颜色。
可以是BGR格式的值,例如`Scalar(255, 0, 0)`表示蓝色直线;也可以是灰度值,例如`Scalar(255)`表示白色直线。
- `thickness`:直线的粗细,默认为1。
- `lineType`:直线的类型,默认为8-connected。
可以选择`LINE_4`(4-connected)或`LINE_8`(8-connected)。
- `shift`:坐标点的小数位数,默认为0。
例子:```cppcv::Mat image(400, 600, CV_8UC3, cv::Scalar(0, 0, 0)); //创建一张黑色图像cv::Point pt1(100, 100); //直线的起始点cv::Point pt2(500, 300); //直线的终止点cv::Scalar color(0, 0, 255); //直线的颜色为红色cv::line(image, pt1, pt2, color, 2, cv::LINE_AA); //在图像上绘制直线cv::imshow("Image", image);cv::waitKey(0);cv::destroyAllWindows();```上述例子中,我们创建了一张宽度为600,高度为400,通道数为3的黑色图像。
opencv4应用开发- 入门、进阶与工程化实践概述及解释说明1. 引言1.1 概述在计算机视觉领域,OpenCV是一个非常强大的开放源码库,提供了一系列用于处理图像和视频的函数。
随着计算机视觉技术的快速发展,在各个领域中广泛应用,对OpenCV的需求也越来越大。
本文主要介绍了Opencv4应用开发的入门、进阶与工程化实践。
1.2 文章结构本文分为五个部分:引言、Opencv4应用开发入门、Opencv4应用开发进阶、Opencv4应用开发工程化实践以及结论。
通过这些部分,读者将逐步了解Opencv4应用开发的基础知识,深入理解图像处理技术,并学习如何优化和加速图像处理算法,以及如何部署Opencv应用到嵌入式平台。
1.3 目的本文旨在向读者介绍Opencv4应用开发的基础知识和技巧,并通过示例代码和说明,帮助读者理解和掌握相关概念和方法。
同时,本文还将讨论未来Opencv 应用开发可能面临的挑战和趋势,为读者提供一个全面认识该领域并深入学习的基础。
无论是初学者还是具有一定经验的开发者,本文都将为他们提供有价值的指导和建议。
完成该篇文章后,读者将能够理解Opencv4应用开发所需的基础知识,并能够在实际项目中灵活运用这些知识。
2. Opencv4应用开发入门:2.1 Opencv简介:Opencv(Open Source Computer Vision Library)是一个开源的计算机视觉库,提供了丰富的图像处理和计算机视觉算法。
它支持多种编程语言,如C++、Python等,并可在多个操作系统上运行。
Opencv被广泛应用于图像处理、目标检测与跟踪、人脸识别、机器学习等领域。
2.2 安装和配置Opencv环境:在开始使用Opencv进行应用开发前,首先需要安装和配置Opencv环境。
可以从官方网站下载适合自己的版本,并根据相应的安装指南进行安装步骤。
一般而言,安装包会包含一些基本的例子和示范代码,供用户学习和参考。
∙Open Source Computer Vision Library ∙∙ 论坛 ∙ 商业 ∙ 专题 ∙ 讲座 ∙ 例程 ∙ 安装 ∙ 常见问题 ∙ 函数说明Cv 图像处理Wikipedia ,自由的百科全书注意:本章描述图像处理和分析的一些函数。
大多数函数都是针对两维象素数组的,这里,我们称这些数组为“图像”,但是它们不一定非得是IplImage 结构,也可以是CvMat 或者CvMatND 结构。
目录[隐藏]∙ 1 梯度、边缘和角点o 1.1 Sobelo 1.2 Laplaceo 1.3 Cannyo 1.4 PreCornerDetecto 1.5 CornerEigenValsAndVecso 1.6 CornerMinEigenValo 1.7 CornerHarriso 1.8 FindCornerSubPixo 1.9 GoodFeaturesToTrack∙ 2 采样、插值和几何变换o 2.1 InitLineIteratoro 2.2 SampleLineo 2.3 GetRectSubPixo 2.4 GetQuadrangleSubPixo 2.5 Resizeo 2.6 WarpAffineo 2.7 GetAffineTransformo 2.8 2DRotationMatrixo 2.9 WarpPerspectiveo 2.10 WarpPerspectiveQMatrixo 2.11 GetPerspectiveTransformo 2.12 Remapo 2.13 LogPolar∙ 3 形态学操作o 3.1 CreateStructuringElementExo 3.2 ReleaseStructuringElemento 3.3 Erodeo 3.4 Dilateo 3.5 MorphologyEx∙ 4 滤波器与色彩空间变换o 4.1 Smootho 4.2 Filter2Do 4.3 CopyMakeBordero 4.4 Integralo 4.5 CvtColoro 4.6 Thresholdo 4.7 AdaptiveThreshold∙ 5 金字塔及其应用o 5.1 PyrDowno 5.2 PyrUp∙ 6 连接部件o 6.1 CvConnectedCompo 6.2 FloodFillo 6.3 FindContourso 6.4 StartFindContourso 6.5 FindNextContouro 6.6 SubstituteContouro 6.7 EndFindContourso 6.8 PyrSegmentationo 6.9 PyrMeanShiftFilteringo 6.10 Watershed∙7 图像与轮廓矩o7.1 Momentso7.2 GetSpatialMomento7.3 GetCentralMomento7.4 GetNormalizedCentralMomento7.5 GetHuMoments∙8 特殊图像变换o8.1 HoughLineso8.2 HoughCircleso8.3 DistTransformo8.4 Inpaint∙9 直方图o9.1 CvHistogramo9.2 CreateHisto9.3 SetHistBinRangeso9.4 ReleaseHisto9.5 ClearHisto9.6 MakeHistHeaderForArrayo9.7 QueryHistValue_1Do9.8 GetHistValue_1Do9.9 GetMinMaxHistValueo9.10 NormalizeHisto9.11 ThreshHisto9.12 CompareHisto9.13 CopyHisto9.14 CalcHisto9.15 CalcBackProjecto9.16 CalcBackProjectPatcho9.17 CalcProbDensityo9.18 EqualizeHist∙10 匹配o10.1 MatchTemplateo10.2 MatchShapeso10.3 CalcEMD2[编辑]梯度、边缘和角点[编辑]Sobel使用扩展 Sobel 算子计算一阶、二阶、三阶或混合图像差分void cvSobel( const CvArr* src, CvArr* dst, int xorder, int yorder, int aperture_size=3 );src输入图像.dst输出图像.xorderx 方向上的差分阶数yordery 方向上的差分阶数aperture_size扩展 Sobel 核的大小,必须是 1, 3, 5 或 7。
opencv subtract 用法OpenCV是一个广泛使用的计算机视觉库,提供了许多用于图像处理和计算机视觉应用的工具和函数。
其中一个常用的函数是subtract,它用于执行两个图像之间的减法运算。
在OpenCV中,subtract函数可以将两个图像相减,从而得到一个表示两个图像差异的图像。
一、基本用法在OpenCV中,subtract函数的基本语法如下:```cppvoid subtract(InputArray src1, InputArray src2, OutputArray dst, bool mask = true);```其中,src1和src2是输入图像,dst是输出图像,mask是一个可选参数,用于指定是否使用掩码进行运算。
二、函数参数说明1. InputArray src1和src2:表示要进行减法运算的两个输入图像。
可以是灰度图像或彩色图像,也可以是矩阵或数组。
2. OutputArray dst:表示输出图像,即进行减法运算后的结果。
dst的维度和类型应该与输入图像相同。
3. bool mask:可选参数,用于指定是否使用掩码进行运算。
当mask为true时,函数将使用输入图像中的值来创建一个掩码,并将掩码应用于输出图像。
这样可以仅对输出图像中的某些像素进行减法运算。
三、函数应用示例下面是一个简单的示例代码,展示了如何使用OpenCV的subtract函数:```cpp#include <opencv2/opencv.hpp>#include <iostream>int main() {// 读取两个灰度图像cv::Mat img1 = cv::imread("image1.jpg",cv::IMREAD_GRAYSCALE);cv::Mat img2 = cv::imread("image2.jpg",cv::IMREAD_GRAYSCALE);// 确保两个图像大小相同if (img1.size() != img2.size()) {std::cerr << "Images must have the same size." << std::endl;return -1;}// 创建输出图像cv::Mat dst;dst.create(img1.size(), img1.type());// 进行减法运算cv::subtract(img1, img2, dst);// 显示结果图像cv::namedWindow("Subtracted Image",cv::WINDOW_NORMAL);cv::imshow("Subtracted Image", dst);cv::waitKey();return 0;}```上述代码中,我们首先读取两个灰度图像,并确保它们具有相同的大小。
getStructuringElement 是OpenCV 中的一个函数,用于获取指定形状和尺寸的结构元素。
结构元素在图像处理中常用于形态学操作,如腐蚀、膨胀等。
函数原型:cppcv::Mat getStructuringElement(int shape, cv::Size ksize, int anchor = 1)参数说明:shape:结构元素的形状,可以是以下值之一:cv::MORPH_RECT:矩形结构元素(默认值)cv::MORPH_ELLIPSE:椭圆形结构元素cv::MORPH_CROSS:交叉形结构元素ksize:结构元素的尺寸,表示为一个包含两个整数的cv::Size 对象。
例如,cv::Size(3, 3) 表示一个3x3 的结构元素。
anchor:结构元素的锚点,即结构元素的中心位置。
默认值为1,表示锚点位于结构元素的中心。
如果提供了锚点坐标,结构元素将相对于锚点进行平移。
返回值:返回一个表示结构元素的cv::Mat 对象。
使用示例:cpp#include <opencv2/opencv.hpp>#include <iostream>int main() {// 创建一个5x5 的矩形结构元素cv::Mat element = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(5, 5));// 输出结构元素std::cout << "结构元素:" << std::endl;std::cout << element << std::endl;return 0;}在这个示例中,我们创建了一个5x5 的矩形结构元素,并将其输出到控制台。
opencv contourarea用法(一)OpenCV ContourArea用法详解OpenCV ContourArea函数用于计算轮廓的面积。
在图像处理和计算机视觉中,轮廓是表示物体边界的连续曲线。
通过计算轮廓的面积,可以对物体进行形状分析和分类等操作。
下面将详细介绍OpenCV ContourArea函数的用法。
1. 函数定义OpenCV ContourArea函数的定义如下:retval = (contour[, oriented])参数说明:•contour:输入的轮廓。
•oriented(可选):如果为True,则函数返回有向面积;如果为False(默认),则函数返回绝对值面积。
返回值:轮廓的面积。
2. 示例以下是使用OpenCV ContourArea函数的示例代码:import cv2# 读取图像并转为灰度图image = ("")gray = (image, _BGR2GRAY)# 阈值化处理_, threshold = (gray, 127, 255, _BINARY)# 查找轮廓contours, _ = (threshold, _EXTERNAL, _APPROX_SIMPLE)# 计算第一个轮廓的面积area = (contours[0])print("Contour Area:", area)3. 解析上述示例代码中,首先读取图像并将其转换为灰度图像。
然后,通过阈值化处理提取图像中的目标物体。
接下来,使用``函数查找轮廓。
找到轮廓后,可以通过``函数计算每个轮廓的面积。
在示例代码中,我们计算了第一个轮廓的面积。
最后,输出面积的值。
4. 注意事项•输入的轮廓必须是二维点集,且顺序不能有误,即必须是顺时针或逆时针的顺序。
•当计算有向面积时,默认顺序是按照坐标顺序。
如果需要逆时针方向的有向面积,可以将oriented参数设置为True。
opencv addweighted函数是图像处理中常用的函数之一,它可以对两张图片进行加权相加操作,从而实现图像融合或者亮度调节等功能。
下面我们将介绍opencv addweighted函数的用法和具体操作步骤。
一、函数原型和参数说明1.1 函数原型函数原型如下所示:dst = cv2.addWeighted(src1, alpha, src2, beta, gamma)其中,src1和src2分别表示要相加的两张图片,alpha和beta分别表示src1和src2的权重,gamma表示加到结果图像上的值。
1.2 参数说明- src1:输入图像1- alpha:输入图像1的权重- src2:输入图像2- beta:输入图像2的权重- gamma:加到结果图像上的值二、具体操作步骤2.1 读取图片我们需要利用opencv中的imread函数读取两张要进行加权相加操作的图片,代码如下:```pythonimport cv2import numpy as npsrc1 = cv2.imread('image1.jpg')src2 = cv2.imread('image2.jpg')```2.2 对图片进行加权相加操作接下来,我们利用opencv中的addWeighted函数对两张图片进行加权相加操作,代码如下:```pythondst = cv2.addWeighted(src1, 0.7, src2, 0.3, 0)```其中,0.7和0.3为权重参数,可以根据实际需要进行调节。
2.3 显示结果图片我们可以利用opencv中的imshow函数显示结果图片,代码如下:```pythoncv2.imshow('result', dst)cv2.w本人tKey(0)cv2.destroyAllWindows()```三、实例下面我们以一个实际例子来演示opencv addWeighted函数的使用。
Open CV的安装及使用说明******************************************************************************* 如果不需要安装OpenCV中的(CalibFilter、ProxyTrans、SyncFilter),则步骤为以下方式(1)安装Open CV(这里的OpenCV版本为OpenCV_1.0);(2)点击”我的电脑”右键属性的系统环境变量,在path中添加<opencv_root>\bin路径,例如:D:\OpenCV\bin;(3)打开<opencv_root>\_make\opencv.dsw,选择菜单Build->Batch Build->Build;******************************************************************************* 如果需要安装OpenCV中的(CalibFilter、ProxyTrans、SyncFilter),则步骤为以下方式(1)安装SDK(注意:2004年下半年及2005以后的版本都不包括directshow),安装目录为:D:\ DXSDK;(2)安装Open CV(这里的OpenCV版本为OpenCV_1.0);(3)点击”我的电脑”右键属性的系统环境变量,在path中添加<opencv_root>\bin路径,例如:D:\OpenCV\bin;(4)编译D:\DXSDK\Samples\C++\DirectShow\BaseClasses,编译建立Release和Debug版本,将产生的库strmbase.lib和strmbasd.lib拷贝到目录<DirectXSDKInstallFolder>\lib下,在Developer Studio的Tools->Options->Directories->Include files中添加如下路径:<DirectXSDKInstallFolder>\include<DirectXSDKInstallFolder>\samples\C++\DirectShow\BaseClasses另外在Tools->Options->Directories->Library files中添加如下路径:<DirectXSDKInstallFolder>\lib;(5)打开<opencv_root>\_make\opencv.dsw,选择菜单Build->Batch Build->Build,又打开<opencv_root>\_make\opencv_directshow.dsw,选择菜单Build->Batch Build->Build;*******************************************************************************注意:在编译opencv.dsw有错误错误的地方是"foreground_regions"问题。
opencv createbutton用法在OpenCV 中,`createButton` 函数是用于创建一个具有交互式按钮的窗口的函数。
该按钮可用于执行特定的操作或更改图像的属性。
以下是`createButton` 函数的基本用法:```pythonimport cv2def on_button_click(state, userdata):# 处理按钮点击事件的回调函数print("Button Clicked! Current State:", state)# 创建一个图像窗口dWindow("Button Window")# 创建一个按钮并指定回调函数cv2.createButton("Click Me", on_button_click, None, cv2.QT_PUSH_BUTTON)# 显示图像窗口,等待用户交互cv2.waitKey(0)cv2.destroyAllWindows()```上述代码中,`cv2.createButton` 函数用于创建一个名为"Click Me" 的按钮,并指定了一个回调函数`on_button_click`。
当用户点击按钮时,回调函数会被调用,并输出按钮的当前状态。
参数说明:- `"Click Me"`: 按钮的显示文本。
- `on_button_click`: 按钮点击事件的回调函数。
- `None`: 用户数据,可在回调函数中使用。
- `cv2.QT_PUSH_BUTTON`: 按钮类型,这里使用的是一个简单的推按钮。
你可以根据实际需求在回调函数中执行特定的操作,例如更改图像的显示内容、调整参数等。
请注意,`createButton` 在使用Qt 图形用户界面时可用。
在OpenCV 中,`createButton` 主要用于图形用户界面的简单交互,如果需要更复杂的用户界面,可能需要考虑使用其他库,例如PyQt 或Tkinter。
一
1、OpenCV+ Code::Blocks开发环境安装流程
Code::Blocks是一款非常优秀的跨平台的IDE,相较于VS系列的IDE,具有启动速度快、界面干净的优点,其编译器采用GCC标准,比VS更加规范。
此外,Code::Blocks可以创建针对OpenCV的编译器,在需要的时候进行切换,大大提高了日常的编译速度。
配置的操作系统是Win7 64位版,以下方法32位也可以。
已测试过多个Code::Blocks 和OpenCV版本,均可以运行。
下面是详细的配置步骤:
假设我们都已经安装好OpenCV 2.4.2和Code::Blocks 10.05,且预设的安装路径为「D:\opencv」以及系统环境变量PATH的值为
D:\opencv\build\x86\vc10\bin;
D:\opencv\build\common\tbb\ia32\vc10;
D:\opencv\build\x86\mingw\bin;
注意:环境变量设定完后一定要重新启动,后面有设定环境变量的方法。
以下开始介绍OpenCV 2.4.2在Code::Blocks 10.05里的设定流程:
1. 开启Code::Blocks后,在最上面列表中找到「Setting」并选取「Compiler and debugger」。
注意,这里有一个小技巧,就是选择「Copy」默认的编译器,将之重命名为「GNU GCC Compiler for OpenCV」,选择「Set as Default」,这样的话,你接下来的工程就不需要重新设定链接库了。
然后平时使用Code::Blocks可以再切换到原本默认的编译器。
2. 选取「Search directories」的「Compiler」,点选「Add」并新增两个路径:D:\opencv\build\include
D:\opencv\include\opencv。
3. 选取「Search directories」的「Linker」,点选「Add」并新增两个路径:D:\opencv\build\x86\vc10\lib
D:\opencv\build\x86\vc10\staticlib。
4. 选取「Linker settings」,点选「Add」把
D:\opencv\build\x86\vc10\lib
D:\opencv\build\x86\vc10\staticlib
D:\opencv\build\x86\mingw\lib
三个文件夹下的lib全部加入。
再点选「OK」,就完成OpenCV 2.4.2在Code::Blocks的设
定了,也就可以开始写OpenCV的函数,实际测试看看了。
以上,OpenCV已成功配置。
使用C/C++在Code::Blocks创建工程:
1.点开「Project」。
2.选择「Console application」,再点选「Go」。
3.选择您要的使用的程式语言,再点选「Next」。
4.输入工程名称和放置工程文件夹的路径。
(路径一定要设,不然会有问题。
)
5.点选「Finish」。
6. 双击「main.cpp」后,就可以开始写一段代码或者直接载入OpenCV下Sample文件夹的工程运行。
Windows 7环境变量设定:
1. 在「桌面」或是「文件夹旁」的电脑上,点选右键的「内容」。
2. 点选左上角的「进阶系统设定」。
3. 点选「进阶」里的「环境变量」。
4. 使用「新增」或是「编辑」要设定的PATH值为:
D:\opencv\build\x86\vc10\bin;
D:\opencv\build\common\tbb\ia32\vc10;
D:\opencv\build\x86\mingw\bin;
(或是把要设定的PATH值,加在原有PATH值的后面,记得以「;」隔开)。
设定完成后,点选「确定」完成环境变量的设定。
设定时遇到的一些小问题(与下载的版本有关):
在使用有「cv namespace」的函数,还需要再另外下载两个dll文件:「libgcc_s_dw2-1.dll」
和「libstdc++-6.dll」,然后放到「D:\CodeBlocks\MinGW\bin」里头。
在官方网站下载的Code::Blocks 10.05(mingw版)里的MinGW编译器里是没有这两个文件的。
资源下载:
1. OpenCV
2.4.2
/downloads.html
2. Code::Blocks-10.05 mingw
/downloads/26
3. libgcc_s_dw2-1.dll
「http://pt.sourceforge.jp/projects/sfnet_openmarias/downloads/libgcc_s_dw2-1.d ll/」
4. libstdc++-6.dll
「http://de.sourceforge.jp/projects/sfnet_hamilton/downloads/stdcpp6/2/2.0/dev-bin/libstdc++-6.dll/」。