Я думаю, что самое разное, OpenCV 4.0
использует больше возможностей C ++ 11.Теперь cv::String == std::string
и cv::Ptr
- это тонкая оболочка поверх std::shared_ptr
.
Opencv 4.0 удаляет папку include/opencv
и сохраняет только include/opencv2
.Большая часть C API из OpenCV 1.x была удалена.Затронутые модули objdetect, photo, video, videoio, imgcodecs, calib3d
.Старое определение макроса или безымянное перечисление не предлагается, используйте именованное перечисление enum.
//! include/opencv2/imgcodes.hpp
namespace cv
{
//! @addtogroup imgcodecs
//! @{
//! Imread flags
enum ImreadModes {
IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped).
IMREAD_GRAYSCALE = 0, //!< If set, always convert image to the single channel grayscale image (codec internal conversion).
IMREAD_COLOR = 1, //!< If set, always convert image to the 3 channel BGR color image.
IMREAD_ANYDEPTH = 2, //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
IMREAD_ANYCOLOR = 4, //!< If set, the image is read in any possible color format.
IMREAD_LOAD_GDAL = 8, //!< If set, use the gdal driver for loading the image.
IMREAD_REDUCED_GRAYSCALE_2 = 16, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/2.
IMREAD_REDUCED_COLOR_2 = 17, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2.
IMREAD_REDUCED_GRAYSCALE_4 = 32, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/4.
IMREAD_REDUCED_COLOR_4 = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.
IMREAD_REDUCED_GRAYSCALE_8 = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8.
IMREAD_REDUCED_COLOR_8 = 65, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.
IMREAD_IGNORE_ORIENTATION = 128 //!< If set, do not rotate the image according to EXIF's orientation flag.
};
// ...
}
Например, при считывании изображения оно должно выглядеть примерно так:
cv::Mat img = cv::imread("test.png", cv::IMREAD_COLOR);
За исключением новых возможностей, большинство API C ++ сохраняют то же самое.Хотя самое большое различие, которое я нашел, это cv2.findContours
(в Python OpenCV
):
В OpenCV 3.4:
findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> image, contours, hierarchy
В OpenCV 4.0:
findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> contours, hierarchy
Альтернативой для работы с 2.x 、 3.x 、 4.x является:
cnts, hiers = cv2.findContours(...)[-2:]
Некоторые ссылки:
- Выпуск OpenCV
- OpenCV ChangeLog
- Введение в OpenCV
- Документация OpenCV
- Как использовать `cv2.findContours` в различных версиях OpenCV?
- OpenCV на Stackoverflow