DNN namespace compatibility

Hello,

I have a question regarding the DNN module namespace.

From my understanding, changes in minor version number and patch level version number indicate that the code and the library are backward compatible.

I modified the OPENCV_DLLVERSION, so that the libaries only having the OPENCV_VERSION_MAJOR number in their name. With this modification, I can run projects compiled with older OpenCV versions also with a newer version of the OpenCV libraries.

For other OpenCV modules like Core or Imgproc it’s working and they are backward compatible

But using the DNN module, I ran into some problems. I looked into the DNN code and saw, that there is a namespace with an individual name for every version of OpenCV - even if only patch level number increased (OPENCV_DNN_API_VERSION).

E.g. at OpenCV version 4.5.1 the DNN module has the namespace “dnn4_v20201117”, but at version 4.5.2 it is “dnn4_v20210301”. Therefore these versions of the DNN module aren’t compatible.

Is there a specific reason for this concept? Are there some incompatibilities between any DNN version?

For testing I renamed the namespace of the DNN module of version 4.5.1 to match the namespace of version 4.0.1 and compiled OpenCV. Then I took a simple DNN test project compiled with OpenCV version 4.0.1 and run it with the newly compiled OpenCV 4.5.1 libraries and it worked.

So would I run into trouble removing the version/date number from the DNN namespace?

Thank you very much!

yea, there are incompatibilities, that’ s why this namespace acts as a guard against mixing different versions :wink:

there’s like 3 years of development between those, and you expect it to work ?

1 Like

Hi, thank you for the quick reply.

So, even if only the patch level of OpenCV changes, you can’t expect OpenCV (or the DNN module) to be backward compatible?
Does this behavior only occur at the DNN module or does it exits at other modules as well?

I didn’t expect it to work, I just tested it :wink:.
For the simple OpenCV DNN tutorial it worked.

But I understand from your answer that I can’t easily assume OpenCV is backward compatible when a new version of OpenCV is released with a new minor or patch level version.

well, there are abi (binary) compatibility checks for major versions , so the api stays stable.
however we shouldn’t actually encourage you to break the versioning, right ? :slight_smile: