Skip to content

Commit

Permalink
More OpenCV 4 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
frankier committed May 19, 2020
1 parent 2f3a0ba commit 8f90b2b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/caffe/layers/video_data_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ void VideoDataLayer<Ftype, Btype>::DataLayerSetUp(
if (!cap_.open(video_file)) {
LOG(FATAL) << "Failed to open video: " << video_file;
}
total_frames_ = cap_.get(CV_CAP_PROP_FRAME_COUNT);
total_frames_ = cap_.get(cv::CAP_PROP_FRAME_COUNT);
processed_frames_ = 0;
// Read image to infer shape.
cap_ >> cv_img;
// Set index back to the first frame.
cap_.set(CV_CAP_PROP_POS_FRAMES, 0);
cap_.set(cv::CAP_PROP_POS_FRAMES, 0);
} else {
LOG(FATAL) << "Unknow video type!";
}
Expand Down
6 changes: 3 additions & 3 deletions src/caffe/util/bbox_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,7 @@ void VisualizeBBox(const vector<cv::Mat>& images, const Blob* detections,
&baseline);
cv::rectangle(image, cv::Point(0, 0),
cv::Point(text.width, text.height + baseline),
CV_RGB(255, 255, 255), CV_FILLED);
CV_RGB(255, 255, 255), cv::FILLED);
cv::putText(image, buffer, cv::Point(0, text.height + baseline / 2.),
fontface, scale, CV_RGB(0, 0, 0), thickness, 8);
// Draw bboxes.
Expand All @@ -2262,7 +2262,7 @@ void VisualizeBBox(const vector<cv::Mat>& images, const Blob* detections,
cv::rectangle(
image, bottom_left_pt + cv::Point(0, 0),
bottom_left_pt + cv::Point(text.width, -text.height-baseline),
color, CV_FILLED);
color, cv::FILLED);
cv::putText(image, buffer, bottom_left_pt - cv::Point(0, baseline),
fontface, scale, CV_RGB(0, 0, 0), thickness, 8);
}
Expand All @@ -2271,7 +2271,7 @@ void VisualizeBBox(const vector<cv::Mat>& images, const Blob* detections,
if (!save_file.empty()) {
if (!cap_out.isOpened()) {
cv::Size size(image.size().width, image.size().height);
cv::VideoWriter outputVideo(save_file, CV_FOURCC('D', 'I', 'V', 'X'),
cv::VideoWriter outputVideo(save_file, cv::VideoWriter::fourcc('D', 'I', 'V', 'X'),
30, size, true);
cap_out = outputVideo;
}
Expand Down
6 changes: 3 additions & 3 deletions src/caffe/util/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ cv::Mat ReadImageToCVMat(const string& filename,
}
if (cv_img_origin.data) {
if (is_color && cv_img_origin.channels() < 3) {
cv::cvtColor(cv_img_origin, cv_img, CV_GRAY2RGB);
cv::cvtColor(cv_img_origin, cv_img, cv::COLOR_GRAY2RGB);
}
if (short_side > 0) {
if (cv_img_origin.rows > cv_img_origin.cols) {
Expand All @@ -212,10 +212,10 @@ cv::Mat ReadImageToCVMat(const string& filename,
}
cv::Size sz(width, height);
if (cv_img.data) {
cv::resize(cv_img, cv_img_origin, sz, 0., 0., CV_INTER_LINEAR);
cv::resize(cv_img, cv_img_origin, sz, 0., 0., cv::INTER_LINEAR);
return cv_img_origin;
}
cv::resize(cv_img_origin, cv_img, sz, 0., 0., CV_INTER_LINEAR);
cv::resize(cv_img_origin, cv_img, sz, 0., 0., cv::INTER_LINEAR);
} else {
LOG(ERROR) << "Could not decode file " << filename;
}
Expand Down

0 comments on commit 8f90b2b

Please sign in to comment.