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
This commit is contained in:
Leo Mao 2019-08-10 14:27:38 -07:00 committed by Facebook Github Bot
parent 365b3ff56e
commit 6be24be9ff

View File

@ -573,7 +573,7 @@ bool VideoInputOp<Context>::GetImageAndLabelsFromDBValue(
&encoded_size,
CV_8UC1,
const_cast<char*>(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<Context>::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;
}