重磅發佈 | OpenCV 4.0正式來了

三天前OpenCV通過GITHUB正式發佈了OpenCV又一個重要里程碑版本OpenCV 4.0。

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

release note中介紹了OpenCV4.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深度神經網絡-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只想於自己方便。哈哈!

新模塊

新模塊G-API模塊,特別重點推薦一下,這個模塊可以定義一系列的圖像處理過程,然後把整個過程看成一個API調用,後續小編會有文章單獨演示OpenCV 4.0新特性,請繼續關注本公衆號即可。

性能全部提升,各種優化,跟開發者關係比較大的是這條,自己編譯OpenCV源碼時候,添加CPU_BASELINE=AVX2可以獲得比原來15~30%的速度提升,請收藏此技能。

支持二維碼檢測與解析了,在對象檢測模塊中。同時還是感謝了神人的貢獻。

3D對象掃描與模型創建流行算法Kinect Fusion algorithm已經被實現,被集成到了rgbd模塊中,這個東西太好用啦,值得嘗試一波。

DIS稠密光流算法已經從擴展模塊中移到主倉發佈,在OpenCV視頻模板中,同時還把TV L1光流算法從master移到擴展模塊中去啦,果然是一波神操作。

致謝

最後OpenCV自己總結了一下:

OpenCV 4.0 有155位開發者參與 OpenCV4.0 擴展模塊有43位開發者參與

讓我們感謝這些開發者的無私奉獻與OpenCV社區對開源的貢獻,用好OpenCV框架這個計算機視覺開發工具給自己的工作開疆拓土,乘風破浪,不斷前進。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章