Computer Vision (a) the installation and use -openCV

First, what is computer vision

Such computer vision techniques may be still images or video data is converted into a new representation or decision. All such conversions are to accomplish a specific purpose carried out. The input data may contain some scenes information, such as "The camera is mounted on the collar of the car," or "a radar meters away there is a target." Representation is to convert color images to black and white images, or eliminate the effects of camera motion is generated from a sequence of images.

Non-computer professionals may feel that computer vision is a very simple task, but this is misleading because the human race is one kind of visual animals produced human brain visual signal is divided into a number of channels, allowing you to receive different information , the brain's attention system testing task-based approach through an important part of the image to estimate other regions in the visual system will generate a huge amount of feedback, humans produce cross-association based on their years of life experience to obtain the perception of an object , because you know you like the way the book is rectangular and made up a lot of paper, when you see a similar picture of the brain will give you feedback this is a book of information, because you look like books from an early age has been contacted , so the brain has built a complete pattern recognition mechanism.

In computer vision system, the computer will be received from the camera or digital hard disk arranged in a grid-like, i.e., a computer vision system does not identify the mechanism of a pre-established pattern of presence. No automatic control of focus and aperture, no more years of experience, like a newborn child (of course not a child so smart) We only need to know a concept, the computer only saw numbers, and can not understand that people see all kinds of pictures of the world, and the computer at the time of a real three-dimensional objects photographed sampled at different viewpoints data obtained is not the same, and even view the same position, the two samples obtained pictures the data will be different, because of noise pollution (noise nor that this noise) and distortion.

Second, what is openCV

openCV is an open source computer vision library, from http://opencv.org get, openCV library written in C and C ++ language, the system can run windows, linux, Mac OS, etc. (not write does not mean that the system does not support the current already supports almost all major operating system), is a cross-platform computer vision library. ARM even have carried out support, but because of their origin Intel, the Intel processor for openCV a lot of optimizations (IPPICV IPP sub-libraries), and therefore is the most suitable hardware platform running openCV.

Third, how to use openCV

openCV is an open source free computer vision library, which may be the purpose of commercial or non-commercial, program I have written may not be open source, the module openCV itself is divided freely use and restrict the use of, for example: Nonfree module is to restrict the use of the internal module contains some patents involve algorithms. openCV can go to the official website http://opencv.org download can also go to GitHub Download ( https://github.com/opencv/opencv ), but generally the official website updated faster, and downloaded from github is not compiled source code, so after downloading need to be compiled with Cmake. Downloaded directly from the official website is exe executable file, can be installed directly. Environment variables need to be configured after installation:

Right-click on My Computer -> Properties -> Advanced System Settings -> Environment Variables

Found in the PATH system variable was then added:

F:\openCV\opencv\build\x64\vc15\bin

F:\openCV\opencv\build\bin

(This is my own openCV the installation path, you can change their own, in addition to the x64 folder and have vc14 vc15 directly select the latest vc15 can)

image_thumb3

So it openCV configured, then that is the compiler of choice, my choice is VS2019, VS2019 The following describes how to configure the installation openCV library:

First to: F: \ openCV opencv x64 \ vc15 bin directory \ \ build \ \ (according to their openCV installation directory) to find the following three files:

image_thumb5

Note: The file name may be different, for example, I use the version it has openCV4.1.1 411 words behind file, but if it is version 4.0.0 is 400 words.

Copy these three files to: C: \ under the Windows \ System32 folder (the folder may require administrator privileges, you can allow direct)

Then VS to create a project, right-click the project file -> Properties -> C ++ directory, then add the following in the corresponding entry:

1, was added to the directory containing the
F: \ openCV \ OpenCV \ Build \ the include
F: \ openCV \ OpenCV \ Build \ the include \ opencv2

2, adding the library directory
F: \ openCV \ opencv \ build \ x64 \ vc15 \ lib

These changes according to their own installation directory

Also in the Properties - Add> Additional Dependencies entry at the input -> Connector:

opencv_world411d.lib (this document and the above three documents as required according to their openCV version of the name change, such as the 4.0.0 version should be opencv_world400d.lib)

Above will be configured, it can be encoded, here accompanied by some test code:

#include <iostream>
#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>

using namespace cv;
using namespace std;

main int ()
{
     Mat Image;
     Image = imread ( "F: \\ images \\ desktop background \\ 123.jpg"); // Read the file

    if (image.empty()) // Check for invalid input
     {
         cout << "Could not open or find the image" << std::endl;
         return -1;
     }


     namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
     imshow("Display window", image); // Show our image inside it.

    waitKey(0); // Wait for a keystroke in the window

    cout << "Hello World!\n";
}


Note: The path to the image of the code into their own casual remember a photograph and a path, a path where there is attention to using the double slash \\

Guess you like

Origin www.cnblogs.com/geek-hao/p/11655982.html