ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi,

That line simply defines a string called OPENCV_WINDOW with value "Image window". It is just the name of the OpenCV window that is opened in line 26.

cv::namedWindow(OPENCV_WINDOW);

If you look at the OpenCV documentation here, you can understand what the namedWindow() method does. To quote it, "The function namedWindow creates a window that can be used as a placeholder for images and trackbars. Created windows are referred to by their names."

So you can use the string "Image window" (the value of OPENCV_WINDOW string variable) to refer to this window. Eg : Line 31

cv::destroyWindow(OPENCV_WINDOW);

This line is used to close the window opened in line 26.

As for a good tutorial to subscribe to a topic, once you identify the topic you need to subscribe to, look at the roscpp documentation on subscribers and publishers here.

Hi,

That line simply defines a string called OPENCV_WINDOW with value "Image window". It is just the name of the OpenCV window that is opened in line 26.

cv::namedWindow(OPENCV_WINDOW);

If you look at the OpenCV documentation here, you can understand what the namedWindow() method does. To quote it, "The function namedWindow creates a window that can be used as a placeholder for images and trackbars. Created windows are referred to by their names."

So you can use the string "Image window" (the value of OPENCV_WINDOW string variable) to refer to this window. Eg : Line 31

cv::destroyWindow(OPENCV_WINDOW);

This line is used to close the window opened in line 26.

You don't HAVE TO declare a string variable. You can simply open and close the window like this.

cv::namedWindow("Image window");

cv::destroyWindow("Image window");

However, it is a good practice to define these kind of values at the top of your code so that if you ever want to change it to something else (say, "Image window 1"), you don't have to comb through your code looking for all appearances of it. If it were me, I would have set it as a constant string so that I (or anyone else) accidentally (or intentionally) change the value somewhere else (can lead to very hard to debug bugs).

As for a good tutorial to subscribe to a topic, once you identify the topic you need to subscribe to, look at the roscpp documentation on subscribers and publishers here.

.

Hi,

That line simply defines a string called OPENCV_WINDOW with value "Image window". It is just the name of the OpenCV window that is opened in line 26.

cv::namedWindow(OPENCV_WINDOW);

If you look at the OpenCV documentation here, you can understand what the namedWindow() method does. To quote it, "The function namedWindow creates a window that can be used as a placeholder for images and trackbars. Created windows are referred to by their names."

So you can use the string "Image window" (the value of OPENCV_WINDOW string variable) to refer to this window. Eg : Line 31

cv::destroyWindow(OPENCV_WINDOW);

This line is used to close the window opened in line 26.

You don't HAVE TO declare a string variable. You can simply open and close the window like this.

cv::namedWindow("Image window");

cv::destroyWindow("Image window");

However, it is a good practice to define these kind of values at the top of your code so that if you ever want to change it to something else (say, "Image window 1"), you don't have to comb through your code looking for all appearances of it. If it were me, I would have set it as a constant string so that I (or anyone else) accidentally (or intentionally) can't change the value somewhere else (can lead to very hard to debug bugs).

As for a good tutorial to subscribe to a topic, once you identify the topic you need to subscribe to, look at the roscpp documentation on subscribers and publishers here.