Skip to content

Commit

Permalink
Dynamic build for Objective-C/Swift wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
komakai committed Jun 25, 2020
1 parent 085bd5f commit 59ba336
Show file tree
Hide file tree
Showing 57 changed files with 183 additions and 73 deletions.
2 changes: 1 addition & 1 deletion cmake/OpenCVGenInfoPlist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set(OPENCV_APPLE_BUNDLE_NAME "OpenCV")
set(OPENCV_APPLE_BUNDLE_ID "org.opencv")

if(IOS)
if (APPLE_FRAMEWORK AND BUILD_SHARED_LIBS)
if (APPLE_FRAMEWORK AND DYNAMIC_PLIST)
configure_file("${OpenCV_SOURCE_DIR}/platforms/ios/Info.Dynamic.plist.in"
"${CMAKE_BINARY_DIR}/ios/Info.plist")
else()
Expand Down
3 changes: 2 additions & 1 deletion modules/core/misc/objc/common/ByteVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
#ifdef __cplusplus
#import <vector>
#endif
#import "CVObjcUtil.h"

NS_ASSUME_NONNULL_BEGIN

/**
* Utility class to wrap a `std::vector<char>`
*/
@interface ByteVector : NSObject
CV_EXPORTS @interface ByteVector : NSObject

#pragma mark - Constructors

Expand Down
8 changes: 8 additions & 0 deletions modules/core/misc/objc/common/CVObjcUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ typedef union { float f; int32_t i; } V32;
#define DOUBLE_TO_BITS(x) ((V64){ .d = x }).l
#define FLOAT_TO_BITS(x) ((V32){ .f = x }).i

#ifndef CV_EXPORTS
#ifdef __cplusplus
#define CV_EXPORTS __attribute__ ((visibility ("default")))
#else
#define CV_EXPORTS
#endif
#endif

#ifdef __cplusplus
#import <vector>

Expand Down
4 changes: 3 additions & 1 deletion modules/core/misc/objc/common/Converters.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#else
#define CV_EXPORTS
#endif

#import <Foundation/Foundation.h>
Expand All @@ -27,7 +29,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface Converters : NSObject
CV_EXPORTS @interface Converters : NSObject

+ (Mat*)vector_Point_to_Mat:(NSArray<Point2i*>*)pts NS_SWIFT_NAME(vector_Point_to_Mat(_:));

Expand Down
4 changes: 3 additions & 1 deletion modules/core/misc/objc/common/CvType.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#ifdef __cplusplus
#import "opencv.hpp"
#else
#define CV_EXPORTS
#endif

#import <Foundation/Foundation.h>
Expand All @@ -15,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Utility functions for handling CvType values
*/
@interface CvType : NSObject
CV_EXPORTS @interface CvType : NSObject

#pragma mark - Type Utility functions

Expand Down
4 changes: 3 additions & 1 deletion modules/core/misc/objc/common/DMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#ifdef __cplusplus
#import "opencv.hpp"
#else
#define CV_EXPORTS
#endif

#import <Foundation/Foundation.h>
Expand All @@ -18,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
* Structure for matching: query descriptor index, train descriptor index, train
* image index and distance between descriptors.
*/
@interface DMatch : NSObject
CV_EXPORTS @interface DMatch : NSObject

/**
* Query descriptor index.
Expand Down
9 changes: 3 additions & 6 deletions modules/core/misc/objc/common/Double2.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#ifdef __cplusplus
#import "opencv.hpp"
#else
#define CV_EXPORTS
#endif

#import <Foundation/Foundation.h>
Expand All @@ -19,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Simple wrapper for a vector of two `double`
*/
@interface Double2 : NSObject
CV_EXPORTS @interface Double2 : NSObject

#pragma mark - Properties

Expand All @@ -33,11 +35,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property double v1;

/**
* Third vector element
*/
@property double v2;


#ifdef __cplusplus
/**
Expand Down
4 changes: 3 additions & 1 deletion modules/core/misc/objc/common/Double3.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#ifdef __cplusplus
#import "opencv.hpp"
#else
#define CV_EXPORTS
#endif

#import <Foundation/Foundation.h>
Expand All @@ -19,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Simple wrapper for a vector of three `double`
*/
@interface Double3 : NSObject
CV_EXPORTS @interface Double3 : NSObject

#pragma mark - Properties

Expand Down
3 changes: 2 additions & 1 deletion modules/core/misc/objc/common/DoubleVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
#ifdef __cplusplus
#import <vector>
#endif
#import "CVObjcUtil.h"

NS_ASSUME_NONNULL_BEGIN

/**
* Utility class to wrap a `std::vector<double>`
*/
@interface DoubleVector : NSObject
CV_EXPORTS @interface DoubleVector : NSObject

#pragma mark - Constructors

Expand Down
4 changes: 3 additions & 1 deletion modules/core/misc/objc/common/Float4.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#ifdef __cplusplus
#import "opencv.hpp"
#else
#define CV_EXPORTS
#endif

#import <Foundation/Foundation.h>
Expand All @@ -19,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Simple wrapper for a vector of four `float`
*/
@interface Float4 : NSObject
CV_EXPORTS @interface Float4 : NSObject

#pragma mark - Properties

Expand Down
4 changes: 3 additions & 1 deletion modules/core/misc/objc/common/Float6.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#ifdef __cplusplus
#import "opencv.hpp"
#else
#define CV_EXPORTS
#endif

#import <Foundation/Foundation.h>
Expand All @@ -19,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Simple wrapper for a vector of six `float`
*/
@interface Float6 : NSObject
CV_EXPORTS @interface Float6 : NSObject

#pragma mark - Properties

Expand Down
3 changes: 2 additions & 1 deletion modules/core/misc/objc/common/FloatVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
#ifdef __cplusplus
#import <vector>
#endif
#import "CVObjcUtil.h"

NS_ASSUME_NONNULL_BEGIN

/**
* Utility class to wrap a `std::vector<float>`
*/
@interface FloatVector : NSObject
CV_EXPORTS @interface FloatVector : NSObject

#pragma mark - Constructors

Expand Down
4 changes: 3 additions & 1 deletion modules/core/misc/objc/common/Int4.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#ifdef __cplusplus
#import "opencv.hpp"
#else
#define CV_EXPORTS
#endif

#import <Foundation/Foundation.h>
Expand All @@ -19,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Simple wrapper for a vector of four `int`
*/
@interface Int4 : NSObject
CV_EXPORTS @interface Int4 : NSObject

#pragma mark - Properties

Expand Down
3 changes: 2 additions & 1 deletion modules/core/misc/objc/common/IntVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
#ifdef __cplusplus
#import <vector>
#endif
#import "CVObjcUtil.h"

NS_ASSUME_NONNULL_BEGIN

/**
* Utility class to wrap a `std::vector<int>`
*/
@interface IntVector : NSObject
CV_EXPORTS @interface IntVector : NSObject

#pragma mark - Constructors

Expand Down
4 changes: 3 additions & 1 deletion modules/core/misc/objc/common/KeyPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#ifdef __cplusplus
#import "opencv.hpp"
#else
#define CV_EXPORTS
#endif

#import <Foundation/Foundation.h>
Expand All @@ -18,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Object representing a point feature found by one of many available keypoint detectors, such as Harris corner detector, FAST, StarDetector, SURF, SIFT etc.
*/
@interface KeyPoint : NSObject
CV_EXPORTS @interface KeyPoint : NSObject

#pragma mark - Properties

Expand Down
4 changes: 3 additions & 1 deletion modules/core/misc/objc/common/Mat.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#ifdef __cplusplus
#import "opencv.hpp"
#else
#define CV_EXPORTS
#endif

#import <Foundation/Foundation.h>
Expand All @@ -23,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* The class Mat represents an n-dimensional dense numerical single-channel or multi-channel array.
*/
@interface Mat : NSObject
CV_EXPORTS @interface Mat : NSObject

#ifdef __cplusplus
@property(readonly) cv::Ptr<cv::Mat> nativePtr;
Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfByte.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mat representation of an array of bytes
*/
@interface MatOfByte : Mat
CV_EXPORTS @interface MatOfByte : Mat

#pragma mark - Constructors

Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfDMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mat representation of an array of DMatch objects
*/
@interface MatOfDMatch : Mat
CV_EXPORTS @interface MatOfDMatch : Mat

#pragma mark - Constructors

Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfDouble.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mat representation of an array of doubles
*/
@interface MatOfDouble : Mat
CV_EXPORTS @interface MatOfDouble : Mat

#pragma mark - Constructors

Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfFloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mat representation of an array of floats
*/
@interface MatOfFloat : Mat
CV_EXPORTS @interface MatOfFloat : Mat

#ifdef __cplusplus
- (instancetype)initWithNativeMat:(cv::Mat*)nativeMat;
Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfFloat4.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mat representation of an array of vectors of four floats
*/
@interface MatOfFloat4 : Mat
CV_EXPORTS @interface MatOfFloat4 : Mat

#pragma mark - Constructors

Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfFloat6.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mat representation of an array of vectors of six floats
*/
@interface MatOfFloat6 : Mat
CV_EXPORTS @interface MatOfFloat6 : Mat

#pragma mark - Constructors

Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mat representation of an array of ints
*/
@interface MatOfInt : Mat
CV_EXPORTS @interface MatOfInt : Mat

#pragma mark - Constructors

Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfInt4.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mat representation of an array of vectors of four ints
*/
@interface MatOfInt4 : Mat
CV_EXPORTS @interface MatOfInt4 : Mat

#pragma mark - Constructors

Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfKeyPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mat representation of an array of KeyPoint objects
*/
@interface MatOfKeyPoint : Mat
CV_EXPORTS @interface MatOfKeyPoint : Mat

#pragma mark - Constructors

Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfPoint2f.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mat representation of an array of Point2f objects
*/
@interface MatOfPoint2f : Mat
CV_EXPORTS @interface MatOfPoint2f : Mat

#pragma mark - Constructors

Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfPoint2i.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
* Mat representation of an array of Point objects
*/
NS_SWIFT_NAME(MatOfPoint)
@interface MatOfPoint2i : Mat
CV_EXPORTS @interface MatOfPoint2i : Mat

#pragma mark - Constructors

Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfPoint3.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mat representation of an array of Point3i objects
*/
@interface MatOfPoint3 : Mat
CV_EXPORTS @interface MatOfPoint3 : Mat

#pragma mark - Constructors

Expand Down
2 changes: 1 addition & 1 deletion modules/core/misc/objc/common/MatOfPoint3f.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mat representation of an array of Point3f objects
*/
@interface MatOfPoint3f : Mat
CV_EXPORTS @interface MatOfPoint3f : Mat

#pragma mark - Constructors

Expand Down
Loading

0 comments on commit 59ba336

Please sign in to comment.