From 6be24be9ff7c7100e08971ca2031d4b720a139ac Mon Sep 17 00:00:00 2001 From: Leo Mao Date: Sat, 10 Aug 2019 14:27:38 -0700 Subject: [PATCH] OpenCV 4 compatibility fix for caffe2/video (#24143) Summary: Trying to fix https://github.com/pytorch/pytorch/issues/24073 as in https://github.com/pytorch/pytorch/issues/9966. Make caffe2 compile with OpenCV 4. Pull Request resolved: https://github.com/pytorch/pytorch/pull/24143 Differential Revision: D16753624 Pulled By: ezyang fbshipit-source-id: 524eac10a9285e0c0a803a8566917aa95aa0662c --- caffe2/video/video_input_op.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/caffe2/video/video_input_op.h b/caffe2/video/video_input_op.h index b047eb68326..85046276115 100644 --- a/caffe2/video/video_input_op.h +++ b/caffe2/video/video_input_op.h @@ -573,7 +573,7 @@ bool VideoInputOp::GetImageAndLabelsFromDBValue( &encoded_size, CV_8UC1, const_cast(encoded_image_str.data())), - CV_LOAD_IMAGE_COLOR); + cv::IMREAD_COLOR); if (src.rows == 0 or src.cols == 0) { throw std::runtime_error("Both rows and cols are 0 for image"); } @@ -606,13 +606,13 @@ bool VideoInputOp::GetImageAndLabelsFromDBValue( img = scaled_img; } else { cv::cvtColor( - scaled_img, img, (channels_rgb_ == 1) ? CV_BGR2GRAY : CV_GRAY2BGR); + scaled_img, img, (channels_rgb_ == 1) ? cv::COLOR_BGR2GRAY : cv::COLOR_GRAY2BGR); } cv::Mat rgb_img; if (channels_rgb_ == 1) { - cv::cvtColor(img, rgb_img, CV_BGR2RGB); + cv::cvtColor(img, rgb_img, cv::COLOR_BGR2RGB); } else { rgb_img = img; }