-
Notifications
You must be signed in to change notification settings - Fork 330
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 intra_process_demo for OpenCV 4 compatibility #307
Conversation
Xenial (which is using OpenCV from upstream 2.4.9) appears to be missing some of the newly used API. |
@nuclearsandwich @wjwwood Thoughts on adding pre-processor checks? Specifically needed in three different places: image_tools/src/burger.cpp
@@ -82,7 +82,11 @@ Burger::Burger()
std::vector<uint8_t> burger_png;
burger_png.resize(burger_size);
decode_base64(BURGER, burger_png);
+#if CV_MAJOR_VERSION < 3
+ burger_template = cv::imdecode(burger_png, CV_LOAD_IMAGE_COLOR);
+#else
burger_template = cv::imdecode(burger_png, cv::ImreadModes::IMREAD_COLOR);
+#endif
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
image_tools/src/cam2image.cpp
@@ -156,8 +156,13 @@ int main(int argc, char * argv[])
cap.open(0);
// Set the width and height based on command line arguments.
+#if CV_MAJOR_VERSION < 3
+ cap.set(CV_CAP_PROP_FRAME_WIDTH, static_cast<double>(width));
+ cap.set(CV_CAP_PROP_FRAME_HEIGHT, static_cast<double>(height));
+#else
cap.set(cv::CAP_PROP_FRAME_WIDTH, static_cast<double>(width));
cap.set(cv::CAP_PROP_FRAME_HEIGHT, static_cast<double>(height));
+#endif
if (!cap.isOpened()) {
RCLCPP_ERROR(node_logger, "Could not open video stream");
return 1;
intra_process_demo/include/image_pipeline/camera_node.hpp
@@ -38,8 +38,13 @@ public:
{
// Initialize OpenCV
cap_.open(device);
+#if CV_MAJOR_VERSION < 3
+ cap_.set(CV_CAP_PROP_FRAME_WIDTH, static_cast<double>(width));
+ cap_.set(CV_CAP_PROP_FRAME_HEIGHT, static_cast<double>(height));
+#else
cap_.set(cv::CAP_PROP_FRAME_WIDTH, static_cast<double>(width));
cap_.set(cv::CAP_PROP_FRAME_HEIGHT, static_cast<double>(height));
+#endif
if (!cap_.isOpened()) {
throw std::runtime_error("Could not open video stream!");
} |
That's unfortunate, but perhaps the best thing we can do for now. We can have a TODO/issue to remove that when we drop support for Xenial. When are we doing that btw, isn't the case for Dashing? |
I'm not sure what the timeline is, but if we're dropping Xenial support in Dashing then is it an option to create a |
I think the plan is to pitch dropping Xenial for Dashing to the technical steering committee at the next meeting. It is certainly what I advocate. |
I don't think that gains us much because we're trying to support Xenial with OpenCV 2 and MacOS with OpenCV4 within Crystal. so whether we add this logic to master or create a separate Crystal branch doesn't obviate the need for it, and since we haven't disabled Xenial jobs yet (and Xenial may remain supported Dashing possibly) omitting the logic on master would break the Xenial jobs while that all shakes out. |
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
The test failures on Xenial appear irrelevant to this PR. |
The pyqt issue has been long outstanding. I haven't seen this tlsf failure before in recent builds. |
Worth investigating, but I don't see how these changes could cause the issue in tlsf. |
I can reproduce the tlsf failure without this change. New issue opened: ros2/realtime_support#69 |
Follow up from #306. Forget to update the intra_proces_demo package...