Merge pull request #17882 from komakai:objc-contrib-wrappers

pull/18031/head
Alexander Alekhin 4 years ago
commit 1192734131
  1. 4
      modules/calib3d/misc/objc/gen_dict.json
  2. 2
      modules/core/misc/objc/common/Float6.mm
  3. 5
      modules/core/misc/objc/common/Point3d.h
  4. 10
      modules/core/misc/objc/common/Point3d.mm
  5. 4
      modules/core/misc/objc/common/Point3f.h
  6. 10
      modules/core/misc/objc/common/Point3f.mm
  7. 5
      modules/core/misc/objc/common/Point3i.h
  8. 10
      modules/core/misc/objc/common/Point3i.mm
  9. 59
      modules/core/misc/objc/gen_dict.json
  10. 36
      modules/dnn/misc/objc/gen_dict.json
  11. 23
      modules/features2d/misc/objc/gen_dict.json
  12. 168
      modules/imgproc/misc/objc/gen_dict.json
  13. 99
      modules/objc/generator/gen_objc.py
  14. 6
      modules/photo/misc/objc/gen_dict.json
  15. 4
      modules/videoio/misc/objc/gen_dict.json

@ -1,5 +1,7 @@
{
"func_arg_fix" : {
"findCirclesGrid" : { "blobDetector" : {"defval" : "cv::SimpleBlobDetector::create()"} }
"Calib3d" : {
"findCirclesGrid" : { "blobDetector" : {"defval" : "cv::SimpleBlobDetector::create()"} }
}
}
}

@ -98,7 +98,7 @@
}
-(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 {

@ -39,6 +39,11 @@ CV_EXPORTS @interface Point3d : NSObject
- (instancetype)initWithPoint:(Point2d*)point;
- (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
#ifdef __cplusplus
+ (instancetype)fromNative:(cv::Point3d&)point;
- (void)update:(cv::Point3d&)point;
#endif
# pragma mark - Methods
/**

@ -65,6 +65,16 @@
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 {
self.x = (vals != nil && vals.count > 0) ? vals[0].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)initWithVals:(NSArray<NSNumber*>*)vals;
#ifdef __cplusplus
+ (instancetype)fromNative:(cv::Point3f&)point;
- (void)update:(cv::Point3f&)point;
#endif
# pragma mark - Methods

@ -65,6 +65,16 @@
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 {
self.x = (vals != nil && vals.count > 0) ? vals[0].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)initWithVals:(NSArray<NSNumber*>*)vals;
#ifdef __cplusplus
+ (instancetype)fromNative:(cv::Point3i&)point;
- (void)update:(cv::Point3i&)point;
#endif
# pragma mark - Methods
/**

@ -66,6 +66,16 @@
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 {
self.x = (vals != nil && vals.count > 0) ? vals[0].intValue : 0;
self.y = (vals != nil && vals.count > 1) ? vals[1].intValue : 0;

@ -55,27 +55,28 @@
}
},
"func_arg_fix" : {
"randu" : { "low" : {"ctype" : "double"},
"high" : {"ctype" : "double"} },
"randn" : { "mean" : {"ctype" : "double"},
"stddev" : {"ctype" : "double"} },
"inRange" : { "lowerb" : {"ctype" : "Scalar"},
"upperb" : {"ctype" : "Scalar"} },
"boundingRect" : { "points" : {"ctype" : "vector_Point"} },
"hconcat" : { "src" : {"ctype" : "vector_Mat"} },
"vconcat" : { "src" : {"ctype" : "vector_Mat"} },
"checkRange" : {"pos" : {"ctype" : "*"} },
"meanStdDev" : { "mean" : {"ctype" : "vector_double"},
"stddev" : {"ctype" : "vector_double"} },
"mixChannels" : { "dst" : {"attrib" : []} },
"rotate" : { "rotateCode" : {"ctype" : "RotateFlags"} },
"norm" : { "normType" : {"ctype" : "NormTypes"} },
"batchDistance" : { "normType" : {"ctype" : "NormTypes"} },
"normalize" : { "norm_type" : {"ctype" : "NormTypes"} },
"compare" : { "cmpop" : {"ctype" : "CmpTypes"} },
"copyMakeBorder" : { "borderType" : {"ctype" : "BorderTypes"} },
"borderInterpolate" : { "borderType" : {"ctype" : "BorderTypes"} },
"(void)divide:(double)scale src2:(Mat*)src2 dst:(Mat*)dst dtype:(int)dtype" : { "src2" : {"name" : "src"} }
"Core": {
"randu" : { "low" : {"ctype" : "double"},
"high" : {"ctype" : "double"} },
"randn" : { "mean" : {"ctype" : "double"},
"stddev" : {"ctype" : "double"} },
"inRange" : { "lowerb" : {"ctype" : "Scalar"},
"upperb" : {"ctype" : "Scalar"} },
"hconcat" : { "src" : {"ctype" : "vector_Mat"} },
"vconcat" : { "src" : {"ctype" : "vector_Mat"} },
"checkRange" : {"pos" : {"ctype" : "*"} },
"meanStdDev" : { "mean" : {"ctype" : "vector_double"},
"stddev" : {"ctype" : "vector_double"} },
"mixChannels" : { "dst" : {"attrib" : []} },
"rotate" : { "rotateCode" : {"ctype" : "RotateFlags"} },
"norm" : { "normType" : {"ctype" : "NormTypes"} },
"batchDistance" : { "normType" : {"ctype" : "NormTypes"} },
"normalize" : { "norm_type" : {"ctype" : "NormTypes"} },
"compare" : { "cmpop" : {"ctype" : "CmpTypes"} },
"copyMakeBorder" : { "borderType" : {"ctype" : "BorderTypes"} },
"borderInterpolate" : { "borderType" : {"ctype" : "BorderTypes"} },
"(void)divide:(double)scale src2:(Mat*)src2 dst:(Mat*)dst dtype:(int)dtype" : { "src2" : {"name" : "src"} }
}
},
"type_dict" : {
"Algorithm": {
@ -227,7 +228,9 @@
"from_cpp": "[Double3 fromNative:%(n)s]"
},
"c_string": {
"objc_type": "NSString*"
"objc_type": "NSString*",
"to_cpp": "%(n)s.UTF8String",
"from_cpp": "[NSString stringWithUTF8String:%(n)s]"
},
"vector_DMatch": {
"objc_type": "DMatch*",
@ -355,6 +358,18 @@
"objc_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": {
"objc_type": "ByteVector*",
"cast_to": "std::vector<char>"

@ -1,21 +1,25 @@
{
"func_arg_fix" : {
"(Net*)readNetFromCaffe:(NSString*)prototxt caffeModel:(NSString*)caffeModel" : { "readNetFromCaffe" : {"name" : "readNetFromCaffeFile"} },
"(Net*)readNetFromCaffe:(ByteVector*)bufferProto bufferModel:(ByteVector*)bufferModel" : { "readNetFromCaffe" : {"name" : "readNetFromCaffeBuffer"} },
"(Net*)readNetFromDarknet:(NSString*)cfgFile darknetModel:(NSString*)darknetModel" : { "readNetFromDarknet" : {"name" : "readNetFromDarknetFile"} },
"(Net*)readNetFromDarknet:(ByteVector*)bufferCfg bufferModel:(ByteVector*)bufferModel" : { "readNetFromDarknet" : {"name" : "readNetFromDarknetBuffer"} },
"(Net*)readNetFromONNX:(NSString*)onnxFile" : { "readNetFromONNX" : {"name" : "readNetFromONNXFile"} },
"(Net*)readNetFromONNX:(ByteVector*)buffer" : { "readNetFromONNX" : {"name" : "readNetFromONNXBuffer"} },
"(Net*)readNetFromTensorflow:(NSString*)model config:(NSString*)config" : { "readNetFromTensorflow" : {"name" : "readNetFromTensorflowFile"} },
"(Net*)readNetFromTensorflow:(ByteVector*)bufferModel bufferConfig:(ByteVector*)bufferConfig" : { "readNetFromTensorflow" : {"name" : "readNetFromTensorflowBuffer"} },
"(void)forward:(NSMutableArray<Mat*>*)outputBlobs outputName:(NSString*)outputName" : { "forward" : {"name" : "forwardOutputBlobs"} },
"(void)forward:(NSMutableArray<Mat*>*)outputBlobs outBlobNames:(NSArray<NSString*>*)outBlobNames" : { "forward" : {"name" : "forwardOutputBlobs"} },
"(long)getFLOPS:(IntVector*)netInputShape" : { "getFLOPS" : {"name" : "getFLOPSWithNetInputShape"} },
"(long)getFLOPS:(NSArray<IntVector*>*)netInputShapes" : { "getFLOPS" : {"name" : "getFLOPSWithNetInputShapes"} },
"(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"} }
"Dnn": {
"(Net*)readNetFromCaffe:(NSString*)prototxt caffeModel:(NSString*)caffeModel" : { "readNetFromCaffe" : {"name" : "readNetFromCaffeFile"} },
"(Net*)readNetFromCaffe:(ByteVector*)bufferProto bufferModel:(ByteVector*)bufferModel" : { "readNetFromCaffe" : {"name" : "readNetFromCaffeBuffer"} },
"(Net*)readNetFromDarknet:(NSString*)cfgFile darknetModel:(NSString*)darknetModel" : { "readNetFromDarknet" : {"name" : "readNetFromDarknetFile"} },
"(Net*)readNetFromDarknet:(ByteVector*)bufferCfg bufferModel:(ByteVector*)bufferModel" : { "readNetFromDarknet" : {"name" : "readNetFromDarknetBuffer"} },
"(Net*)readNetFromONNX:(NSString*)onnxFile" : { "readNetFromONNX" : {"name" : "readNetFromONNXFile"} },
"(Net*)readNetFromONNX:(ByteVector*)buffer" : { "readNetFromONNX" : {"name" : "readNetFromONNXBuffer"} },
"(Net*)readNetFromTensorflow:(NSString*)model config:(NSString*)config" : { "readNetFromTensorflow" : {"name" : "readNetFromTensorflowFile"} },
"(Net*)readNetFromTensorflow:(ByteVector*)bufferModel bufferConfig:(ByteVector*)bufferConfig" : { "readNetFromTensorflow" : {"name" : "readNetFromTensorflowBuffer"} }
},
"Net": {
"(void)forward:(NSMutableArray<Mat*>*)outputBlobs outputName:(NSString*)outputName" : { "forward" : {"name" : "forwardOutputBlobs"} },
"(void)forward:(NSMutableArray<Mat*>*)outputBlobs outBlobNames:(NSArray<NSString*>*)outBlobNames" : { "forward" : {"name" : "forwardOutputBlobs"} },
"(long)getFLOPS:(IntVector*)netInputShape" : { "getFLOPS" : {"name" : "getFLOPSWithNetInputShape"} },
"(long)getFLOPS:(NSArray<IntVector*>*)netInputShapes" : { "getFLOPS" : {"name" : "getFLOPSWithNetInputShapes"} },
"(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": {
"MatShape": {

@ -4,13 +4,20 @@
"AgastFeatureDetector" : { "DetectorType": "AgastDetectorType" }
},
"func_arg_fix" : {
"(void)compute:(NSArray<Mat*>*)images keypoints:(NSMutableArray<NSMutableArray<KeyPoint*>*>*)keypoints descriptors:(NSMutableArray<Mat*>*)descriptors" : { "compute" : {"name" : "compute2"} },
"(void)detect:(NSArray<Mat*>*)images keypoints:(NSMutableArray<NSMutableArray<KeyPoint*>*>*)keypoints masks:(NSArray<Mat*>*)masks" : { "detect" : {"name" : "detect2"} },
"(DescriptorMatcher*)create:(NSString*)descriptorMatcherType" : { "create" : {"name" : "create2"} },
"FlannBasedMatcher": { "indexParams" : {"defval" : "cv::makePtr<cv::flann::KDTreeIndexParams>()"}, "searchParams" : {"defval" : "cv::makePtr<cv::flann::SearchParams>()"} },
"(SimpleBlobDetector*)create" : { "parameters" : {"defval" : "cv::SimpleBlobDetector::Params()"} },
"BFMatcher" : { "normType" : {"ctype" : "NormTypes"} },
"(BFMatcher*)create:(int)normType crossCheck:(BOOL)crossCheck" : { "create" : {"name" : "createBFMatcher"},
"normType" : {"ctype" : "NormTypes"} }
"Feature2D": {
"(void)compute:(NSArray<Mat*>*)images keypoints:(NSMutableArray<NSMutableArray<KeyPoint*>*>*)keypoints descriptors:(NSMutableArray<Mat*>*)descriptors" : { "compute" : {"name" : "compute2"} },
"(void)detect:(NSArray<Mat*>*)images keypoints:(NSMutableArray<NSMutableArray<KeyPoint*>*>*)keypoints masks:(NSArray<Mat*>*)masks" : { "detect" : {"name" : "detect2"} }
},
"DescriptorMatcher": {
"(DescriptorMatcher*)create:(NSString*)descriptorMatcherType" : { "create" : {"name" : "create2"} }
},
"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" : {
"goodFeaturesToTrack" : { "corners" : {"ctype" : "vector_Point"} },
"minEnclosingCircle" : { "points" : {"ctype" : "vector_Point2f"} },
"fitEllipse" : { "points" : {"ctype" : "vector_Point2f"} },
"fillPoly" : { "pts" : {"ctype" : "vector_vector_Point"},
"lineType" : {"ctype" : "LineTypes"}},
"polylines" : { "pts" : {"ctype" : "vector_vector_Point"},
"lineType" : {"ctype" : "LineTypes"} },
"fillConvexPoly" : { "points" : {"ctype" : "vector_Point"},
"Imgproc" : {
"goodFeaturesToTrack" : { "corners" : {"ctype" : "vector_Point"} },
"minEnclosingCircle" : { "points" : {"ctype" : "vector_Point2f"} },
"fitEllipse" : { "points" : {"ctype" : "vector_Point2f"} },
"fillPoly" : { "pts" : {"ctype" : "vector_vector_Point"},
"lineType" : {"ctype" : "LineTypes"}},
"polylines" : { "pts" : {"ctype" : "vector_vector_Point"},
"lineType" : {"ctype" : "LineTypes"} },
"approxPolyDP" : { "curve" : {"ctype" : "vector_Point2f"},
"approxCurve" : {"ctype" : "vector_Point2f"} },
"arcLength" : { "curve" : {"ctype" : "vector_Point2f"} },
"pointPolygonTest" : { "contour" : {"ctype" : "vector_Point2f"} },
"minAreaRect" : { "points" : {"ctype" : "vector_Point2f"} },
"getAffineTransform" : { "src" : {"ctype" : "vector_Point2f"},
"dst" : {"ctype" : "vector_Point2f"} },
"drawContours" : { "contours" : {"ctype" : "vector_vector_Point"},
"lineType" : {"ctype" : "LineTypes"} },
"findContours" : { "contours" : {"ctype" : "vector_vector_Point"},
"mode" : {"ctype" : "RetrievalModes"},
"method" : {"ctype" : "ContourApproximationModes"} },
"convexityDefects" : { "contour" : {"ctype" : "vector_Point"},
"convexhull" : {"ctype" : "vector_int"},
"convexityDefects" : {"ctype" : "vector_Vec4i"} },
"isContourConvex" : { "contour" : {"ctype" : "vector_Point"} },
"convexHull" : { "points" : {"ctype" : "vector_Point"},
"hull" : {"ctype" : "vector_int"},
"returnPoints" : {"ctype" : ""} },
"getStructuringElement" : { "shape" : {"ctype" : "MorphShapes"} },
"EMD" : {"lowerBound" : {"defval" : "cv::Ptr<float>()"},
"distType" : {"ctype" : "DistanceTypes"}},
"createLineSegmentDetector" : { "_refine" : {"ctype" : "LineSegmentDetectorModes"}},
"compareHist" : { "method" : {"ctype" : "HistCompMethods"}},
"matchShapes" : { "method" : {"ctype" : "ShapeMatchModes"}},
"threshold" : { "type" : {"ctype" : "ThresholdTypes"}},
"connectedComponentsWithStatsWithAlgorithm" : { "ccltype" : {"ctype" : "ConnectedComponentsAlgorithmsTypes"}},
"GaussianBlur" : { "borderType" : {"ctype" : "BorderTypes"}},
"HoughCircles" : { "method" : {"ctype" : "HoughModes"}},
"Laplacian" : { "borderType" : {"ctype" : "BorderTypes"}},
"Scharr" : { "borderType" : {"ctype" : "BorderTypes"}},
"Sobel" : { "borderType" : {"ctype" : "BorderTypes"}},
"adaptiveThreshold" : { "adaptiveMethod" : {"ctype" : "AdaptiveThresholdTypes"},
"thresholdType" : {"ctype" : "ThresholdTypes"}},
"applyColorMap" : { "colormap" : {"ctype" : "ColormapTypes"}},
"arrowedLine" : { "line_type" : {"ctype" : "LineTypes"}},
"bilateralFilter" : { "borderType" : {"ctype" : "BorderTypes"}},
"blur" : { "borderType" : {"ctype" : "BorderTypes"}},
"boxFilter" : { "borderType" : {"ctype" : "BorderTypes"}},
"circle" : { "lineType" : {"ctype" : "LineTypes"}},
"cornerEigenValsAndVecs" : { "borderType" : {"ctype" : "BorderTypes"}},
"cornerHarris" : { "borderType" : {"ctype" : "BorderTypes"}},
"cornerMinEigenVal" : { "borderType" : {"ctype" : "BorderTypes"}},
"cvtColor" : { "code" : {"ctype" : "ColorConversionCodes"}},
"dilate" : { "borderType" : {"ctype" : "BorderTypes"}},
"distanceTransformWithLabels" : { "labelType" : {"ctype" : "DistanceTransformLabelTypes"},
"distanceType" : {"ctype" : "DistanceTypes"},
"maskSize" : {"ctype" : "DistanceTransformMasks"}},
"distanceTransform" : { "distanceType" : {"ctype" : "DistanceTypes"},
"maskSize" : {"ctype" : "DistanceTransformMasks"}},
"drawMarker" : { "markerType" : {"ctype" : "MarkerTypes"},
"line_type" : {"ctype" : "LineTypes"}},
"ellipse" : { "lineType" : {"ctype" : "LineTypes"}},
"erode" : { "borderType" : {"ctype" : "BorderTypes"}},
"filter2D" : { "borderType" : {"ctype" : "BorderTypes"}},
"fitLine" : { "distType" : {"ctype" : "DistanceTypes"}},
"line" : { "lineType" : {"ctype" : "LineTypes"}},
"matchTemplate" : { "method" : {"ctype" : "TemplateMatchModes"}},
"morphologyEx" : { "op" : {"ctype" : "MorphTypes"},
"borderType" : {"ctype" : "BorderTypes"}},
"preCornerDetect" : { "borderType" : {"ctype" : "BorderTypes"}},
"putText" : { "fontFace" : {"ctype" : "HersheyFonts"},
"lineType" : {"ctype" : "LineTypes"}},
"pyrDown" : { "borderType" : {"ctype" : "BorderTypes"}},
"pyrUp" : { "borderType" : {"ctype" : "BorderTypes"}},
"rectangle" : { "lineType" : {"ctype" : "LineTypes"}},
"remap" : { "borderMode": {"ctype" : "BorderTypes"}},
"sepFilter2D" : { "borderType" : {"ctype" : "BorderTypes"}},
"spatialGradient" : { "borderType" : {"ctype" : "BorderTypes"}},
"sqrBoxFilter" : { "borderType" : {"ctype" : "BorderTypes"}},
"warpAffine" : { "borderMode": {"ctype" : "BorderTypes"}},
"warpPerspective" : { "borderMode": {"ctype" : "BorderTypes"}},
"getTextSize" : { "fontFace": {"ctype" : "HersheyFonts"}},
"(void)insert:(NSArray<Point2f*>*)ptvec" : { "insert" : {"name" : "insertVector"} }
"fillConvexPoly" : { "points" : {"ctype" : "vector_Point"},
"lineType" : {"ctype" : "LineTypes"} },
"approxPolyDP" : { "curve" : {"ctype" : "vector_Point2f"},
"approxCurve" : {"ctype" : "vector_Point2f"} },
"arcLength" : { "curve" : {"ctype" : "vector_Point2f"} },
"pointPolygonTest" : { "contour" : {"ctype" : "vector_Point2f"} },
"minAreaRect" : { "points" : {"ctype" : "vector_Point2f"} },
"getAffineTransform" : { "src" : {"ctype" : "vector_Point2f"},
"dst" : {"ctype" : "vector_Point2f"} },
"drawContours" : { "contours" : {"ctype" : "vector_vector_Point"},
"lineType" : {"ctype" : "LineTypes"} },
"findContours" : { "contours" : {"ctype" : "vector_vector_Point"},
"mode" : {"ctype" : "RetrievalModes"},
"method" : {"ctype" : "ContourApproximationModes"} },
"convexityDefects" : { "contour" : {"ctype" : "vector_Point"},
"convexhull" : {"ctype" : "vector_int"},
"convexityDefects" : {"ctype" : "vector_Vec4i"} },
"isContourConvex" : { "contour" : {"ctype" : "vector_Point"} },
"convexHull" : { "points" : {"ctype" : "vector_Point"},
"hull" : {"ctype" : "vector_int"},
"returnPoints" : {"ctype" : ""} },
"getStructuringElement" : { "shape" : {"ctype" : "MorphShapes"} },
"EMD" : {"lowerBound" : {"defval" : "cv::Ptr<float>()"},
"distType" : {"ctype" : "DistanceTypes"}},
"createLineSegmentDetector" : { "_refine" : {"ctype" : "LineSegmentDetectorModes"}},
"compareHist" : { "method" : {"ctype" : "HistCompMethods"}},
"matchShapes" : { "method" : {"ctype" : "ShapeMatchModes"}},
"threshold" : { "type" : {"ctype" : "ThresholdTypes"}},
"connectedComponentsWithStatsWithAlgorithm" : { "ccltype" : {"ctype" : "ConnectedComponentsAlgorithmsTypes"}},
"GaussianBlur" : { "borderType" : {"ctype" : "BorderTypes"}},
"HoughCircles" : { "method" : {"ctype" : "HoughModes"}},
"Laplacian" : { "borderType" : {"ctype" : "BorderTypes"}},
"Scharr" : { "borderType" : {"ctype" : "BorderTypes"}},
"Sobel" : { "borderType" : {"ctype" : "BorderTypes"}},
"adaptiveThreshold" : { "adaptiveMethod" : {"ctype" : "AdaptiveThresholdTypes"},
"thresholdType" : {"ctype" : "ThresholdTypes"}},
"applyColorMap" : { "colormap" : {"ctype" : "ColormapTypes"}},
"arrowedLine" : { "line_type" : {"ctype" : "LineTypes"}},
"bilateralFilter" : { "borderType" : {"ctype" : "BorderTypes"}},
"blur" : { "borderType" : {"ctype" : "BorderTypes"}},
"boxFilter" : { "borderType" : {"ctype" : "BorderTypes"}},
"circle" : { "lineType" : {"ctype" : "LineTypes"}},
"cornerEigenValsAndVecs" : { "borderType" : {"ctype" : "BorderTypes"}},
"cornerHarris" : { "borderType" : {"ctype" : "BorderTypes"}},
"cornerMinEigenVal" : { "borderType" : {"ctype" : "BorderTypes"}},
"cvtColor" : { "code" : {"ctype" : "ColorConversionCodes"}},
"dilate" : { "borderType" : {"ctype" : "BorderTypes"}},
"distanceTransformWithLabels" : { "labelType" : {"ctype" : "DistanceTransformLabelTypes"},
"distanceType" : {"ctype" : "DistanceTypes"},
"maskSize" : {"ctype" : "DistanceTransformMasks"}},
"distanceTransform" : { "distanceType" : {"ctype" : "DistanceTypes"},
"maskSize" : {"ctype" : "DistanceTransformMasks"}},
"drawMarker" : { "markerType" : {"ctype" : "MarkerTypes"},
"line_type" : {"ctype" : "LineTypes"}},
"ellipse" : { "lineType" : {"ctype" : "LineTypes"}},
"erode" : { "borderType" : {"ctype" : "BorderTypes"}},
"filter2D" : { "borderType" : {"ctype" : "BorderTypes"}},
"fitLine" : { "distType" : {"ctype" : "DistanceTypes"}},
"line" : { "lineType" : {"ctype" : "LineTypes"}},
"matchTemplate" : { "method" : {"ctype" : "TemplateMatchModes"}},
"morphologyEx" : { "op" : {"ctype" : "MorphTypes"},
"borderType" : {"ctype" : "BorderTypes"}},
"preCornerDetect" : { "borderType" : {"ctype" : "BorderTypes"}},
"putText" : { "fontFace" : {"ctype" : "HersheyFonts"},
"lineType" : {"ctype" : "LineTypes"}},
"pyrDown" : { "borderType" : {"ctype" : "BorderTypes"}},
"pyrUp" : { "borderType" : {"ctype" : "BorderTypes"}},
"rectangle" : { "lineType" : {"ctype" : "LineTypes"}},
"remap" : { "borderMode": {"ctype" : "BorderTypes"}},
"sepFilter2D" : { "borderType" : {"ctype" : "BorderTypes"}},
"spatialGradient" : { "borderType" : {"ctype" : "BorderTypes"}},
"sqrBoxFilter" : { "borderType" : {"ctype" : "BorderTypes"}},
"warpAffine" : { "borderMode": {"ctype" : "BorderTypes"}},
"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
namespaces_dict = {}
# { class : [ header ] }
# { module: { class | "*" : [ header ]} }
AdditionalImports = {}
# { class : { func : {declaration, implementation} } }
@ -74,6 +74,9 @@ func_arg_fix = {}
# { class : { enum: fixed_enum } }
enum_fix = {}
# { class : { enum: { const: fixed_const} } }
const_fix = {}
# { (class, func) : objc_signature }
method_dict = {
("Mat", "convertTo") : "-convertTo:rtype:alpha:beta:",
@ -226,14 +229,15 @@ class ClassPropInfo():
class ClassInfo(GeneralInfo):
def __init__(self, decl, namespaces=[]): # [ 'class/struct cname', ': base', [modlist] ]
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_suffixes = {}
self.consts = [] # using a list to save the occurrence order
self.private_consts = []
self.imports = set()
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.additionalImports = None # additional import files
self.enum_declarations = None # Objective-C enum declarations stream
@ -422,10 +426,12 @@ class ArgInfo():
defval=self.defval)
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)
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.cv_name = self.fullName(isCPP=True)
self.isconstructor = self.name == self.classname
@ -439,7 +445,7 @@ class FuncInfo(GeneralInfo):
self.static = ["","static"][ "/S" in decl[2] ]
self.ctype = re.sub(r"^CvTermCriteria", "TermCriteria", decl[1] or "")
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]:
arg = a[:]
arg_fix_map = func_fix_map.get(arg[1], {})
@ -449,7 +455,7 @@ class FuncInfo(GeneralInfo):
self.args.append(ArgInfo(arg))
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, {})
self.objc_name = name_fix_map.get('name', self.objc_name)
for arg in self.args:
@ -574,14 +580,14 @@ class ObjectiveCWrapperGenerator(object):
self.skipped_func_list = []
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)
if classinfo.name in class_ignore_list:
logging.info('ignored: %s', classinfo)
return
if classinfo.name != module:
self.classes[module].member_classes.append(classinfo.name)
name = classinfo.name
if classinfo.name != self.Module:
self.classes[self.Module].member_classes.append(classinfo.objc_name)
name = classinfo.cname
if self.isWrapped(name) and not classinfo.base:
logging.warning('duplicated: %s', classinfo)
return
@ -613,9 +619,11 @@ class ObjectiveCWrapperGenerator(object):
type_dict.setdefault("Ptr_"+name, {}).update(
{ "objc_type" : classinfo.objc_name + "*",
"c_type" : name,
"real_c_type" : classinfo.real_cname,
"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)
def add_const(self, decl, scope=None, enumType=None): # [ "const cname", val, [], [] ]
@ -623,6 +631,12 @@ class ObjectiveCWrapperGenerator(object):
if constinfo.isIgnored():
logging.info('ignored: %s', constinfo)
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):
logging.info('class not found: %s', constinfo)
constinfo.name = constinfo.classname + '_' + constinfo.name
@ -668,7 +682,7 @@ class ObjectiveCWrapperGenerator(object):
self.add_const(decl, self.Module, enumType)
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
if classname in class_ignore_list:
logging.info('ignored: %s', fi)
@ -709,7 +723,7 @@ class ObjectiveCWrapperGenerator(object):
# TODO: support UMat versions of declarations (implement UMat-wrapper for Java)
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
includes = []
@ -729,7 +743,7 @@ class ObjectiveCWrapperGenerator(object):
logging.info("\n--- Incoming ---\n%s", pformat(decl[:5], 4)) # without docstring
name = decl[0]
if name.startswith("struct") or name.startswith("class"):
self.add_class(decl, self.Module)
self.add_class(decl)
elif name.startswith("const"):
self.add_const(decl)
elif name.startswith("enum"):
@ -745,7 +759,7 @@ class ObjectiveCWrapperGenerator(object):
if ci.name == "Mat":
continue
ci.initCodeStreams(self.Module)
self.gen_class(ci)
self.gen_class(ci, self.module)
classObjcHeaderCode = ci.generateObjcHeaderCode(self.module, self.Module, ci.objc_name)
header_file = "%s/%s/%s.h" % (output_objc_path, module, ci.objc_name)
self.save(header_file, classObjcHeaderCode)
@ -952,8 +966,9 @@ class ObjectiveCWrapperGenerator(object):
epilogue.append("CV2OBJC2(" + cpp_type + ", " + objc_type[:-1] + ", retValVector, retVal);")
elif ret_type.startswith("Ptr_"):
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)
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];"
elif ret_type == "void":
ret_val = ""
@ -1027,10 +1042,15 @@ class ObjectiveCWrapperGenerator(object):
else:
break
def gen_class(self, ci):
def gen_class(self, ci, module):
logging.info("%s", ci)
if ci.name in AdditionalImports:
ci.additionalImports.write("\n".join(["#import %s" % h for h in AdditionalImports[ci.name]]))
if module in AdditionalImports and (ci.name in AdditionalImports[module] or "*" in AdditionalImports[module]):
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
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")
ptr_ref = "self." + ci.native_ptr_name + "->" if not ci.is_base_class else "self.nativePtr->"
if type_data.has_key("v_type"):
vector_type = type_data["v_type"]
full_cpp_type = (self.get_namespace_prefix(vector_type) if (vector_type.find("::") == -1) else "") + vector_type
ret_val = "std::vector<" + full_cpp_type + "> retValVector = "
ci.method_implementations.write("-(NSArray<" + objc_type + ">*)" + pi.name + "{\n")
vector_cpp_type = type_data["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<" + 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("\t" + ret_val + ptr_ref + pi.name + ";\n")
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("\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:
from_cpp = type_data.get("from_cpp", "%(n)s")
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 type_data.has_key("v_type"):
vector_type = type_data["v_type"]
full_cpp_type = (self.get_namespace_prefix(vector_type) if (vector_type.find("::") == -1) else "") + vector_type
vector_cpp_type = type_data["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
ci.method_implementations.write("-(void)set" + pi.name[0].upper() + pi.name[1:] + ":(NSArray<" + objc_type + ">*)" + pi.name + "{\n")
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" + ptr_ref + pi.name + " = valVector;\n}\n\n")
else:
@ -1375,10 +1413,11 @@ if __name__ == "__main__":
const_private_list += gen_type_dict.get("const_private_list", [])
missing_consts.update(gen_type_dict.get("missing_consts", {}))
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", {}))
func_arg_fix.update(gen_type_dict.get("func_arg_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", {}))
module_imports += gen_type_dict.get("module_imports", [])

@ -1,6 +1,8 @@
{
"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" } },
"(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" } }
"Photo": {
"(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" : {
"(BOOL)open:(int)index apiPreference:(int)apiPreference" : { "open" : {"name" : "openWithIndex"} }
"VideoCapture" : {
"(BOOL)open:(int)index apiPreference:(int)apiPreference" : { "open" : {"name" : "openWithIndex"} }
}
}
}

Loading…
Cancel
Save