E0035 This header with legacy C API declarations has been removed from OpenCV

I ported my OCV 2.4 C-API code using lpImage to OCV 3.4 C++ using Mat and got everything working. Now I am trying to do the final port to OCV 4.5 and have cleared all VS2017 compiler errors except for

Error (active) E0035 #error directive: “This header with legacy C API declarations has been removed from OpenCV.
Legacy constants are available from legacy/constants_c.h file.”

I included the opencv2\imgcodecs\legacy\constants_c.h into the project where needed and that didn’t seem to change anything.

Any ideas. I see reference to this when OCV 4.0 first came out but no other references.

I asked this question too fast. I removed the include for opencv2\imgcodecs\imgcodecs_c.h and that pointed to a single like of C-API cvLoadImage. I corrected that line and everything compiled.

So the solution was not to include the opencv2\imgcodecs\legacy\constants_c.h but to remove the include for opencv2\imgcodecs\imgcodecs_c.h.

This may help someone else. It’s always something.

1 Like