重磅发布 | OpenCV 4.0正式来了

Posted OpenCV学堂

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了重磅发布 | OpenCV 4.0正式来了相关的知识,希望对你有一定的参考价值。

三天前OpenCV通过GITHUB正式发布了OpenCV又一个重要里程碑版本OpenCV 4.0。

https://github.com/opencv/opencv/wiki/ChangeLog#version400

release note中介绍了OpenCV4.0 内含一些特别有用的新特性与新模块,下面就来先睹为快!

新特性

重磅发布 | OpenCV 4.0正式来了

1.A lot of C API from OpenCV 1.x has been removed. The affected modules are objdetect, photo, video, videoio, imgcodecs, calib3d.

意思说OpenCV1.x以来许多C风格的API又被干掉啦,这次受影响的模块包括对象检测、照片、视频、视频读写、图像读写、三维校正。貌似OpenCV3.x版本以来每个版本都会干掉一批,毫无疑问学习OpenCV从最新版本开始是个明智而且避免浪费时间的选择,其实它还没说OpenCV3.x之后,扩展模块一直在抛弃C风格的API。

2.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. For now base64 support is not complete (only loading base64-encoded XML and YAML is supported, encoding is not supported at all). Also, random access of sequences stored in a FileNode is slow O(N) operation; use cv::FileNodeIterator for much faster sequential access. On the positive side, loaded FileStorage takes 3-6x less memory than in the previous implementation.

意思是说OpenCV优化了持久层,可以结构化写XML、YAML、JOSN在核心模块中,原来的C风格API又又被抛弃了,使用FileNodeIterator可以更快访问序列存储,FileStorage也优化啦,比以前需要更少的内存。这个用过OpenCV中ML模块的都知道XML、YAML经常用来存储训练结果数据的,以后这个加载与存储会快了是福音。

3.OpenCV is now C++11 library and requires C++11-compliant compiler. Note that OpenCV 3.x can also be built as C++11 library by passing -DENABLE_CXX11=ON flag to CMake. Now this is the only option so the flag is not needed and is not available anymore.

意思是说OpenCV现在基于C++11库而且要求C++11的编译器在CMake的时候,然后说CMake OpenCV 4.0与OpenCV3.x之间的不同,需要注意一下,如果自己编译OpenCV 4.0源码应该注意到。

4.Thanks to the extended C++11 standard library, we could get rid of hand-crafted cv::String and cv::Ptr. Now cv::String == std::string and cv::Ptr is a thin wrapper on top of std::shared_ptr. Also, on Linux/BSD for cv::parallel_for_ we now use std::thread's instead of pthreads.

意思是说感谢C++11的标准库扩展,以后没有cv::String与cv::Ptr了。在OpenCV3.x中我其实还比较喜欢用cv::String,看来这个习惯要改啦。

重磅发布 | OpenCV 4.0正式来了

OpenCV深度神经网络-DNN模块
1.Added support for Mask-RCNN model. Follow a guide and use a python sample.

重磅消息终于支持Mask-RCNN模型的预测,具体可以看指南与python教程

2.Integrated ONNX parser. We now support many popular classification networks. YOLO object detection network in partially supported as well (ONNX version of YOLO lacks some final layers that actually give you the list of rectangles). Thanks to Lubov Batanina for her first-time contribution to OpenCV!

这个说是集成ONNX解析器,这样就支持了大多数分类网络,YOLO对象检测网络也是部分支持(晕倒,还不是完全支持),最后是要感谢ubov Batanina这个哥们,显然这个新特性跟他有莫大的关系,身上隐藏了不少秘密。

3.Further improved performance of DNN module when it's built with Intel DLDT support by utilizing more layers from DLDT. By the way, DLDT has been recently released as open-source. See the guide how to build and use OpenCV with DLDT support.

这条对一般开发者暂时无影响,是说DNN模块的性能又有提升了,而且是基于Intel DLDT,看来这个属于Intel在发布时候夹带的私货。

4.API changes: by default, blobFromImage methods family do not swap red and blue channels and do not crop the input image. Beware that this API change has also been propagated to OpenCV 3.4 branch.

这个改变跟开发者息息相关,就是DNN模块输入tensor数据的API改啦,不再交换RGB/BGR这样的通道交换支持啦,也不剪切传图啦,然后还是这个3.4的分支中已经改啦,这个我好像会经常用,看来以前的代码在OpenCV4.0上必须操作一波才可以继续工作。

5.Experimental Vulkan backend has been added for the platforms where OpenCL is not available: https://github.com/opencv/opencv/pull/12703. Thanks to Zhiwen Wu and Juan J. Zhao for the contribution!

意思是说如果OpenCL不支持的话,还可以通过Vulkan backend来执行一波,显然也要感谢一波对这个问题有贡献的人。

6.Added shortcuts for the most popular deep learning networks supported by OpenCV. You may specify an alias name of model to skip pre-processing parameters and even paths to models! In example, instead of

意思是是说支持快捷方式,可以声明一个别名跳过预处理参数甚至模型路径,说实话小编有点发懵,难道这么就可以操作一波啦,仔细看了一下代码示例,发现确实如此,有一堆默认值,可以直接通过tf的组件读取模型了,而且跟tensorflow object detection API实现了无缝对接,这个是不是以后tensorflow object detection API导出模型直接可以用了,这样对端侧应用来说是很大的福音,为OpenCV这个新特性打Call。
以前需要

python object_detection.py --model opencv_face_detector.caffemodel --config opencv_face_detector.prototxt --mean 104 177 123 --width 300 --height 300

you can type just
现在只需要

python object_detection.py opencv_fd

7.Fixed OpenCL acceleration on AMD and NVIDIA GPUs. Now you may enable DNN_TARGET_OPENCL for your model without extra environment variables. Please note that DNN_TARGET_OPENCL_FP16 is tested on Intel GPUs only, so it still requires additional flags.

意思是或现在支持OpenCL不需要配置一堆啦,直接一句话搞定,最后又说这个好像只有对Intel GPU才行,对其它还需要操作一波,显然Intel只想于自己方便。哈哈!

新模块

重磅发布 | OpenCV 4.0正式来了

重磅发布 | OpenCV 4.0正式来了

性能全部提升,各种优化,跟开发者关系比较大的是这条,自己编译OpenCV源码时候,添加CPU_BASELINE=AVX2可以获得比原来15~30%的速度提升,请收藏此技能。

重磅发布 | OpenCV 4.0正式来了

支持二维码检测与解析了,在对象检测模块中。同时还是感谢了神人的贡献。

重磅发布 | OpenCV 4.0正式来了

3D对象扫描与模型创建流行算法Kinect Fusion algorithm已经被实现,被集成到了rgbd模块中,这个东西太好用啦,值得尝试一波。

重磅发布 | OpenCV 4.0正式来了

DIS稠密光流算法已经从扩展模块中移到主仓发布,在OpenCV视频模板中,同时还把TV L1光流算法从master移到扩展模块中去啦,果然是一波神操作。

致谢

最后OpenCV自己总结了一下:

OpenCV 4.0 有155位开发者参与
OpenCV4.0 扩展模块有43位开发者参与

让我们感谢这些开发者的无私奉献与OpenCV社区对开源的贡献,用好OpenCV框架这个计算机视觉开发工具给自己的工作开疆拓土,乘风破浪,不断前进。

欢迎扫码加入【OpenCV研习社】

推荐阅读











关注【OpenCV学堂】

长按或者扫码即可关注


以上是关于重磅发布 | OpenCV 4.0正式来了的主要内容,如果未能解决你的问题,请参考以下文章

开发 | OpenCV 4.0 正式发布

千呼万唤始出来!OpenCV 4.0正式发布!

重磅:张小龙出品,微信键盘正式版来了

刚刚,华为重磅宣布,鸿蒙手机要来了!

HDC2022重磅发布“鸿蒙赋能全家桶”,开发者的新时代要来了?

HDC2022重磅发布“鸿蒙赋能全家桶”,开发者的新时代要来了?