Add Objective-C/Swift wrappers for opencv_contrib modules
This commit is contained in:
parent
af9ee90091
commit
4cf76754d3
@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"func_arg_fix" : {
|
"func_arg_fix" : {
|
||||||
"findCirclesGrid" : { "blobDetector" : {"defval" : "cv::SimpleBlobDetector::create()"} }
|
"Calib3d" : {
|
||||||
|
"findCirclesGrid" : { "blobDetector" : {"defval" : "cv::SimpleBlobDetector::create()"} }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
-(NSArray<NSNumber*>*)get {
|
-(NSArray<NSNumber*>*)get {
|
||||||
return @[[NSNumber numberWithFloat:native[0]], [NSNumber numberWithFloat:native[1]], [NSNumber numberWithFloat:native[2]], [NSNumber numberWithFloat:native[3]]];
|
return @[[NSNumber numberWithFloat:native[0]], [NSNumber numberWithFloat:native[1]], [NSNumber numberWithFloat:native[2]], [NSNumber numberWithFloat:native[3]], [NSNumber numberWithFloat:native[4]], [NSNumber numberWithFloat:native[5]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isEqual:(id)other {
|
- (BOOL)isEqual:(id)other {
|
||||||
|
|||||||
@ -39,6 +39,11 @@ CV_EXPORTS @interface Point3d : NSObject
|
|||||||
- (instancetype)initWithPoint:(Point2d*)point;
|
- (instancetype)initWithPoint:(Point2d*)point;
|
||||||
- (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
|
- (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
+ (instancetype)fromNative:(cv::Point3d&)point;
|
||||||
|
- (void)update:(cv::Point3d&)point;
|
||||||
|
#endif
|
||||||
|
|
||||||
# pragma mark - Methods
|
# pragma mark - Methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -65,6 +65,16 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (instancetype)fromNative:(cv::Point3d&)point {
|
||||||
|
return [[Point3d alloc] initWithX:point.x y:point.y z:point.z];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)update:(cv::Point3d&)point {
|
||||||
|
self.x = point.x;
|
||||||
|
self.y = point.y;
|
||||||
|
self.z = point.z;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)set:(NSArray<NSNumber*>*)vals {
|
- (void)set:(NSArray<NSNumber*>*)vals {
|
||||||
self.x = (vals != nil && vals.count > 0) ? vals[0].doubleValue : 0.0;
|
self.x = (vals != nil && vals.count > 0) ? vals[0].doubleValue : 0.0;
|
||||||
self.y = (vals != nil && vals.count > 1) ? vals[1].doubleValue : 0.0;
|
self.y = (vals != nil && vals.count > 1) ? vals[1].doubleValue : 0.0;
|
||||||
|
|||||||
@ -39,6 +39,10 @@ CV_EXPORTS @interface Point3f : NSObject
|
|||||||
- (instancetype)initWithPoint:(Point2f*)point;
|
- (instancetype)initWithPoint:(Point2f*)point;
|
||||||
- (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
|
- (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
+ (instancetype)fromNative:(cv::Point3f&)point;
|
||||||
|
- (void)update:(cv::Point3f&)point;
|
||||||
|
#endif
|
||||||
|
|
||||||
# pragma mark - Methods
|
# pragma mark - Methods
|
||||||
|
|
||||||
|
|||||||
@ -65,6 +65,16 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (instancetype)fromNative:(cv::Point3f&)point {
|
||||||
|
return [[Point3f alloc] initWithX:point.x y:point.y z:point.z];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)update:(cv::Point3f&)point {
|
||||||
|
self.x = point.x;
|
||||||
|
self.y = point.y;
|
||||||
|
self.z = point.z;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)set:(NSArray<NSNumber*>*)vals {
|
- (void)set:(NSArray<NSNumber*>*)vals {
|
||||||
self.x = (vals != nil && vals.count > 0) ? vals[0].floatValue : 0.0;
|
self.x = (vals != nil && vals.count > 0) ? vals[0].floatValue : 0.0;
|
||||||
self.y = (vals != nil && vals.count > 1) ? vals[1].floatValue : 0.0;
|
self.y = (vals != nil && vals.count > 1) ? vals[1].floatValue : 0.0;
|
||||||
|
|||||||
@ -39,6 +39,11 @@ CV_EXPORTS @interface Point3i : NSObject
|
|||||||
- (instancetype)initWithPoint:(Point2i*)point;
|
- (instancetype)initWithPoint:(Point2i*)point;
|
||||||
- (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
|
- (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
+ (instancetype)fromNative:(cv::Point3i&)point;
|
||||||
|
- (void)update:(cv::Point3i&)point;
|
||||||
|
#endif
|
||||||
|
|
||||||
# pragma mark - Methods
|
# pragma mark - Methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -66,6 +66,16 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (instancetype)fromNative:(cv::Point3i&)point {
|
||||||
|
return [[Point3i alloc] initWithX:point.x y:point.y z:point.z];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)update:(cv::Point3i&)point {
|
||||||
|
self.x = point.x;
|
||||||
|
self.y = point.y;
|
||||||
|
self.z = point.z;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)set:(NSArray<NSNumber*>*)vals {
|
- (void)set:(NSArray<NSNumber*>*)vals {
|
||||||
self.x = (vals != nil && vals.count > 0) ? vals[0].intValue : 0;
|
self.x = (vals != nil && vals.count > 0) ? vals[0].intValue : 0;
|
||||||
self.y = (vals != nil && vals.count > 1) ? vals[1].intValue : 0;
|
self.y = (vals != nil && vals.count > 1) ? vals[1].intValue : 0;
|
||||||
|
|||||||
@ -55,27 +55,28 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"func_arg_fix" : {
|
"func_arg_fix" : {
|
||||||
"randu" : { "low" : {"ctype" : "double"},
|
"Core": {
|
||||||
"high" : {"ctype" : "double"} },
|
"randu" : { "low" : {"ctype" : "double"},
|
||||||
"randn" : { "mean" : {"ctype" : "double"},
|
"high" : {"ctype" : "double"} },
|
||||||
"stddev" : {"ctype" : "double"} },
|
"randn" : { "mean" : {"ctype" : "double"},
|
||||||
"inRange" : { "lowerb" : {"ctype" : "Scalar"},
|
"stddev" : {"ctype" : "double"} },
|
||||||
"upperb" : {"ctype" : "Scalar"} },
|
"inRange" : { "lowerb" : {"ctype" : "Scalar"},
|
||||||
"boundingRect" : { "points" : {"ctype" : "vector_Point"} },
|
"upperb" : {"ctype" : "Scalar"} },
|
||||||
"hconcat" : { "src" : {"ctype" : "vector_Mat"} },
|
"hconcat" : { "src" : {"ctype" : "vector_Mat"} },
|
||||||
"vconcat" : { "src" : {"ctype" : "vector_Mat"} },
|
"vconcat" : { "src" : {"ctype" : "vector_Mat"} },
|
||||||
"checkRange" : {"pos" : {"ctype" : "*"} },
|
"checkRange" : {"pos" : {"ctype" : "*"} },
|
||||||
"meanStdDev" : { "mean" : {"ctype" : "vector_double"},
|
"meanStdDev" : { "mean" : {"ctype" : "vector_double"},
|
||||||
"stddev" : {"ctype" : "vector_double"} },
|
"stddev" : {"ctype" : "vector_double"} },
|
||||||
"mixChannels" : { "dst" : {"attrib" : []} },
|
"mixChannels" : { "dst" : {"attrib" : []} },
|
||||||
"rotate" : { "rotateCode" : {"ctype" : "RotateFlags"} },
|
"rotate" : { "rotateCode" : {"ctype" : "RotateFlags"} },
|
||||||
"norm" : { "normType" : {"ctype" : "NormTypes"} },
|
"norm" : { "normType" : {"ctype" : "NormTypes"} },
|
||||||
"batchDistance" : { "normType" : {"ctype" : "NormTypes"} },
|
"batchDistance" : { "normType" : {"ctype" : "NormTypes"} },
|
||||||
"normalize" : { "norm_type" : {"ctype" : "NormTypes"} },
|
"normalize" : { "norm_type" : {"ctype" : "NormTypes"} },
|
||||||
"compare" : { "cmpop" : {"ctype" : "CmpTypes"} },
|
"compare" : { "cmpop" : {"ctype" : "CmpTypes"} },
|
||||||
"copyMakeBorder" : { "borderType" : {"ctype" : "BorderTypes"} },
|
"copyMakeBorder" : { "borderType" : {"ctype" : "BorderTypes"} },
|
||||||
"borderInterpolate" : { "borderType" : {"ctype" : "BorderTypes"} },
|
"borderInterpolate" : { "borderType" : {"ctype" : "BorderTypes"} },
|
||||||
"(void)divide:(double)scale src2:(Mat*)src2 dst:(Mat*)dst dtype:(int)dtype" : { "src2" : {"name" : "src"} }
|
"(void)divide:(double)scale src2:(Mat*)src2 dst:(Mat*)dst dtype:(int)dtype" : { "src2" : {"name" : "src"} }
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"type_dict" : {
|
"type_dict" : {
|
||||||
"Algorithm": {
|
"Algorithm": {
|
||||||
@ -227,7 +228,9 @@
|
|||||||
"from_cpp": "[Double3 fromNative:%(n)s]"
|
"from_cpp": "[Double3 fromNative:%(n)s]"
|
||||||
},
|
},
|
||||||
"c_string": {
|
"c_string": {
|
||||||
"objc_type": "NSString*"
|
"objc_type": "NSString*",
|
||||||
|
"to_cpp": "%(n)s.UTF8String",
|
||||||
|
"from_cpp": "[NSString stringWithUTF8String:%(n)s]"
|
||||||
},
|
},
|
||||||
"vector_DMatch": {
|
"vector_DMatch": {
|
||||||
"objc_type": "DMatch*",
|
"objc_type": "DMatch*",
|
||||||
@ -355,6 +358,18 @@
|
|||||||
"objc_type": "ByteVector*",
|
"objc_type": "ByteVector*",
|
||||||
"v_type": "ByteVector"
|
"v_type": "ByteVector"
|
||||||
},
|
},
|
||||||
|
"vector_vector_int": {
|
||||||
|
"objc_type": "IntVector*",
|
||||||
|
"v_type": "IntVector"
|
||||||
|
},
|
||||||
|
"vector_vector_float": {
|
||||||
|
"objc_type": "FloatVector*",
|
||||||
|
"v_type": "FloatVector"
|
||||||
|
},
|
||||||
|
"vector_vector_double": {
|
||||||
|
"objc_type": "DoubleVector*",
|
||||||
|
"v_type": "DoubleVector"
|
||||||
|
},
|
||||||
"ByteVector": {
|
"ByteVector": {
|
||||||
"objc_type": "ByteVector*",
|
"objc_type": "ByteVector*",
|
||||||
"cast_to": "std::vector<char>"
|
"cast_to": "std::vector<char>"
|
||||||
|
|||||||
@ -1,21 +1,25 @@
|
|||||||
{
|
{
|
||||||
"func_arg_fix" : {
|
"func_arg_fix" : {
|
||||||
"(Net*)readNetFromCaffe:(NSString*)prototxt caffeModel:(NSString*)caffeModel" : { "readNetFromCaffe" : {"name" : "readNetFromCaffeFile"} },
|
"Dnn": {
|
||||||
"(Net*)readNetFromCaffe:(ByteVector*)bufferProto bufferModel:(ByteVector*)bufferModel" : { "readNetFromCaffe" : {"name" : "readNetFromCaffeBuffer"} },
|
"(Net*)readNetFromCaffe:(NSString*)prototxt caffeModel:(NSString*)caffeModel" : { "readNetFromCaffe" : {"name" : "readNetFromCaffeFile"} },
|
||||||
"(Net*)readNetFromDarknet:(NSString*)cfgFile darknetModel:(NSString*)darknetModel" : { "readNetFromDarknet" : {"name" : "readNetFromDarknetFile"} },
|
"(Net*)readNetFromCaffe:(ByteVector*)bufferProto bufferModel:(ByteVector*)bufferModel" : { "readNetFromCaffe" : {"name" : "readNetFromCaffeBuffer"} },
|
||||||
"(Net*)readNetFromDarknet:(ByteVector*)bufferCfg bufferModel:(ByteVector*)bufferModel" : { "readNetFromDarknet" : {"name" : "readNetFromDarknetBuffer"} },
|
"(Net*)readNetFromDarknet:(NSString*)cfgFile darknetModel:(NSString*)darknetModel" : { "readNetFromDarknet" : {"name" : "readNetFromDarknetFile"} },
|
||||||
"(Net*)readNetFromONNX:(NSString*)onnxFile" : { "readNetFromONNX" : {"name" : "readNetFromONNXFile"} },
|
"(Net*)readNetFromDarknet:(ByteVector*)bufferCfg bufferModel:(ByteVector*)bufferModel" : { "readNetFromDarknet" : {"name" : "readNetFromDarknetBuffer"} },
|
||||||
"(Net*)readNetFromONNX:(ByteVector*)buffer" : { "readNetFromONNX" : {"name" : "readNetFromONNXBuffer"} },
|
"(Net*)readNetFromONNX:(NSString*)onnxFile" : { "readNetFromONNX" : {"name" : "readNetFromONNXFile"} },
|
||||||
"(Net*)readNetFromTensorflow:(NSString*)model config:(NSString*)config" : { "readNetFromTensorflow" : {"name" : "readNetFromTensorflowFile"} },
|
"(Net*)readNetFromONNX:(ByteVector*)buffer" : { "readNetFromONNX" : {"name" : "readNetFromONNXBuffer"} },
|
||||||
"(Net*)readNetFromTensorflow:(ByteVector*)bufferModel bufferConfig:(ByteVector*)bufferConfig" : { "readNetFromTensorflow" : {"name" : "readNetFromTensorflowBuffer"} },
|
"(Net*)readNetFromTensorflow:(NSString*)model config:(NSString*)config" : { "readNetFromTensorflow" : {"name" : "readNetFromTensorflowFile"} },
|
||||||
"(void)forward:(NSMutableArray<Mat*>*)outputBlobs outputName:(NSString*)outputName" : { "forward" : {"name" : "forwardOutputBlobs"} },
|
"(Net*)readNetFromTensorflow:(ByteVector*)bufferModel bufferConfig:(ByteVector*)bufferConfig" : { "readNetFromTensorflow" : {"name" : "readNetFromTensorflowBuffer"} }
|
||||||
"(void)forward:(NSMutableArray<Mat*>*)outputBlobs outBlobNames:(NSArray<NSString*>*)outBlobNames" : { "forward" : {"name" : "forwardOutputBlobs"} },
|
},
|
||||||
"(long)getFLOPS:(IntVector*)netInputShape" : { "getFLOPS" : {"name" : "getFLOPSWithNetInputShape"} },
|
"Net": {
|
||||||
"(long)getFLOPS:(NSArray<IntVector*>*)netInputShapes" : { "getFLOPS" : {"name" : "getFLOPSWithNetInputShapes"} },
|
"(void)forward:(NSMutableArray<Mat*>*)outputBlobs outputName:(NSString*)outputName" : { "forward" : {"name" : "forwardOutputBlobs"} },
|
||||||
"(long)getFLOPS:(int)layerId netInputShape:(IntVector*)netInputShape" : { "getFLOPS" : {"name" : "getFLOPSWithLayerId"} },
|
"(void)forward:(NSMutableArray<Mat*>*)outputBlobs outBlobNames:(NSArray<NSString*>*)outBlobNames" : { "forward" : {"name" : "forwardOutputBlobs"} },
|
||||||
"(long)getFLOPS:(int)layerId netInputShapes:(NSArray<IntVector*>*)netInputShapes" : { "getFLOPS" : {"name" : "getFLOPSWithLayerId"} },
|
"(long)getFLOPS:(IntVector*)netInputShape" : { "getFLOPS" : {"name" : "getFLOPSWithNetInputShape"} },
|
||||||
"(void)getLayersShapes:(IntVector*)netInputShape layersIds:(IntVector*)layersIds inLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)inLayersShapes outLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)outLayersShapes" : { "getLayersShapes" : {"name" : "getLayersShapesWithNetInputShape"} },
|
"(long)getFLOPS:(NSArray<IntVector*>*)netInputShapes" : { "getFLOPS" : {"name" : "getFLOPSWithNetInputShapes"} },
|
||||||
"(void)getLayersShapes:(NSArray<IntVector*>*)netInputShapes layersIds:(IntVector*)layersIds inLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)inLayersShapes outLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)outLayersShapes" : { "getLayersShapes" : {"name" : "getLayersShapesWithNetInputShapes"} }
|
"(long)getFLOPS:(int)layerId netInputShape:(IntVector*)netInputShape" : { "getFLOPS" : {"name" : "getFLOPSWithLayerId"} },
|
||||||
|
"(long)getFLOPS:(int)layerId netInputShapes:(NSArray<IntVector*>*)netInputShapes" : { "getFLOPS" : {"name" : "getFLOPSWithLayerId"} },
|
||||||
|
"(void)getLayersShapes:(IntVector*)netInputShape layersIds:(IntVector*)layersIds inLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)inLayersShapes outLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)outLayersShapes" : { "getLayersShapes" : {"name" : "getLayersShapesWithNetInputShape"} },
|
||||||
|
"(void)getLayersShapes:(NSArray<IntVector*>*)netInputShapes layersIds:(IntVector*)layersIds inLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)inLayersShapes outLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)outLayersShapes" : { "getLayersShapes" : {"name" : "getLayersShapesWithNetInputShapes"} }
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"type_dict": {
|
"type_dict": {
|
||||||
"MatShape": {
|
"MatShape": {
|
||||||
|
|||||||
@ -4,13 +4,20 @@
|
|||||||
"AgastFeatureDetector" : { "DetectorType": "AgastDetectorType" }
|
"AgastFeatureDetector" : { "DetectorType": "AgastDetectorType" }
|
||||||
},
|
},
|
||||||
"func_arg_fix" : {
|
"func_arg_fix" : {
|
||||||
"(void)compute:(NSArray<Mat*>*)images keypoints:(NSMutableArray<NSMutableArray<KeyPoint*>*>*)keypoints descriptors:(NSMutableArray<Mat*>*)descriptors" : { "compute" : {"name" : "compute2"} },
|
"Feature2D": {
|
||||||
"(void)detect:(NSArray<Mat*>*)images keypoints:(NSMutableArray<NSMutableArray<KeyPoint*>*>*)keypoints masks:(NSArray<Mat*>*)masks" : { "detect" : {"name" : "detect2"} },
|
"(void)compute:(NSArray<Mat*>*)images keypoints:(NSMutableArray<NSMutableArray<KeyPoint*>*>*)keypoints descriptors:(NSMutableArray<Mat*>*)descriptors" : { "compute" : {"name" : "compute2"} },
|
||||||
"(DescriptorMatcher*)create:(NSString*)descriptorMatcherType" : { "create" : {"name" : "create2"} },
|
"(void)detect:(NSArray<Mat*>*)images keypoints:(NSMutableArray<NSMutableArray<KeyPoint*>*>*)keypoints masks:(NSArray<Mat*>*)masks" : { "detect" : {"name" : "detect2"} }
|
||||||
"FlannBasedMatcher": { "indexParams" : {"defval" : "cv::makePtr<cv::flann::KDTreeIndexParams>()"}, "searchParams" : {"defval" : "cv::makePtr<cv::flann::SearchParams>()"} },
|
},
|
||||||
"(SimpleBlobDetector*)create" : { "parameters" : {"defval" : "cv::SimpleBlobDetector::Params()"} },
|
"DescriptorMatcher": {
|
||||||
"BFMatcher" : { "normType" : {"ctype" : "NormTypes"} },
|
"(DescriptorMatcher*)create:(NSString*)descriptorMatcherType" : { "create" : {"name" : "create2"} }
|
||||||
"(BFMatcher*)create:(int)normType crossCheck:(BOOL)crossCheck" : { "create" : {"name" : "createBFMatcher"},
|
},
|
||||||
"normType" : {"ctype" : "NormTypes"} }
|
"FlannBasedMatcher": {
|
||||||
|
"FlannBasedMatcher": { "indexParams" : {"defval" : "cv::makePtr<cv::flann::KDTreeIndexParams>()"}, "searchParams" : {"defval" : "cv::makePtr<cv::flann::SearchParams>()"} }
|
||||||
|
},
|
||||||
|
"BFMatcher": {
|
||||||
|
"BFMatcher" : { "normType" : {"ctype" : "NormTypes"} },
|
||||||
|
"(BFMatcher*)create:(int)normType crossCheck:(BOOL)crossCheck" : { "create" : {"name" : "createBFMatcher"},
|
||||||
|
"normType" : {"ctype" : "NormTypes"} }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,88 +34,92 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"func_arg_fix" : {
|
"func_arg_fix" : {
|
||||||
"goodFeaturesToTrack" : { "corners" : {"ctype" : "vector_Point"} },
|
"Imgproc" : {
|
||||||
"minEnclosingCircle" : { "points" : {"ctype" : "vector_Point2f"} },
|
"goodFeaturesToTrack" : { "corners" : {"ctype" : "vector_Point"} },
|
||||||
"fitEllipse" : { "points" : {"ctype" : "vector_Point2f"} },
|
"minEnclosingCircle" : { "points" : {"ctype" : "vector_Point2f"} },
|
||||||
"fillPoly" : { "pts" : {"ctype" : "vector_vector_Point"},
|
"fitEllipse" : { "points" : {"ctype" : "vector_Point2f"} },
|
||||||
"lineType" : {"ctype" : "LineTypes"}},
|
"fillPoly" : { "pts" : {"ctype" : "vector_vector_Point"},
|
||||||
"polylines" : { "pts" : {"ctype" : "vector_vector_Point"},
|
"lineType" : {"ctype" : "LineTypes"}},
|
||||||
"lineType" : {"ctype" : "LineTypes"} },
|
"polylines" : { "pts" : {"ctype" : "vector_vector_Point"},
|
||||||
"fillConvexPoly" : { "points" : {"ctype" : "vector_Point"},
|
|
||||||
"lineType" : {"ctype" : "LineTypes"} },
|
"lineType" : {"ctype" : "LineTypes"} },
|
||||||
"approxPolyDP" : { "curve" : {"ctype" : "vector_Point2f"},
|
"fillConvexPoly" : { "points" : {"ctype" : "vector_Point"},
|
||||||
"approxCurve" : {"ctype" : "vector_Point2f"} },
|
"lineType" : {"ctype" : "LineTypes"} },
|
||||||
"arcLength" : { "curve" : {"ctype" : "vector_Point2f"} },
|
"approxPolyDP" : { "curve" : {"ctype" : "vector_Point2f"},
|
||||||
"pointPolygonTest" : { "contour" : {"ctype" : "vector_Point2f"} },
|
"approxCurve" : {"ctype" : "vector_Point2f"} },
|
||||||
"minAreaRect" : { "points" : {"ctype" : "vector_Point2f"} },
|
"arcLength" : { "curve" : {"ctype" : "vector_Point2f"} },
|
||||||
"getAffineTransform" : { "src" : {"ctype" : "vector_Point2f"},
|
"pointPolygonTest" : { "contour" : {"ctype" : "vector_Point2f"} },
|
||||||
"dst" : {"ctype" : "vector_Point2f"} },
|
"minAreaRect" : { "points" : {"ctype" : "vector_Point2f"} },
|
||||||
"drawContours" : { "contours" : {"ctype" : "vector_vector_Point"},
|
"getAffineTransform" : { "src" : {"ctype" : "vector_Point2f"},
|
||||||
"lineType" : {"ctype" : "LineTypes"} },
|
"dst" : {"ctype" : "vector_Point2f"} },
|
||||||
"findContours" : { "contours" : {"ctype" : "vector_vector_Point"},
|
"drawContours" : { "contours" : {"ctype" : "vector_vector_Point"},
|
||||||
"mode" : {"ctype" : "RetrievalModes"},
|
"lineType" : {"ctype" : "LineTypes"} },
|
||||||
"method" : {"ctype" : "ContourApproximationModes"} },
|
"findContours" : { "contours" : {"ctype" : "vector_vector_Point"},
|
||||||
"convexityDefects" : { "contour" : {"ctype" : "vector_Point"},
|
"mode" : {"ctype" : "RetrievalModes"},
|
||||||
"convexhull" : {"ctype" : "vector_int"},
|
"method" : {"ctype" : "ContourApproximationModes"} },
|
||||||
"convexityDefects" : {"ctype" : "vector_Vec4i"} },
|
"convexityDefects" : { "contour" : {"ctype" : "vector_Point"},
|
||||||
"isContourConvex" : { "contour" : {"ctype" : "vector_Point"} },
|
"convexhull" : {"ctype" : "vector_int"},
|
||||||
"convexHull" : { "points" : {"ctype" : "vector_Point"},
|
"convexityDefects" : {"ctype" : "vector_Vec4i"} },
|
||||||
"hull" : {"ctype" : "vector_int"},
|
"isContourConvex" : { "contour" : {"ctype" : "vector_Point"} },
|
||||||
"returnPoints" : {"ctype" : ""} },
|
"convexHull" : { "points" : {"ctype" : "vector_Point"},
|
||||||
"getStructuringElement" : { "shape" : {"ctype" : "MorphShapes"} },
|
"hull" : {"ctype" : "vector_int"},
|
||||||
"EMD" : {"lowerBound" : {"defval" : "cv::Ptr<float>()"},
|
"returnPoints" : {"ctype" : ""} },
|
||||||
"distType" : {"ctype" : "DistanceTypes"}},
|
"getStructuringElement" : { "shape" : {"ctype" : "MorphShapes"} },
|
||||||
"createLineSegmentDetector" : { "_refine" : {"ctype" : "LineSegmentDetectorModes"}},
|
"EMD" : {"lowerBound" : {"defval" : "cv::Ptr<float>()"},
|
||||||
"compareHist" : { "method" : {"ctype" : "HistCompMethods"}},
|
"distType" : {"ctype" : "DistanceTypes"}},
|
||||||
"matchShapes" : { "method" : {"ctype" : "ShapeMatchModes"}},
|
"createLineSegmentDetector" : { "_refine" : {"ctype" : "LineSegmentDetectorModes"}},
|
||||||
"threshold" : { "type" : {"ctype" : "ThresholdTypes"}},
|
"compareHist" : { "method" : {"ctype" : "HistCompMethods"}},
|
||||||
"connectedComponentsWithStatsWithAlgorithm" : { "ccltype" : {"ctype" : "ConnectedComponentsAlgorithmsTypes"}},
|
"matchShapes" : { "method" : {"ctype" : "ShapeMatchModes"}},
|
||||||
"GaussianBlur" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"threshold" : { "type" : {"ctype" : "ThresholdTypes"}},
|
||||||
"HoughCircles" : { "method" : {"ctype" : "HoughModes"}},
|
"connectedComponentsWithStatsWithAlgorithm" : { "ccltype" : {"ctype" : "ConnectedComponentsAlgorithmsTypes"}},
|
||||||
"Laplacian" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"GaussianBlur" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"Scharr" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"HoughCircles" : { "method" : {"ctype" : "HoughModes"}},
|
||||||
"Sobel" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"Laplacian" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"adaptiveThreshold" : { "adaptiveMethod" : {"ctype" : "AdaptiveThresholdTypes"},
|
"Scharr" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"thresholdType" : {"ctype" : "ThresholdTypes"}},
|
"Sobel" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"applyColorMap" : { "colormap" : {"ctype" : "ColormapTypes"}},
|
"adaptiveThreshold" : { "adaptiveMethod" : {"ctype" : "AdaptiveThresholdTypes"},
|
||||||
"arrowedLine" : { "line_type" : {"ctype" : "LineTypes"}},
|
"thresholdType" : {"ctype" : "ThresholdTypes"}},
|
||||||
"bilateralFilter" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"applyColorMap" : { "colormap" : {"ctype" : "ColormapTypes"}},
|
||||||
"blur" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"arrowedLine" : { "line_type" : {"ctype" : "LineTypes"}},
|
||||||
"boxFilter" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"bilateralFilter" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"circle" : { "lineType" : {"ctype" : "LineTypes"}},
|
"blur" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"cornerEigenValsAndVecs" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"boxFilter" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"cornerHarris" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"circle" : { "lineType" : {"ctype" : "LineTypes"}},
|
||||||
"cornerMinEigenVal" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"cornerEigenValsAndVecs" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"cvtColor" : { "code" : {"ctype" : "ColorConversionCodes"}},
|
"cornerHarris" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"dilate" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"cornerMinEigenVal" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"distanceTransformWithLabels" : { "labelType" : {"ctype" : "DistanceTransformLabelTypes"},
|
"cvtColor" : { "code" : {"ctype" : "ColorConversionCodes"}},
|
||||||
"distanceType" : {"ctype" : "DistanceTypes"},
|
"dilate" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"maskSize" : {"ctype" : "DistanceTransformMasks"}},
|
"distanceTransformWithLabels" : { "labelType" : {"ctype" : "DistanceTransformLabelTypes"},
|
||||||
"distanceTransform" : { "distanceType" : {"ctype" : "DistanceTypes"},
|
"distanceType" : {"ctype" : "DistanceTypes"},
|
||||||
"maskSize" : {"ctype" : "DistanceTransformMasks"}},
|
"maskSize" : {"ctype" : "DistanceTransformMasks"}},
|
||||||
"drawMarker" : { "markerType" : {"ctype" : "MarkerTypes"},
|
"distanceTransform" : { "distanceType" : {"ctype" : "DistanceTypes"},
|
||||||
"line_type" : {"ctype" : "LineTypes"}},
|
"maskSize" : {"ctype" : "DistanceTransformMasks"}},
|
||||||
"ellipse" : { "lineType" : {"ctype" : "LineTypes"}},
|
"drawMarker" : { "markerType" : {"ctype" : "MarkerTypes"},
|
||||||
"erode" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"line_type" : {"ctype" : "LineTypes"}},
|
||||||
"filter2D" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"ellipse" : { "lineType" : {"ctype" : "LineTypes"}},
|
||||||
"fitLine" : { "distType" : {"ctype" : "DistanceTypes"}},
|
"erode" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"line" : { "lineType" : {"ctype" : "LineTypes"}},
|
"filter2D" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"matchTemplate" : { "method" : {"ctype" : "TemplateMatchModes"}},
|
"fitLine" : { "distType" : {"ctype" : "DistanceTypes"}},
|
||||||
"morphologyEx" : { "op" : {"ctype" : "MorphTypes"},
|
"line" : { "lineType" : {"ctype" : "LineTypes"}},
|
||||||
"borderType" : {"ctype" : "BorderTypes"}},
|
"matchTemplate" : { "method" : {"ctype" : "TemplateMatchModes"}},
|
||||||
"preCornerDetect" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"morphologyEx" : { "op" : {"ctype" : "MorphTypes"},
|
||||||
"putText" : { "fontFace" : {"ctype" : "HersheyFonts"},
|
"borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"lineType" : {"ctype" : "LineTypes"}},
|
"preCornerDetect" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"pyrDown" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"putText" : { "fontFace" : {"ctype" : "HersheyFonts"},
|
||||||
"pyrUp" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"lineType" : {"ctype" : "LineTypes"}},
|
||||||
"rectangle" : { "lineType" : {"ctype" : "LineTypes"}},
|
"pyrDown" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"remap" : { "borderMode": {"ctype" : "BorderTypes"}},
|
"pyrUp" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"sepFilter2D" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"rectangle" : { "lineType" : {"ctype" : "LineTypes"}},
|
||||||
"spatialGradient" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"remap" : { "borderMode": {"ctype" : "BorderTypes"}},
|
||||||
"sqrBoxFilter" : { "borderType" : {"ctype" : "BorderTypes"}},
|
"sepFilter2D" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"warpAffine" : { "borderMode": {"ctype" : "BorderTypes"}},
|
"spatialGradient" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"warpPerspective" : { "borderMode": {"ctype" : "BorderTypes"}},
|
"sqrBoxFilter" : { "borderType" : {"ctype" : "BorderTypes"}},
|
||||||
"getTextSize" : { "fontFace": {"ctype" : "HersheyFonts"}},
|
"warpAffine" : { "borderMode": {"ctype" : "BorderTypes"}},
|
||||||
"(void)insert:(NSArray<Point2f*>*)ptvec" : { "insert" : {"name" : "insertVector"} }
|
"warpPerspective" : { "borderMode": {"ctype" : "BorderTypes"}},
|
||||||
|
"getTextSize" : { "fontFace": {"ctype" : "HersheyFonts"}}
|
||||||
|
},
|
||||||
|
"Subdiv2D" : {
|
||||||
|
"(void)insert:(NSArray<Point2f*>*)ptvec" : { "insert" : {"name" : "insertVector"} }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,7 +62,7 @@ type_dict = {
|
|||||||
# In example, cv::fisheye::stereoRectify from namespace fisheye is wrapped as fisheye_stereoRectify
|
# In example, cv::fisheye::stereoRectify from namespace fisheye is wrapped as fisheye_stereoRectify
|
||||||
namespaces_dict = {}
|
namespaces_dict = {}
|
||||||
|
|
||||||
# { class : [ header ] }
|
# { module: { class | "*" : [ header ]} }
|
||||||
AdditionalImports = {}
|
AdditionalImports = {}
|
||||||
|
|
||||||
# { class : { func : {declaration, implementation} } }
|
# { class : { func : {declaration, implementation} } }
|
||||||
@ -74,6 +74,9 @@ func_arg_fix = {}
|
|||||||
# { class : { enum: fixed_enum } }
|
# { class : { enum: fixed_enum } }
|
||||||
enum_fix = {}
|
enum_fix = {}
|
||||||
|
|
||||||
|
# { class : { enum: { const: fixed_const} } }
|
||||||
|
const_fix = {}
|
||||||
|
|
||||||
# { (class, func) : objc_signature }
|
# { (class, func) : objc_signature }
|
||||||
method_dict = {
|
method_dict = {
|
||||||
("Mat", "convertTo") : "-convertTo:rtype:alpha:beta:",
|
("Mat", "convertTo") : "-convertTo:rtype:alpha:beta:",
|
||||||
@ -226,14 +229,15 @@ class ClassPropInfo():
|
|||||||
class ClassInfo(GeneralInfo):
|
class ClassInfo(GeneralInfo):
|
||||||
def __init__(self, decl, namespaces=[]): # [ 'class/struct cname', ': base', [modlist] ]
|
def __init__(self, decl, namespaces=[]): # [ 'class/struct cname', ': base', [modlist] ]
|
||||||
GeneralInfo.__init__(self, "class", decl, namespaces)
|
GeneralInfo.__init__(self, "class", decl, namespaces)
|
||||||
self.cname = get_cname(self.name)
|
self.cname = self.name if not self.classname else self.classname + "_" + self.name
|
||||||
|
self.real_cname = self.name if not self.classname else self.classname + "::" + self.name
|
||||||
self.methods = []
|
self.methods = []
|
||||||
self.methods_suffixes = {}
|
self.methods_suffixes = {}
|
||||||
self.consts = [] # using a list to save the occurrence order
|
self.consts = [] # using a list to save the occurrence order
|
||||||
self.private_consts = []
|
self.private_consts = []
|
||||||
self.imports = set()
|
self.imports = set()
|
||||||
self.props= []
|
self.props= []
|
||||||
self.objc_name = self.name
|
self.objc_name = self.name if not self.classname else self.classname + self.name
|
||||||
self.smart = None # True if class stores Ptr<T>* instead of T* in nativeObj field
|
self.smart = None # True if class stores Ptr<T>* instead of T* in nativeObj field
|
||||||
self.additionalImports = None # additional import files
|
self.additionalImports = None # additional import files
|
||||||
self.enum_declarations = None # Objective-C enum declarations stream
|
self.enum_declarations = None # Objective-C enum declarations stream
|
||||||
@ -422,10 +426,12 @@ class ArgInfo():
|
|||||||
defval=self.defval)
|
defval=self.defval)
|
||||||
|
|
||||||
class FuncInfo(GeneralInfo):
|
class FuncInfo(GeneralInfo):
|
||||||
def __init__(self, decl, namespaces=[]): # [ funcname, return_ctype, [modifiers], [args] ]
|
def __init__(self, decl, module, namespaces=[]): # [ funcname, return_ctype, [modifiers], [args] ]
|
||||||
GeneralInfo.__init__(self, "func", decl, namespaces)
|
GeneralInfo.__init__(self, "func", decl, namespaces)
|
||||||
self.cname = get_cname(decl[0])
|
self.cname = get_cname(decl[0])
|
||||||
self.objc_name = self.name
|
nested_type = self.classpath.find(".") != -1
|
||||||
|
self.objc_name = self.name if not nested_type else self.classpath.replace(".", "")
|
||||||
|
self.classname = self.classname if not nested_type else self.classpath.replace(".", "_")
|
||||||
self.swift_name = self.name
|
self.swift_name = self.name
|
||||||
self.cv_name = self.fullName(isCPP=True)
|
self.cv_name = self.fullName(isCPP=True)
|
||||||
self.isconstructor = self.name == self.classname
|
self.isconstructor = self.name == self.classname
|
||||||
@ -439,7 +445,7 @@ class FuncInfo(GeneralInfo):
|
|||||||
self.static = ["","static"][ "/S" in decl[2] ]
|
self.static = ["","static"][ "/S" in decl[2] ]
|
||||||
self.ctype = re.sub(r"^CvTermCriteria", "TermCriteria", decl[1] or "")
|
self.ctype = re.sub(r"^CvTermCriteria", "TermCriteria", decl[1] or "")
|
||||||
self.args = []
|
self.args = []
|
||||||
func_fix_map = func_arg_fix.get(self.objc_name, {})
|
func_fix_map = func_arg_fix.get(self.classname or module, {}).get(self.objc_name, {})
|
||||||
for a in decl[3]:
|
for a in decl[3]:
|
||||||
arg = a[:]
|
arg = a[:]
|
||||||
arg_fix_map = func_fix_map.get(arg[1], {})
|
arg_fix_map = func_fix_map.get(arg[1], {})
|
||||||
@ -449,7 +455,7 @@ class FuncInfo(GeneralInfo):
|
|||||||
self.args.append(ArgInfo(arg))
|
self.args.append(ArgInfo(arg))
|
||||||
|
|
||||||
if type_complete(self.args, self.ctype):
|
if type_complete(self.args, self.ctype):
|
||||||
func_fix_map = func_arg_fix.get(self.signature(self.args), {})
|
func_fix_map = func_arg_fix.get(self.classname or module, {}).get(self.signature(self.args), {})
|
||||||
name_fix_map = func_fix_map.get(self.name, {})
|
name_fix_map = func_fix_map.get(self.name, {})
|
||||||
self.objc_name = name_fix_map.get('name', self.objc_name)
|
self.objc_name = name_fix_map.get('name', self.objc_name)
|
||||||
for arg in self.args:
|
for arg in self.args:
|
||||||
@ -574,14 +580,14 @@ class ObjectiveCWrapperGenerator(object):
|
|||||||
self.skipped_func_list = []
|
self.skipped_func_list = []
|
||||||
self.def_args_hist = {} # { def_args_cnt : funcs_cnt }
|
self.def_args_hist = {} # { def_args_cnt : funcs_cnt }
|
||||||
|
|
||||||
def add_class(self, decl, module):
|
def add_class(self, decl):
|
||||||
classinfo = ClassInfo(decl, namespaces=self.namespaces)
|
classinfo = ClassInfo(decl, namespaces=self.namespaces)
|
||||||
if classinfo.name in class_ignore_list:
|
if classinfo.name in class_ignore_list:
|
||||||
logging.info('ignored: %s', classinfo)
|
logging.info('ignored: %s', classinfo)
|
||||||
return
|
return
|
||||||
if classinfo.name != module:
|
if classinfo.name != self.Module:
|
||||||
self.classes[module].member_classes.append(classinfo.name)
|
self.classes[self.Module].member_classes.append(classinfo.objc_name)
|
||||||
name = classinfo.name
|
name = classinfo.cname
|
||||||
if self.isWrapped(name) and not classinfo.base:
|
if self.isWrapped(name) and not classinfo.base:
|
||||||
logging.warning('duplicated: %s', classinfo)
|
logging.warning('duplicated: %s', classinfo)
|
||||||
return
|
return
|
||||||
@ -613,9 +619,11 @@ class ObjectiveCWrapperGenerator(object):
|
|||||||
type_dict.setdefault("Ptr_"+name, {}).update(
|
type_dict.setdefault("Ptr_"+name, {}).update(
|
||||||
{ "objc_type" : classinfo.objc_name + "*",
|
{ "objc_type" : classinfo.objc_name + "*",
|
||||||
"c_type" : name,
|
"c_type" : name,
|
||||||
|
"real_c_type" : classinfo.real_cname,
|
||||||
"to_cpp": "%(n)s." + classinfo.native_ptr_name,
|
"to_cpp": "%(n)s." + classinfo.native_ptr_name,
|
||||||
"from_cpp_ptr": "[" + name + " fromNativePtr:%(n)s]"}
|
"from_cpp": "[" + name + " fromNative:%(n)s]"}
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info('ok: class %s, name: %s, base: %s', classinfo, name, classinfo.base)
|
logging.info('ok: class %s, name: %s, base: %s', classinfo, name, classinfo.base)
|
||||||
|
|
||||||
def add_const(self, decl, scope=None, enumType=None): # [ "const cname", val, [], [] ]
|
def add_const(self, decl, scope=None, enumType=None): # [ "const cname", val, [], [] ]
|
||||||
@ -623,6 +631,12 @@ class ObjectiveCWrapperGenerator(object):
|
|||||||
if constinfo.isIgnored():
|
if constinfo.isIgnored():
|
||||||
logging.info('ignored: %s', constinfo)
|
logging.info('ignored: %s', constinfo)
|
||||||
else:
|
else:
|
||||||
|
objc_type = enumType.rsplit(".", 1)[-1] if enumType else ""
|
||||||
|
if const_fix.has_key(constinfo.classname) and const_fix[constinfo.classname].has_key(objc_type) and const_fix[constinfo.classname][objc_type].has_key(constinfo.name):
|
||||||
|
fixed_const = const_fix[constinfo.classname][objc_type][constinfo.name]
|
||||||
|
constinfo.name = fixed_const
|
||||||
|
constinfo.cname = fixed_const
|
||||||
|
|
||||||
if not self.isWrapped(constinfo.classname):
|
if not self.isWrapped(constinfo.classname):
|
||||||
logging.info('class not found: %s', constinfo)
|
logging.info('class not found: %s', constinfo)
|
||||||
constinfo.name = constinfo.classname + '_' + constinfo.name
|
constinfo.name = constinfo.classname + '_' + constinfo.name
|
||||||
@ -668,7 +682,7 @@ class ObjectiveCWrapperGenerator(object):
|
|||||||
self.add_const(decl, self.Module, enumType)
|
self.add_const(decl, self.Module, enumType)
|
||||||
|
|
||||||
def add_func(self, decl):
|
def add_func(self, decl):
|
||||||
fi = FuncInfo(decl, namespaces=self.namespaces)
|
fi = FuncInfo(decl, self.Module, namespaces=self.namespaces)
|
||||||
classname = fi.classname or self.Module
|
classname = fi.classname or self.Module
|
||||||
if classname in class_ignore_list:
|
if classname in class_ignore_list:
|
||||||
logging.info('ignored: %s', fi)
|
logging.info('ignored: %s', fi)
|
||||||
@ -709,7 +723,7 @@ class ObjectiveCWrapperGenerator(object):
|
|||||||
# TODO: support UMat versions of declarations (implement UMat-wrapper for Java)
|
# TODO: support UMat versions of declarations (implement UMat-wrapper for Java)
|
||||||
parser = hdr_parser.CppHeaderParser(generate_umat_decls=False)
|
parser = hdr_parser.CppHeaderParser(generate_umat_decls=False)
|
||||||
|
|
||||||
self.add_class( ['class ' + self.Module, '', [], []], self.Module ) # [ 'class/struct cname', ':bases', [modlist] [props] ]
|
self.add_class( ['class ' + self.Module, '', [], []]) # [ 'class/struct cname', ':bases', [modlist] [props] ]
|
||||||
|
|
||||||
# scan the headers and build more descriptive maps of classes, consts, functions
|
# scan the headers and build more descriptive maps of classes, consts, functions
|
||||||
includes = []
|
includes = []
|
||||||
@ -729,7 +743,7 @@ class ObjectiveCWrapperGenerator(object):
|
|||||||
logging.info("\n--- Incoming ---\n%s", pformat(decl[:5], 4)) # without docstring
|
logging.info("\n--- Incoming ---\n%s", pformat(decl[:5], 4)) # without docstring
|
||||||
name = decl[0]
|
name = decl[0]
|
||||||
if name.startswith("struct") or name.startswith("class"):
|
if name.startswith("struct") or name.startswith("class"):
|
||||||
self.add_class(decl, self.Module)
|
self.add_class(decl)
|
||||||
elif name.startswith("const"):
|
elif name.startswith("const"):
|
||||||
self.add_const(decl)
|
self.add_const(decl)
|
||||||
elif name.startswith("enum"):
|
elif name.startswith("enum"):
|
||||||
@ -745,7 +759,7 @@ class ObjectiveCWrapperGenerator(object):
|
|||||||
if ci.name == "Mat":
|
if ci.name == "Mat":
|
||||||
continue
|
continue
|
||||||
ci.initCodeStreams(self.Module)
|
ci.initCodeStreams(self.Module)
|
||||||
self.gen_class(ci)
|
self.gen_class(ci, self.module)
|
||||||
classObjcHeaderCode = ci.generateObjcHeaderCode(self.module, self.Module, ci.objc_name)
|
classObjcHeaderCode = ci.generateObjcHeaderCode(self.module, self.Module, ci.objc_name)
|
||||||
header_file = "%s/%s/%s.h" % (output_objc_path, module, ci.objc_name)
|
header_file = "%s/%s/%s.h" % (output_objc_path, module, ci.objc_name)
|
||||||
self.save(header_file, classObjcHeaderCode)
|
self.save(header_file, classObjcHeaderCode)
|
||||||
@ -952,8 +966,9 @@ class ObjectiveCWrapperGenerator(object):
|
|||||||
epilogue.append("CV2OBJC2(" + cpp_type + ", " + objc_type[:-1] + ", retValVector, retVal);")
|
epilogue.append("CV2OBJC2(" + cpp_type + ", " + objc_type[:-1] + ", retValVector, retVal);")
|
||||||
elif ret_type.startswith("Ptr_"):
|
elif ret_type.startswith("Ptr_"):
|
||||||
cpp_type = type_dict[ret_type]["c_type"]
|
cpp_type = type_dict[ret_type]["c_type"]
|
||||||
|
real_cpp_type = type_dict[ret_type].get("real_c_type", cpp_type)
|
||||||
namespace_prefix = self.get_namespace_prefix(cpp_type)
|
namespace_prefix = self.get_namespace_prefix(cpp_type)
|
||||||
ret_val = "cv::Ptr<" + namespace_prefix + cpp_type + "> retVal = "
|
ret_val = "cv::Ptr<" + namespace_prefix + real_cpp_type + "> retVal = "
|
||||||
ret = "return [" + type_dict[ret_type]["objc_type"][:-1] + " fromNative:retVal];"
|
ret = "return [" + type_dict[ret_type]["objc_type"][:-1] + " fromNative:retVal];"
|
||||||
elif ret_type == "void":
|
elif ret_type == "void":
|
||||||
ret_val = ""
|
ret_val = ""
|
||||||
@ -1027,10 +1042,15 @@ class ObjectiveCWrapperGenerator(object):
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
def gen_class(self, ci):
|
def gen_class(self, ci, module):
|
||||||
logging.info("%s", ci)
|
logging.info("%s", ci)
|
||||||
if ci.name in AdditionalImports:
|
if module in AdditionalImports and (ci.name in AdditionalImports[module] or "*" in AdditionalImports[module]):
|
||||||
ci.additionalImports.write("\n".join(["#import %s" % h for h in AdditionalImports[ci.name]]))
|
additional_imports = []
|
||||||
|
if "*" in AdditionalImports[module]:
|
||||||
|
additional_imports += AdditionalImports[module]["*"]
|
||||||
|
if ci.name in AdditionalImports[module]:
|
||||||
|
additional_imports += AdditionalImports[module][ci.name]
|
||||||
|
ci.additionalImports.write("\n".join(["#import %s" % h for h in additional_imports]))
|
||||||
|
|
||||||
# constants
|
# constants
|
||||||
wrote_consts_pragma = False
|
wrote_consts_pragma = False
|
||||||
@ -1089,27 +1109,45 @@ typedef NS_ENUM(int, {2}) {{
|
|||||||
ci.method_declarations.write("@property " + ("(readonly) " if not pi.rw else "") + objc_type + " " + pi.name + ";\n")
|
ci.method_declarations.write("@property " + ("(readonly) " if not pi.rw else "") + objc_type + " " + pi.name + ";\n")
|
||||||
ptr_ref = "self." + ci.native_ptr_name + "->" if not ci.is_base_class else "self.nativePtr->"
|
ptr_ref = "self." + ci.native_ptr_name + "->" if not ci.is_base_class else "self.nativePtr->"
|
||||||
if type_data.has_key("v_type"):
|
if type_data.has_key("v_type"):
|
||||||
vector_type = type_data["v_type"]
|
vector_cpp_type = type_data["v_type"]
|
||||||
full_cpp_type = (self.get_namespace_prefix(vector_type) if (vector_type.find("::") == -1) else "") + vector_type
|
has_namespace = vector_cpp_type.find("::") != -1
|
||||||
ret_val = "std::vector<" + full_cpp_type + "> retValVector = "
|
vector_full_cpp_type = self.fullTypeName(vector_cpp_type) if not has_namespace else vector_cpp_type
|
||||||
ci.method_implementations.write("-(NSArray<" + objc_type + ">*)" + pi.name + "{\n")
|
ret_val = "std::vector<" + vector_full_cpp_type + "> retValVector = "
|
||||||
|
ci.method_implementations.write("-(NSArray<" + objc_type + ">*)" + pi.name + " {\n")
|
||||||
ci.method_implementations.write("\tNSMutableArray<" + objc_type + ">* retVal = [NSMutableArray new];\n")
|
ci.method_implementations.write("\tNSMutableArray<" + objc_type + ">* retVal = [NSMutableArray new];\n")
|
||||||
ci.method_implementations.write("\t" + ret_val + ptr_ref + pi.name + ";\n")
|
ci.method_implementations.write("\t" + ret_val + ptr_ref + pi.name + ";\n")
|
||||||
epilogue = []
|
epilogue = []
|
||||||
self.build_cv2objc_epilogue(epilogue, vector_type, full_cpp_type, objc_type, "retValVector", "retVal")
|
self.build_cv2objc_epilogue(epilogue, vector_cpp_type, vector_full_cpp_type, objc_type, "retValVector", "retVal")
|
||||||
ci.method_implementations.write("\t" + ("\n\t".join(epilogue)) + "\n")
|
ci.method_implementations.write("\t" + ("\n\t".join(epilogue)) + "\n")
|
||||||
ci.method_implementations.write("\treturn retVal;\n}\n\n")
|
ci.method_implementations.write("\treturn retVal;\n}\n\n")
|
||||||
|
elif type_data.has_key("v_v_type"):
|
||||||
|
vector_cpp_type = type_data["v_v_type"]
|
||||||
|
has_namespace = vector_cpp_type.find("::") != -1
|
||||||
|
vector_full_cpp_type = self.fullTypeName(vector_cpp_type) if not has_namespace else vector_cpp_type
|
||||||
|
ret_val = "std::vector<std::vector<" + vector_full_cpp_type + ">> retValVectorVector = "
|
||||||
|
ci.method_implementations.write("-(NSArray<NSArray<" + objc_type + ">*>*)" + pi.name + " {\n")
|
||||||
|
ci.method_implementations.write("\tNSMutableArray<NSMutableArray<" + objc_type + ">*>* retVal = [NSMutableArray new];\n")
|
||||||
|
ci.method_implementations.write("\t" + ret_val + ptr_ref + pi.name + ";\n")
|
||||||
|
ci.method_implementations.write("\tCV2OBJC2(" + vector_full_cpp_type + ", " + objc_type[:-1] + ", retValVectorVector, retVal);\n")
|
||||||
|
ci.method_implementations.write("\treturn retVal;\n}\n\n")
|
||||||
|
elif self.isWrapped(pi.ctype): # wrapped class
|
||||||
|
namespace_prefix = self.get_namespace_prefix(pi.ctype)
|
||||||
|
ci.method_implementations.write("-(" + objc_type + ")" + pi.name + " {\n")
|
||||||
|
ci.method_implementations.write("\tcv::Ptr<" + namespace_prefix + pi.ctype + "> retVal = new " + namespace_prefix + pi.ctype + "(" + ptr_ref + pi.name + ");\n")
|
||||||
|
from_cpp = type_data["from_cpp_ptr"] if type_data.has_key("from_cpp_ptr") else type_data["from_cpp"]
|
||||||
|
ci.method_implementations.write("\treturn " + (from_cpp % {"n": "retVal"}) + ";\n}\n\n")
|
||||||
else:
|
else:
|
||||||
from_cpp = type_data.get("from_cpp", "%(n)s")
|
from_cpp = type_data.get("from_cpp", "%(n)s")
|
||||||
retVal = from_cpp % {"n": (ptr_ref + pi.name)}
|
retVal = from_cpp % {"n": (ptr_ref + pi.name)}
|
||||||
ci.method_implementations.write("-(" + objc_type + ")" + pi.name + "{\n\treturn " + retVal + ";\n}\n\n")
|
ci.method_implementations.write("-(" + objc_type + ")" + pi.name + " {\n\treturn " + retVal + ";\n}\n\n")
|
||||||
if pi.rw:
|
if pi.rw:
|
||||||
if type_data.has_key("v_type"):
|
if type_data.has_key("v_type"):
|
||||||
vector_type = type_data["v_type"]
|
vector_cpp_type = type_data["v_type"]
|
||||||
full_cpp_type = (self.get_namespace_prefix(vector_type) if (vector_type.find("::") == -1) else "") + vector_type
|
has_namespace = vector_cpp_type.find("::") != -1
|
||||||
|
vector_full_cpp_type = self.fullTypeName(vector_cpp_type) if not has_namespace else vector_cpp_type
|
||||||
ci.method_implementations.write("-(void)set" + pi.name[0].upper() + pi.name[1:] + ":(NSArray<" + objc_type + ">*)" + pi.name + "{\n")
|
ci.method_implementations.write("-(void)set" + pi.name[0].upper() + pi.name[1:] + ":(NSArray<" + objc_type + ">*)" + pi.name + "{\n")
|
||||||
prologue = []
|
prologue = []
|
||||||
self.build_objc2cv_prologue(prologue, vector_type, full_cpp_type, objc_type, "valVector", pi.name)
|
self.build_objc2cv_prologue(prologue, vector_cpp_type, vector_full_cpp_type, objc_type, "valVector", pi.name)
|
||||||
ci.method_implementations.write("\t" + ("\n\t".join(prologue)) + "\n")
|
ci.method_implementations.write("\t" + ("\n\t".join(prologue)) + "\n")
|
||||||
ci.method_implementations.write("\t" + ptr_ref + pi.name + " = valVector;\n}\n\n")
|
ci.method_implementations.write("\t" + ptr_ref + pi.name + " = valVector;\n}\n\n")
|
||||||
else:
|
else:
|
||||||
@ -1375,10 +1413,11 @@ if __name__ == "__main__":
|
|||||||
const_private_list += gen_type_dict.get("const_private_list", [])
|
const_private_list += gen_type_dict.get("const_private_list", [])
|
||||||
missing_consts.update(gen_type_dict.get("missing_consts", {}))
|
missing_consts.update(gen_type_dict.get("missing_consts", {}))
|
||||||
type_dict.update(gen_type_dict.get("type_dict", {}))
|
type_dict.update(gen_type_dict.get("type_dict", {}))
|
||||||
AdditionalImports.update(gen_type_dict.get("AdditionalImports", {}))
|
AdditionalImports[module] = gen_type_dict.get("AdditionalImports", {})
|
||||||
ManualFuncs.update(gen_type_dict.get("ManualFuncs", {}))
|
ManualFuncs.update(gen_type_dict.get("ManualFuncs", {}))
|
||||||
func_arg_fix.update(gen_type_dict.get("func_arg_fix", {}))
|
func_arg_fix.update(gen_type_dict.get("func_arg_fix", {}))
|
||||||
enum_fix.update(gen_type_dict.get("enum_fix", {}))
|
enum_fix.update(gen_type_dict.get("enum_fix", {}))
|
||||||
|
const_fix.update(gen_type_dict.get("const_fix", {}))
|
||||||
namespaces_dict.update(gen_type_dict.get("namespaces_dict", {}))
|
namespaces_dict.update(gen_type_dict.get("namespaces_dict", {}))
|
||||||
module_imports += gen_type_dict.get("module_imports", [])
|
module_imports += gen_type_dict.get("module_imports", [])
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"func_arg_fix" : {
|
"func_arg_fix" : {
|
||||||
"(void)fastNlMeansDenoising:(Mat*)src dst:(Mat*)dst h:(FloatVector*)h templateWindowSize:(int)templateWindowSize searchWindowSize:(int)searchWindowSize normType:(int)normType" : { "h" : { "name" : "hVector" } },
|
"Photo": {
|
||||||
"(void)fastNlMeansDenoisingMulti:(NSArray<Mat*>*)srcImgs dst:(Mat*)dst imgToDenoiseIndex:(int)imgToDenoiseIndex temporalWindowSize:(int)temporalWindowSize h:(FloatVector*)h templateWindowSize:(int)templateWindowSize searchWindowSize:(int)searchWindowSize normType:(int)normType" : { "h" : { "name" : "hVector" } }
|
"(void)fastNlMeansDenoising:(Mat*)src dst:(Mat*)dst h:(FloatVector*)h templateWindowSize:(int)templateWindowSize searchWindowSize:(int)searchWindowSize normType:(int)normType" : { "h" : { "name" : "hVector" } },
|
||||||
|
"(void)fastNlMeansDenoisingMulti:(NSArray<Mat*>*)srcImgs dst:(Mat*)dst imgToDenoiseIndex:(int)imgToDenoiseIndex temporalWindowSize:(int)temporalWindowSize h:(FloatVector*)h templateWindowSize:(int)templateWindowSize searchWindowSize:(int)searchWindowSize normType:(int)normType" : { "h" : { "name" : "hVector" } }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"func_arg_fix" : {
|
"func_arg_fix" : {
|
||||||
"(BOOL)open:(int)index apiPreference:(int)apiPreference" : { "open" : {"name" : "openWithIndex"} }
|
"VideoCapture" : {
|
||||||
|
"(BOOL)open:(int)index apiPreference:(int)apiPreference" : { "open" : {"name" : "openWithIndex"} }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user