C + + development face Gender Recognition Tutorial (3)--OPENCV Configuration and Imagewatch plugin introduction

Source: Internet
Author: User

Original address: http://blog.csdn.net/u013088062/article/details/50435079

OpenCV is an important tool for C + + image processing, and the gender-aware project of this face is developed with the help of OpenCV. Although there are a lot of OPENCV on the Internet configuration tutorial, but for the sake of tutorial integrity, here is a special blog to introduce the specific configuration of OPENCV, but also introduce a powerful image processing plug-in--imagewatch OpenCV.

Since this program was written a year ago, The latest version of OpenCV at the time was 2.4.9 (now updated to 3.0), and 2.4.9 and 3.0 are slightly different in configuration methods, here I still use the 2.4.9 version As an example to describe the configuration method, the new features of 3.0 and the configuration method you can refer to network resources.

First, the OPENCV download installs

First, give the official of OpenCV: OpenCV download.

After the download is complete, get an EXE file about 300M or so:

Double-click to start the installation, enter the installation location, click the Extract button:

The installation process is essentially a decompression process:

After the installation is complete, there are two directories: build and source. The build directory contains the relevant library files, which are the main parts of the OpenCV. The source directory mainly contains some help documents and official resources (such as already trained classifiers, etc.):

Second, configure the path

After the download installation is complete, start VS2012 and open a project at any one. Here we create a new empty Win32 console application. In which OpenCV is called:

Here the # include statement is marked with a red underline, stating that the OPENCV configuration is not currently in progress. OK, then start the configuration.

1. Configure vs Path

Click Project-> Properties to open the Properties dialog box:

Under the Configuration Properties->vc++ directory node, click the Down button to the right of the Include directory:

Select the Include folder path under the OpenCV directory:

Similarly, add the Lib folder path in the Library directory:

Here are two points to note:

(1) X64. There are two files under the Build folder X86 and X64,x86 are for 32-bit Windows systems, and X64 is for 64-bit systems. Since my computer is a 64-bit Win7, it is a matter of course to choose X64, but the point is that under the 64-bit system can also use X86 under the file, as long as the debugger is set to Win32.

(2) VC11. There are three folders under the X86 and X64 folders: V10, V11, and V12. Where V10 applies to vs2010,v11 used in VS2012,V12 for VS2013 (which was not yet released VS20150), we choose the VS11 folder here.

Next, under the configuration Properties-> Linker-> Input node, enter the following OpenCV library file name in the Additional Dependencies window:
Opencv_calib3d249d.lib

Opencv_core249d.lib

Opencv_features2d249d.lib

Opencv_flann249d.lib

Opencv_gpu249d.lib

Opencv_highgui249d.lib

Opencv_imgproc249d.lib

Opencv_legacy249d.lib

Opencv_ml249d.lib

Opencv_objdetect249d.lib

Opencv_ts249d.lib

Opencv_video249d.lib

Opencv_contrib249d.lib

Opencv_nonfree249d.lib

Click Apply to close the Settings window.

2. Configure Environment variables

Environment variables for Windows systems are almost always a must for all programming software, because the compiler automatically reads the search path through environment variables at startup.

As for how to open the Environment Variables window here, you will need to add the path "" of the OpenCV Bin (executable) directory to the environment variable:

After the configuration is complete, restart VS, enter the include command again, and find that the "OpenCv2" appears in the list of hints given by VS, and initially assume that the configuration is complete:

Next we write a small program to test OPENCV: read a color image under the F-packing directory, grayscale, and then display the code

Press F7 to compile, program error, type "error LNK2019: unresolved external symbol ...". This is because the program uses the 32-bit debug debugger by default, and we are configuring a 64-bit OPENCV, so we need to use a 64-bit debug debugger. Click the drop-down menu for the toolbar "Win32" to select Configuration Manager:

In the pop-up window, click the "Win32" drop-down button and select "New":

New platform Selection X64:

Click OK to close the Settings dialog box, at which point we have created a 64-bit debug debugger and then select the 64-bit debugger in the debugger bar:

Press F7 again to compile successfully. F5, the debugging is successful. Ctrl+f5, the program runs smoothly and displays pictures.

Third, Imagewatch plug-in

Next introduce a powerful vs helper plugin for OpenCV: Imagewatch.

1. Appearance

First of all, Imagewatch must be in the debugging process to work, to use the imagewatch corresponding to the program set some breakpoints to the program to pause. First, give the appearance of the Imagewatch:

As can be seen, imagewatch can display in real-time the current program in the picture (in fact, the mat matrix) information, including size, pixels, appearance and so on, undoubtedly to the program's debugging brought considerable convenience. Let's take a look at the functionality of this plugin in detail.

2, Imagewatch plug-in installation

First, give me a tutorial on Imagewatch plugin that I wrote earlier about: Imagewatch tutorial.

Imagewatch official Help documentation: Help documentation.

Imagewatch:.

When the download is complete, double-click the installation. The currently installed compilers are automatically recognized during the installation process, and the VS2012 can be selected.

After the installation is complete, you need to enable the plugin manually. Open VS, click "View-> Other Windows->imagewatch":

At this point again set breakpoints, F5 debugging, Imagewatch normal operation. Next we describe several of its common functions.

3. Common functions

(1) Image view

Be able to display the status of the current picture in real time, thumbnails, etc., this does not need to say:

(2) Viewing pixel information

Position the mouse in the preview window on the right, and the upper title bar displays the location coordinates of the current mouse pointer's pixel in real time, as well as the pixel values, scaling (coordinate values and pixel values, scaling from left to right, respectively):

When you press CTRL + Mouse wheel in the preview window, the image zooms in and out until you zoom in to see the pixel value (color image by three values, RGB):

4. Save the picture

Imagewatch can easily save the current picture, just right click on the corresponding icon, select "Dump to File" in the shortcut menu:

Imagewatch also has more features, such as the associated display of the example, and so on, please join the previous blog and the official Help document, here will not repeat.

Iv. Summary

This is the final document in the preparation section of this tutorial, and in the next blog we will begin to write code. Here are a few things to keep in mind:

(1) OpenCV still recommend that you use the new version. OPENCV's development has experienced 1.x, 2.x, to today's 3.0 edition. The 1.x version of OpenCV only provides the C language interface, where all the API functions start with "CV", only the struct, no class structure, the Iplimage pointer type represents the image, and so on. Not to mention, OpenCV's development tends to improve, the 2.4 series version is recognized as a mature version. But in the last two days when I browsed OpenCV's official website, I found that there were a lot of newer algorithms in version 3.0, such as deeplearning, so it is recommended to try out the 3.0 version of the image processing algorithms.

(2) Write a tutorial to use more diagrams. This may be a bit confusing, but I think it is necessary to come up with a word. I used to write tutorials, most of the long-distance, I want to even code to describe the language, and then I translated the "most full pycharm tutorial" process, deeply realized the importance of illustrations, but also deeply experienced the crooked nuts in programming, narrative rigor. So I also learned from the experience, with the figure to speak, so you see this article less than 2500 words, but has 23 pictures of the article, the future of the article is so, do not know whether we can adapt to ha.

(turn) C + + development face Gender Identification Tutorial (3)--OPENCV Configuration and Imagewatch plugin introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.