Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for OpenCV v4.0 compatibility #306

Merged
merged 2 commits into from
Jan 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_<int>(0, 0, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason you're using int specifically rather than double, i.e. cv::Scalar? I assume there is, but I'm just curious.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, no. I think this should just be cv::Scalar 😬

Fixed in 2877adb

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