Ask Your Question
1

How do I know which header file I should use for my OpenCV C++ program?

asked 2018-12-22 10:26:24 -0600

Dear OpenCV community,

This might be a noob question. I have been an OpenCV Python user previously. Now I am switching to C++. I wonder how should I determine which header files I should use for my program. For example, I want to use the function "imread", which header files I should include in my program? I tried to look up on https://docs.opencv.org/master/ but found no clue. Thank you.

Best regards,

Lei

edit retag flag offensive close merge delete

Comments

there is a (working !) search box on the docs page (top right). try it !

(it will show you the module, your function is in)

berak gravatar imageberak ( 2018-12-22 21:02:41 -0600 )edit

Sorry, I tried but I think I did not get what you mentioned. Say I put "imread" in the search box, then click on "imread" in the drop-down list. I don't see any word "imgcodecs" there.

Lei Mao gravatar imageLei Mao ( 2018-12-23 09:53:49 -0600 )edit

group__imgcodecs (in the url) should give it away, already, no ?

berak gravatar imageberak ( 2018-12-23 09:58:08 -0600 )edit
1

Orz. It could have been more standing out to the users. Thank you anyway.

Lei Mao gravatar imageLei Mao ( 2018-12-23 09:59:11 -0600 )edit

ofc. you're right ;)

berak gravatar imageberak ( 2018-12-23 10:04:51 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-12-22 11:08:43 -0600

LBerger gravatar image

updated 2018-12-22 11:39:28 -0600

First take a look at "OpenCV modules" in Documentation :

header for core. Core functionality module is # include<opencv2/core.hpp>

header for imgproc. Image Processing module is # include<opencv2/imgproc.hpp>

header for highgui. High-level GUI module is #include <opencv2/highgui.hpp>

...

and so on.

Then read for example documentation of function findcontours It is in imgproc module (read link or at the beginning of the page it is written Image Processing)

or you can use only #include <opencv2/opencv.hpp> all module in opencv will be included and opencv only.

For opencv_contrib apply first recipe

edit flag offensive delete link more

Comments

Thank you. I got used to the documentation style that CPP references uses. For example, https://en.cppreference.com/w/cpp/io/..., for each function, it specifically tells you where you could find the declaration of the function. It will be beneficial for Googlers if we have this :)

Lei Mao gravatar imageLei Mao ( 2018-12-22 11:57:54 -0600 )edit

you can create a new issue if you believe this is a feature request

sturkmen gravatar imagesturkmen ( 2018-12-22 12:12:41 -0600 )edit

Well, it's personal preference. Somebody may like it somebody may not :) I am not sure I am professional enough in the OpenCV community to request certain features.

Lei Mao gravatar imageLei Mao ( 2018-12-22 12:15:11 -0600 )edit
1

"I am a perfectionist. I want to solve the problems in my hands in perfect ways, which is, however, not achievable in many situations." i liked it. why not.i think the documentation needs many improvements.

sturkmen gravatar imagesturkmen ( 2018-12-22 12:23:53 -0600 )edit

Haha. Thank you. I will propose it on GitHub issues soon.

Lei Mao gravatar imageLei Mao ( 2018-12-22 12:25:18 -0600 )edit
1

OpenCV 4.0.1 released today. I suggest you to build it with examples (set BUILD_EXAMPLES to build all examples)

sturkmen gravatar imagesturkmen ( 2018-12-22 12:51:02 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-12-22 10:26:24 -0600

Seen: 4,743 times

Last updated: Dec 22 '18