Reputation:
I wrote some OpenCV code at xcode but when I compiled, 2 methods got linker fail: UIImageToMat
and MatToUIImage
I was using opencv2.framework (from opencv website, version 3.1 for iOS) and it was working fine, then I used cocoapods and integrated opencv 3.1.1 in my project and all the code worked the same, except for these 2 functions that gave me linker fail. I don't understand why they don't work, when I remove the #include "opencv2/imgcodecs/ios.h"
it says the functions don't exist (instead of linker fail).
Does anyone knows how to fix this? Thank you
Upvotes: 4
Views: 1743
Reputation:
I was able to fix it.
The OpenCV 3.1.1 in Cocoapods has the #include "opencv2/imgcodecs/ios.h"
but it doesn't contain the implementation (which was the reason why I got linker fail, as the header wasn't linking the functions to anywhere), just the declarations of these functions, like seen here: https://github.com/opencv/opencv/blob/master/modules/imgcodecs/include/opencv2/imgcodecs/ios.h
To solve it, in the class where I included this header file, I added the implementation of those 2 functions found here: https://github.com/opencv/opencv/blob/master/modules/imgcodecs/src/ios_conversions.mm
it worked just fine and I guess it's the simplest solution to get UIImageToMat
and MatToUIImage
working on OpenCV 3.1.1 (and 3.2 as well) pod.
Upvotes: 6