Attention! This forum will be made read-only by Dec-20. Please migrate to Most of existing active users should've received invitation by e-mail.
Ask Your Question

Relating flags and numbers for functions like imread or namedWindow.

asked 2017-08-23 10:30:38 -0500

skr_robo gravatar image

updated 2017-08-23 11:49:25 -0500

I saw an example for the usage of namedWindow as shown below:

namedWindow("edges", 1)

I believe that the number 1 is related to a flag such as WINDOW_AUTOSIZE. However, I am not able to find any clear documentation which says what number relates to what flag. In the case of imread, the documentation states:

>0 Return a 3-channel color image.

=0 Return a grayscale image.

<0 Return the loaded image as is (with alpha channel)

For namedWindow, I found that this link has a section called Enumerations which had the following content:

enum    cv::WindowFlags { 
  cv::WINDOW_NORMAL = 0x00000000, 
  cv::WINDOW_AUTOSIZE = 0x00000001, 
  cv::WINDOW_OPENGL = 0x00001000, 
  cv::WINDOW_FREERATIO = 0x00000100, 
  cv::WINDOW_KEEPRATIO = 0x00000000, 
  cv::WINDOW_GUI_EXPANDED =0x00000000, 
  cv::WINDOW_GUI_NORMAL = 0x00000010 
    Flags for cv::namedWindow.

However, I am not sure if this is what I am looking for because some of the values on RHS are not unique. So, how do we differentiate between them (for example cv::WINDOW_NORMAL and cv::WINDOW_KEEPRATIO)? Is there any other place where I can this information for namedWindow and other functions?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-08-23 11:01:19 -0500

LBerger gravatar image

updated 2017-08-23 12:00:02 -0500

Some people use values instead of constant. IMHO it's bad usage. You should use constant Like cv::WINDOW_NORMAL or IMREAD_UNCHANGED

cv::WINDOW_NORMAL and cv::WINDOW_KEEPRATIO yes same value but a window with attribute WINDOW_NORMAL is a windows with a fixed ratio because free ratio bit is set to 0.

you can try some combinations to understand well

    Mat test(2400, 2400, CV_8UC3, Scalar(120, 120, 120));
    circle(test, Point(1200, 1200), 900, Scalar(0, 0, 255), 35);
    namedWindow("Test1", WINDOW_AUTOSIZE);
    namedWindow("Test", WINDOW_NORMAL);
    namedWindow("Test0", WINDOW_NORMAL & WINDOW_KEEPRATIO);
    imshow("Test", test);
    imshow("Test0", test);
    imshow("Test1", test);
    imshow("Test2", test);
edit flag offensive delete link more



documentation is clear please read carefully. cv::namedWindow(), cv::WindowFlags, cv::WindowPropertyFlags

sturkmen gravatar imagesturkmen ( 2017-08-23 11:23:18 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-08-23 10:30:38 -0500

Seen: 642 times

Last updated: Aug 23 '17