仿照 OpenCV 中文官方网站上VC2010安装OpenCV2.4.4的教程安装,该教程地址为 VC 2010下安装OpenCV2.4.4

我的环境和教程中的不一样,先说说教程中的搭建环境:

VC2010

windows 32位操作系统,即x86

opencv2.4.4

我的环境:

VC2012

windows 8.1 64位中文版操作系统,即x64

opencv2.8.2 (最新版)

根据你的CPU位数,按照教程中的方法安装即可。我的是64位,则在选择的时候,x86就换成x64 。另外,将教程中的vc10换成vc12 。

这里有一个值得强调的问题,教程中没有明确说明。按照教程的方法安装好,然后建立测试程序,运行后提示多行类似下面语句的错误:

后来发现,这是我的配置错误,对64位操作系统的配置还没有完成。还需要修改的地方是:

生成–>配置管理器–>活动解决方案平台–>新建–>x64  如下图:

新建好之后,在属性管理器中就能看到多出来了Debug|x64和Release|x64,如下图:

在“属性管理器”中,对Debug|x64或Release|x64的Micro.Cpp.x64.user仿照x86进行设置,但是注意替换VC++目录中的x86为x64,还要记得在“连接器–>输入”中包含库。

需要强调的是,对于Debug|x86或Release|x86的Micro.Cpp.x86.user的设置,请和教程中的保持一致,不是x64,就是x86 。

即,在Debug|x86或Release|x86下就设置x86的,在Debug|x64或Release|x64下才需要设置x64的,分开对待。如下图

我列出VC2012中的opencv\build\x64\vc12\库

x64中要包含的目录:

其他错误的处理方法:

错误1: fatal error C1083: 无法打开包括文件:“opencv2\opencv.hpp”: No such file or …

表示的意思是找不到opencv.hpp,这是在VC++目录中设置的,即在下图中设置,教程中已经说明了。

错误2:找不到msvcr120.dll、msvcp120.dll

表明系统缺少该dll文件,可以在网上搜索下载,然后安装。安装dll文件时注意以下区别:

安装dll,就把dll文件直接拷贝该文件到系统目录里,但是不同系统拷贝的目录是不同的:
1、Windows 95/98/Me系统,将msvcp120.dll复制到C:\Windows\System目录下。
2、Windows NT/2000系统,将msvcp120.dll复制到C:\WINNT\System32目录下。
3、Windows XP/WIN7/Vista系统,将msvcp120.dll复制到C:\Windows\System32目录下。
如果您的系统是64位的请将文件复制到C:\Windows\SysWOW64目录
然后打开”开始-运行-输入regsvr32 ***.dll”,回车即可解决。或者打开cmd(命令提示符)输入刚才的语句即可,***.dll表示你刚才拷贝进去的dll文件。

我出现的就是以上几个错误,都排除了。然后就成功运行了,搭建完成。

测试代码如下:

注意,请将lena.jpg放到项目目录中的同名子目录中,如下图所示:

运行效果图:

代码:(代码转载自:http://ubaa.net/shared/processing/opencv/blob.html

import hypermedia.video.*;

OpenCV opencv;

void setup() {

    size( 640, 480 );

    // open video stream
    opencv = new OpenCV( this );
    opencv.capture( 640, 480 );

}

void draw() {

    background(192);

    opencv.read();           // grab frame from camera
    opencv.threshold(80);    // set black & white threshold

    // find blobs
    Blob[] blobs = opencv.blobs( 10, width*height/2, 100, true, OpenCV.MAX_VERTICES*4 );

    // draw blob results
    for( int i=0; i<blobs.length; i++ ) {
        beginShape();
        for( int j=0; j<blobs[i].points.length; j++ ) {
            vertex( blobs[i].points[j].x, blobs[i].points[j].y );
        }
        endShape(CLOSE);
    }
}

使用效果视频演示:

我们可以在 http://ubaa.net/shared/processing/opencv/ 找到 OpenCV Processing and Java Library。

我提供的下载地址: http://yunpan.cn/Q9yQsLF8HjZSc (附带高清版视频操作演示)

网站说明如下

This implementation is not a complete port of OpenCV. Currently, this library supports :

  • real-time capture
  • video file import
  • basic image treatment (brightness, contrast, threshold, …)
  • object detection (face, body, …)
  • blob detection

Future versions will include more advanced functions such as motion analysis, object and color tracking, multiple OpenCV object instances …

For more information about OpenCV visit the Open Source Computer Vision Library Intel webpage, the OpenCV Library Wiki, and the OpenCV Reference Manual (pdf).

由于是国外网站,有些朋友可能打不开,现提供我备份的下载地址: http://yunpan.cn/Q9yQsLF8HjZSc

 另外,最新的库下载地址在这里:https://github.com/atduskgreg/opencv-processing/releases

安装方法:

Installation instructions

1.Begin by downloading and installing the implementation of OpenCV appropriate to your platform:

  • For Windows, download the OpenCV release version 1.0 (not the 1.1pre1) package and follow the instructions of the installer. notes: be sure to select the additional tasks ‘Add ….OpenCV bin to system PATH’ during installation (or you need to add the rigth path by yourself later) and reboot your machine.

  • For MacOS X, dowload the opencv-framework-1.1.dmg image and install the package by following instructions of the installer

 

  • For Linux users, if your distribution doesn’t propose packages in your favorite Package Manager tool, download the latest opencv-*.tar.gz archive and compile/install the source files as describe in the Linux install guide.

2.Download, unzip, and move the OpenCV Processing Library into your Processing libraries folder, or for Java users copy the content of the library folder in one of your Java Extensions folder.

DUE TO AN ERROR WHILE PACKAGING THE ZIP FILE, THIS VERSION UPDATED SHOULD SOLVE THE WINDOWS PROBLEM ABOUT DLL DEPENDENCIES AND OPENCV 1.0

在 Windows 中安装 OpenCV Processing Library
在 Mac 中安装 OpenCV Processing Library

3.Optionally, you can download these OpenCV Processing examples or, for pure Java users, these OpenCV Java samples.

4.Previous library version can be downloaded here

视频操作演示

PS:下载地址中包括了视频的高清版,可以下载查看。

 

Documentation

  • See the What’s New document for all new implementation or for some of the most important changes
  • Processing documentation … 🙂 start with this page (also include in the OpenCV Processing Library zip archive)
  • For Java users, the Javadoc reference for this project (online only). For offline documentation dowload the OpenCV Java Library API

Credits

The OpenCV Processing Library is a project of the Atelier hypermédia at the École Supérieure d’Art d’Aix-en-Provence. It is maintained by Stéphane Cousot and Douglas Edric Stanley. Special thanks to the openframeworks community for support and the C++ Binary Quicksort method.

OpenCV

The main object for all computer vision processes.

An example(举例): the usage of the first one (OpenCV)

Name OpenCV
Examples
Description The main object for all computer vision processes.
Syntax
OpenCV(parent);
Fields
BILATERAL Blur method
BLUR Blur method
BUFFER Type of Image
CASCADE_FRONTALFACE_ALT Standard Haar classifier cascade file used for object detection
CASCADE_FRONTALFACE_ALT2 Standard Haar classifier cascade file used for object detection
CASCADE_FRONTALFACE_ALT_TREE Standard Haar classifier cascade file used for object detection
CASCADE_FRONTALFACE_DEFAULT Standard Haar classifier cascade file used for object detection
CASCADE_FULLBODY Standard Haar classifier cascade file used for object detection
CASCADE_LOWERBODY Standard Haar classifier cascade file used for object detection
CASCADE_PROFILEFACE Standard Haar classifier cascade file used for object detection
CASCADE_UPPERBODY Standard Haar classifier cascade file used for object detection
FLIP_BOTH Flip mode
FLIP_HORIZONTAL Flip mode
FLIP_VERTICAL Flip mode
GAUSSIAN Blur method
GRAY Colorspace of image
HAAR_DO_CANNY_PRUNING Haar classifier flag
HAAR_DO_ROUGH_SEARCH Haar classifier flag
HAAR_FIND_BIGGEST_OBJECT Haar classifier flag
HAAR_SCALE_IMAGE Haar classifier flag
INTER_AREA Interpolation method
INTER_CUBIC Interpolation method
INTER_LINEAR Interpolation method
INTER_NN Interpolation method
MAX_VERTICES The maximum number of contour points available to blob detection (by default)
MEDIAN Blur method
MEMORY Type of Image
MOVIE_FRAMES Movie info selector (not yet implemented)
MOVIE_MILLISECONDS Movie info selector (not yet implemented)
MOVIE_RATIO Movie info selector (not yet implemented)
RGB Colorspace of image
SOURCE Type of Image
THRESH_BINARY Thresholding method
THRESH_BINARY_INV Thresholding method
THRESH_OTSU Thresholding method
THRESH_TOZERO Thresholding method
THRESH_TOZERO_INV Thresholding method
THRESH_TRUNC Thresholding method
height OpenCV image/buffer height
width OpenCV image/buffer width
Methods
ROI() Set image region of interest to the given rectangle.
absDiff() Calculate the absolute difference between the image in memory and the current image.
allocate() Allocate required buffer with the given size.
blobs() Blob and contour detection.
blur() Smooth the image in one of several ways.
brightness() Adjust the image brightness with the specified value (in range of -128 to 128).
capture() Allocate and initialize resources for reading a video stream from a camera.
cascade() Load into memory the descriptor file for a trained cascade classifier.
contrast() Adjust the image contrast with the specified value (in range of -128 to 128).
convert() Convert the current image from one colorspace to another.
copy() Copy the image (or a part of it) into the current OpenCV buffer (or a part of it).
detect() Detect object(s) in the current image depending on the current cascade description.
flip() Flip the current image around vertical, horizontal or both axes.
image() Return the current (or specified) OpenCV image
interpolation() Set global interpolation method.
invert() Invert image.
jump() Jump to a specified movie frame.
loadImage() Load an image from the specified file.
movie() Allocate and initialize resources for reading a video file from the specified file name.
pixels() Retrieve cuurent (or specified) image data.
read() Grab a new frame from the input camera or a movie file.
remember() Place the image (original or current) in memory.
restore() Revert to the original image.
stop() Stop OpenCV process.
threshold() Apply fixed-level threshold to the current image.
Usage Application
Related

维基百科介绍(全面,可以找到关于OpenCV的各个链接)

OpenCV 2.4.3 documentation

OpenCV DevZone

ChangeLog(新版本的修改日志)

一本新书:

Mastering OpenCV with Practical Computer Vision Projects

  • Detailed tutorials & full-source code for 9 projects (Augmented Reality, SfM, OCR, AAM & POSIT, 2D & 3D Face Tracking, Face Recognition, Kinect, Mobile), using C++ version of OpenCV 2.4.2 or newer.

  • Latest code is available at https://github.com/MasteringOpenCV/code

  • Mastering OpenCV

  • (Assumes you already know how to use OpenCV, such as by reading the 2 books above).

现在OpenCV版本已经更新到了2.3.2(由OpenCV.org.cn得到),有传言已经到了2.4.2(可到新浪爱问共享资料下载到OpenCV-2.4.2.part1,2,3,4,5,搜索便有了),而旧的书,比如Learning OpenCV第一版和yushiqi的书都是基于OpenCV1.x,几乎已经不能拿来使用了。

这本好书叫做:《OpenCV 2 Computer Vision Application Programming Cookbook》

电子书下载地址: OpenCV.2.Computer.Vision.Application.Programming.Cookbook.pdf

另外一本书找不到电子版,这里是google的图书介绍:

Learning OpenCV:Computer Vision in C++ with the OpenCV Library

封面