Skip to content

Commit

Permalink
Update for OpenCV v4.0 compatibility (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobperron committed Jan 11, 2019
1 parent bc20cd4 commit 3dca291
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions image_tools/src/burger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Burger::Burger()
std::vector<uint8_t> burger_png;
burger_png.resize(burger_size);
decode_base64(BURGER, burger_png);
burger_template = cv::imdecode(burger_png, CV_LOAD_IMAGE_COLOR);
burger_template = cv::imdecode(burger_png, cv::ImreadModes::IMREAD_COLOR);
cv::floodFill(burger_template, cv::Point(1, 1), CV_RGB(1, 1, 1));
cv::compare(burger_template, 1, burger_mask, cv::CMP_NE);
#ifndef _WIN32
Expand Down Expand Up @@ -124,7 +124,7 @@ cv::Mat & Burger::render_burger(size_t width, size_t height)
}
burger_buf = cv::Mat(height_i, width_i, CV_8UC3);
}
burger_buf = cvScalar(0, 0, 0);
burger_buf = cv::Scalar(0, 0, 0);
for (int b = 0; b < static_cast<int>(x.size()); b++) {
burger_template.copyTo(burger_buf(cv::Rect(
x[b],
Expand Down
8 changes: 4 additions & 4 deletions image_tools/src/cam2image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ int main(int argc, char * argv[])
cap.open(0);

// Set the width and height based on command line arguments.
cap.set(CV_CAP_PROP_FRAME_WIDTH, static_cast<double>(width));
cap.set(CV_CAP_PROP_FRAME_HEIGHT, static_cast<double>(height));
cap.set(cv::CAP_PROP_FRAME_WIDTH, static_cast<double>(width));
cap.set(cv::CAP_PROP_FRAME_HEIGHT, static_cast<double>(height));
if (!cap.isOpened()) {
RCLCPP_ERROR(node_logger, "Could not open video stream");
return 1;
Expand Down Expand Up @@ -195,9 +195,9 @@ int main(int argc, char * argv[])
if (show_camera) {
// NOTE(esteve): Use C version of cvShowImage to avoid this on Windows:
// http://stackoverflow.com/questions/20854682/opencv-multiple-unwanted-window-with-garbage-name
CvMat cvframe = frame;
cv::Mat cvframe = frame;
// Show the image in a window called "cam2image".
cvShowImage("cam2image", &cvframe);
cv::imshow("cam2image", cvframe);
// Draw the image to the screen and wait 1 millisecond.
cv::waitKey(1);
}
Expand Down
6 changes: 3 additions & 3 deletions image_tools/src/showimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ void show_image(
cv::cvtColor(frame, frame, cv::COLOR_RGB2BGR);
}

CvMat cvframe = frame;
cv::Mat cvframe = frame;

// NOTE(esteve): Use C version of cvShowImage to avoid this on Windows:
// http://stackoverflow.com/q/20854682
// Show the image in a window called "showimage".
cvShowImage("showimage", &cvframe);
cv::imshow("showimage", cvframe);
// Draw the screen and wait for 1 millisecond.
cv::waitKey(1);
}
Expand Down Expand Up @@ -112,7 +112,7 @@ int main(int argc, char * argv[])
if (show_camera) {
std::cerr << "Creating window" << std::endl;
// Initialize an OpenCV named window called "showimage".
cvNamedWindow("showimage", CV_WINDOW_AUTOSIZE);
cv::namedWindow("showimage", cv::WINDOW_AUTOSIZE);
cv::waitKey(1);
std::cerr << "After creating window" << std::endl;
}
Expand Down

0 comments on commit 3dca291

Please sign in to comment.