Sorry for being idiot... do you mean that I have to move "#include opencv2/core.hpp" line to optim.hpp header?