OpenCV 4 的配置和使用

oneNeko 于 2020-06-02 发布

OpenCV 是英特尔开源的跨平台计算机视觉库。也就是说,它是一套包含从图像预处理到预训练模型调用等大量视觉 API 的库,并可以处理图像识别、目标检测、图像分割和行人再识别等主流视觉任务。
opencv4 的主要更新如下

After almost 3.5 years since groundbreaking 3.0 release, we are glad to present the first stable release in the 4.x line.
Release highlights:
OpenCV is now C++11 library and requires C++11-compliant compiler. Minimum required CMake version has been raised to 3.5.1.
A lot of C API from OpenCV 1.x has been removed.
Persistence (storing and loading structured data to/from XML, YAML or JSON) in the core module has been completely reimplemented in C++ and lost the C API as well.
New module G-API has been added, it acts as an engine for very efficient graph-based image procesing pipelines.
dnn module was updated with Deep Learning Deployment Toolkit from the OpenVINO™ toolkit R4. See the guide how to build and use OpenCV with DLDT support.
dnn module now includes experimental Vulkan backend and supports networks in ONNX format.
The popular Kinect Fusion algorithm has been implemented and optimized for CPU and GPU (OpenCL)
QR code detector and decoder have been added to the objdetect module
Very efficient and yet high-quality DIS dense optical flow algorithm has been moved from opencv_contrib to the videomodule.
More details can be found in previous announces: 4.0-alpha, 4.0-beta, 4.0-rc and in the changelog
Branch 3.4 will be switched to maintanence mode: only bugfixes and light features will be accepted. BTW, release 3.4.4 is ready too!





#include <opencv2\opencv.hpp>
using namespace cv;
int main(){
    Mat img; //声明一个保存图像的类
  	img = imread("E:\\ok.png"); //读取图像,根据图片所在位置填写路径即可
  	if (img.empty()) //判断图像文件是否存在
  		std::cout << "请确认图像文件名称是否正确" << std::endl;
  		return -1;
  	imshow("test", img); //显示图像