OpenCV stands for Open Source Computer Vision Library, which is a cross-platform Computer Vision Library.

OpenCV can be referenced in the APP’s main project as follows:

#import <opencv2/opencv.hpp>
#import <opencv2/imgproc/types_c.h>
#import <opencv2/imgcodecs/ios.h>
#import <opencv2/videoio/cap_ios.h>
#import <opencv2/highgui/highgui.hpp>
#import <opencv2/imgproc/imgproc.hpp>
#import <opencv2/core/core.hpp>
#import <opencv2/objdetect/objdetect.hpp>
Copy the code

#import

will cause a compilation error:

#if defined(NO)
warning Detected Apple 'NO' macro definition, it can cause build conflicts. Please, include this header before any Apple headers.

#endif
Copy the code

This is fine if you use the following method

#if __cplusplus && __has_include(<opencv2/imgcodecs/ios.h>)
#import <opencv2/imgproc/types_c.h>
#import <opencv2/core/core.hpp>
#import <opencv2/objdetect/objdetect.hpp>
#import <opencv2/imgcodecs/ios.h>
#import <opencv2/core.hpp>
#import <opencv2/highgui.hpp>
#import <opencv2/imgproc.hpp>

using namespace cv;
using namespace std;

#endif
Copy the code

reference

How to use OpenCV in iOS projects