# Module directory structure

I was wondering why, while most headers are in include/opencv2/<module>/ or include/opencv2/<module>/<hal|utils|detail>, cuda and opencl headers are expected to be in src/cuda and src/opencl respectively. Furthermore both the .cu sources and the .hpp headers for cuda are expected to be in src/cuda, which doesn't necessarily seem like a very good directory structure.

Additionally some of the headers that are cuda related may need to be included by projects using the module, but with those headers being in src/cuda rather than include/opencv2/module/cuda, one would need to add that path explicitly to be able to include those headers (unless I am missing something and src/cuda headers are being added somehow.

edit retag close merge delete

hmm, that's a problem. src/cuda might no more exist after the installation, you cannot rely on that for user-related code.
i guess, you need to wrap the needed functionality into some interface, a public api, (like it is done e.g. in cudastereo), which then has to go into include/opencv2/mymodule
@berak Good point on src/cuda not necessarily being installed. There are ways around the problems, but it just seemed more straightforward and easier to understand structure-wise if the files were in include/opencv2/<module>/cuda, I was just wondering if there is a good reason behind this