Ask Your Question
0

Include folder structure: opencv and/or opencv2?

asked 2012-11-21 04:46:11 -0600

ozymandias gravatar image

updated 2012-11-21 04:47:33 -0600

Hello all,

Could someone explain why OpenCV has two different folders in the include directory, please?

I'm trying to build a project, and am creating a local (to that project) include folder. The OpenCV file structure looks as though it has been designed purposefully. My instinct is to drag'n'drop the contents of include/opencv and include/opencv2 into one folder in my project, but am a little worried that this might have unintended bad consequences...

edit: I know that my project will definitely use cv/h and highgui.h so must have some files from both folders...

Thanks for reading, and many thanks if you can help!

Zadacka

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
5

answered 2012-11-21 08:16:09 -0600

Hi Zadacka

As far as I know the folder opencv contains the header files for old fashion C style opencv functions and the folder opencv2 contains the headers for the new and more flexible C++ interface (please someone correct me if this is not accurate).

This is just my opinion, but I would not consider a good practice to drag and drop include files into your project unless for very specific reasons. Have you considered using CMake to automatically generate your project? This tutorials might help you.

Best regards

edit flag offensive delete link more

Comments

1

Hi Martin,

Thanks muchly for your help!

The C function / C++ function schism sounds like a plausible explanation for the file structure. Unless anyone proposes a different explanation, then I'll mark your answer as 'correct' :)

Regarding dragging and dropping files... I am trying to make use of some opencv functions to get / process images from a webcam. The bulk of the project will be my own code. I've made a folder called "lib" in my solution directory and copied relevant opencv (and other 3rd party) libraries into that. This copying was the 'drag and drop' that I alluded to. The actual include is done properly within the VS2010 options.

Would you still use CMake, in this context? I've previously used it to build openCV, but am not sure how to use it to manage include files..

ozymandias gravatar imageozymandias ( 2012-11-21 10:31:53 -0600 )edit
1

Hi Zadacka, In the end the choice on how to build your projects is entirely yours, if you are comfortable with that approach and you don't foresee any problems with it then it is OK. Personally, always use CMake to generate my projects because it is very flexible and portable. With a CMakeLists.txt as simple as this:

cmake_minimum_required( VERSION 2.6 FATAL_ERROR)

project ( my_project )

find_package(OpenCV 2.4 REQUIRED)

find_package(OtherLibrary REQUIRED)

add_executable (my_executable my_source1.cpp my_source2.cpp ...) target_link_libraries(my_executable ${OpenCV_LIBS} ${OtherLibrary_LIBS})

You can generate project files for VS2012, Eclipse, Unix Makefiles, etc... But, as I said, this is just a suggestion, how you build your projects is entirely your call.

Martin Peris gravatar imageMartin Peris ( 2012-11-21 19:28:13 -0600 )edit

Question Tools

Stats

Asked: 2012-11-21 04:46:11 -0600

Seen: 16,474 times

Last updated: Nov 21 '12