vendor: OpenCV 5.0.0 snapshot at 40738fb16ceddb5fb3fea747585f7ce6abb0605b
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"const_ignore_list": [
|
||||
"CV_TM_.+",
|
||||
"CV_COLORCVT_MAX",
|
||||
"CV_.*Bayer.*",
|
||||
"CV_YUV420(i|sp|p)2.+",
|
||||
"CV_L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV)\\d*2L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV).*",
|
||||
"CV_FLOODFILL_.+",
|
||||
"CV_ADAPTIVE_THRESH_.+"
|
||||
],
|
||||
"const_private_list" : [
|
||||
"CV_MOP_.+",
|
||||
"CV_INTER_.+",
|
||||
"CV_THRESH_.+",
|
||||
"CV_INPAINT_.+",
|
||||
"CV_RETR_.+",
|
||||
"CV_CHAIN_APPROX_.+"
|
||||
],
|
||||
"missing_consts" : {
|
||||
"Imgproc" : {
|
||||
"private" : [
|
||||
["IPL_BORDER_CONSTANT", 0 ],
|
||||
["IPL_BORDER_REPLICATE", 1 ],
|
||||
["IPL_BORDER_REFLECT", 2 ],
|
||||
["IPL_BORDER_WRAP", 3 ],
|
||||
["IPL_BORDER_REFLECT_101", 4 ],
|
||||
["IPL_BORDER_TRANSPARENT", 5 ]
|
||||
]
|
||||
}
|
||||
},
|
||||
"ManualFuncs" : {
|
||||
"Imgproc" : {
|
||||
"getTextSize" : {
|
||||
"j_code" : [
|
||||
"\n",
|
||||
"// C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine);",
|
||||
"//javadoc:getTextSize(text, fontFace, fontScale, thickness, baseLine)",
|
||||
"public static Size getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine) {",
|
||||
" if(baseLine != null && baseLine.length != 1)",
|
||||
" throw new java.lang.IllegalArgumentException(\"'baseLine' must be 'int[1]' or 'null'.\");",
|
||||
" Size retVal = new Size(n_getTextSize(text, fontFace, fontScale, thickness, baseLine));",
|
||||
" return retVal;",
|
||||
"}",
|
||||
"\n"
|
||||
],
|
||||
"jn_code" : [
|
||||
"private static native double[] n_getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine);\n"
|
||||
],
|
||||
"cpp_code" : [
|
||||
"\n",
|
||||
" // C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine);",
|
||||
" JNIEXPORT jdoubleArray JNICALL Java_org_opencv_imgproc_Imgproc_n_1getTextSize (JNIEnv*, jclass, jstring, jint, jdouble, jint, jintArray);",
|
||||
"\n",
|
||||
" JNIEXPORT jdoubleArray JNICALL Java_org_opencv_imgproc_Imgproc_n_1getTextSize",
|
||||
" (JNIEnv* env, jclass, jstring text, jint fontFace, jdouble fontScale, jint thickness, jintArray baseLine)",
|
||||
" {",
|
||||
" try {",
|
||||
" LOGD(\"Core::n_1getTextSize()\");",
|
||||
" jdoubleArray result;",
|
||||
" result = env->NewDoubleArray(2);",
|
||||
" if (result == NULL) {",
|
||||
" return NULL; /* out of memory error thrown */",
|
||||
" }",
|
||||
"\n",
|
||||
" const char* utf_text = env->GetStringUTFChars(text, 0);",
|
||||
" String n_text( utf_text ? utf_text : \"\" );",
|
||||
" env->ReleaseStringUTFChars(text, utf_text);",
|
||||
"\n",
|
||||
" int _baseLine;",
|
||||
" int* pbaseLine = 0;",
|
||||
"\n",
|
||||
" if (baseLine != NULL)",
|
||||
" pbaseLine = &_baseLine;",
|
||||
"\n",
|
||||
" cv::Size rsize = cv::getTextSize(n_text, (int)fontFace, (double)fontScale, (int)thickness, pbaseLine);",
|
||||
"\n",
|
||||
" jdouble fill[2];",
|
||||
" fill[0]=rsize.width;",
|
||||
" fill[1]=rsize.height;",
|
||||
"\n",
|
||||
" env->SetDoubleArrayRegion(result, 0, 2, fill);",
|
||||
"\n",
|
||||
" if (baseLine != NULL) {",
|
||||
" jint jbaseLine = (jint)(*pbaseLine);",
|
||||
" env->SetIntArrayRegion(baseLine, 0, 1, &jbaseLine);",
|
||||
" }",
|
||||
"\n",
|
||||
" return result;",
|
||||
"\n",
|
||||
" } catch(const cv::Exception& e) {",
|
||||
" LOGD(\"Imgproc::n_1getTextSize() caught cv::Exception: %s\", e.what());",
|
||||
" jclass je = env->FindClass(\"org/opencv/core/CvException\");",
|
||||
" if(!je) je = env->FindClass(\"java/lang/Exception\");",
|
||||
" env->ThrowNew(je, e.what());",
|
||||
" return NULL;",
|
||||
" } catch (...) {",
|
||||
" LOGD(\"Imgproc::n_1getTextSize() caught unknown exception (...)\");",
|
||||
" jclass je = env->FindClass(\"java/lang/Exception\");",
|
||||
" env->ThrowNew(je, \"Unknown exception in JNI code {core::getTextSize()}\");",
|
||||
" return NULL;",
|
||||
" }",
|
||||
" }"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"func_arg_fix" : {
|
||||
"drawContours" : {"contours" : {"ctype" : "vector_vector_Point"} },
|
||||
"findContours" : {"contours" : {"ctype" : "vector_vector_Point"} }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
package org.opencv.imgproc;
|
||||
|
||||
//javadoc:Moments
|
||||
public class Moments {
|
||||
|
||||
public double m00;
|
||||
public double m10;
|
||||
public double m01;
|
||||
public double m20;
|
||||
public double m11;
|
||||
public double m02;
|
||||
public double m30;
|
||||
public double m21;
|
||||
public double m12;
|
||||
public double m03;
|
||||
|
||||
public double mu20;
|
||||
public double mu11;
|
||||
public double mu02;
|
||||
public double mu30;
|
||||
public double mu21;
|
||||
public double mu12;
|
||||
public double mu03;
|
||||
|
||||
public double nu20;
|
||||
public double nu11;
|
||||
public double nu02;
|
||||
public double nu30;
|
||||
public double nu21;
|
||||
public double nu12;
|
||||
public double nu03;
|
||||
|
||||
public Moments(
|
||||
double m00,
|
||||
double m10,
|
||||
double m01,
|
||||
double m20,
|
||||
double m11,
|
||||
double m02,
|
||||
double m30,
|
||||
double m21,
|
||||
double m12,
|
||||
double m03)
|
||||
{
|
||||
this.m00 = m00;
|
||||
this.m10 = m10;
|
||||
this.m01 = m01;
|
||||
this.m20 = m20;
|
||||
this.m11 = m11;
|
||||
this.m02 = m02;
|
||||
this.m30 = m30;
|
||||
this.m21 = m21;
|
||||
this.m12 = m12;
|
||||
this.m03 = m03;
|
||||
this.completeState();
|
||||
}
|
||||
|
||||
public Moments() {
|
||||
this(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public Moments(double[] vals) {
|
||||
set(vals);
|
||||
}
|
||||
|
||||
public void set(double[] vals) {
|
||||
if (vals != null) {
|
||||
m00 = vals.length > 0 ? vals[0] : 0;
|
||||
m10 = vals.length > 1 ? vals[1] : 0;
|
||||
m01 = vals.length > 2 ? vals[2] : 0;
|
||||
m20 = vals.length > 3 ? vals[3] : 0;
|
||||
m11 = vals.length > 4 ? vals[4] : 0;
|
||||
m02 = vals.length > 5 ? vals[5] : 0;
|
||||
m30 = vals.length > 6 ? vals[6] : 0;
|
||||
m21 = vals.length > 7 ? vals[7] : 0;
|
||||
m12 = vals.length > 8 ? vals[8] : 0;
|
||||
m03 = vals.length > 9 ? vals[9] : 0;
|
||||
this.completeState();
|
||||
} else {
|
||||
m00 = 0;
|
||||
m10 = 0;
|
||||
m01 = 0;
|
||||
m20 = 0;
|
||||
m11 = 0;
|
||||
m02 = 0;
|
||||
m30 = 0;
|
||||
m21 = 0;
|
||||
m12 = 0;
|
||||
m03 = 0;
|
||||
mu20 = 0;
|
||||
mu11 = 0;
|
||||
mu02 = 0;
|
||||
mu30 = 0;
|
||||
mu21 = 0;
|
||||
mu12 = 0;
|
||||
mu03 = 0;
|
||||
nu20 = 0;
|
||||
nu11 = 0;
|
||||
nu02 = 0;
|
||||
nu30 = 0;
|
||||
nu21 = 0;
|
||||
nu12 = 0;
|
||||
nu03 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Moments [ " +
|
||||
"\n" +
|
||||
"m00=" + m00 + ", " +
|
||||
"\n" +
|
||||
"m10=" + m10 + ", " +
|
||||
"m01=" + m01 + ", " +
|
||||
"\n" +
|
||||
"m20=" + m20 + ", " +
|
||||
"m11=" + m11 + ", " +
|
||||
"m02=" + m02 + ", " +
|
||||
"\n" +
|
||||
"m30=" + m30 + ", " +
|
||||
"m21=" + m21 + ", " +
|
||||
"m12=" + m12 + ", " +
|
||||
"m03=" + m03 + ", " +
|
||||
"\n" +
|
||||
"mu20=" + mu20 + ", " +
|
||||
"mu11=" + mu11 + ", " +
|
||||
"mu02=" + mu02 + ", " +
|
||||
"\n" +
|
||||
"mu30=" + mu30 + ", " +
|
||||
"mu21=" + mu21 + ", " +
|
||||
"mu12=" + mu12 + ", " +
|
||||
"mu03=" + mu03 + ", " +
|
||||
"\n" +
|
||||
"nu20=" + nu20 + ", " +
|
||||
"nu11=" + nu11 + ", " +
|
||||
"nu02=" + nu02 + ", " +
|
||||
"\n" +
|
||||
"nu30=" + nu30 + ", " +
|
||||
"nu21=" + nu21 + ", " +
|
||||
"nu12=" + nu12 + ", " +
|
||||
"nu03=" + nu03 + ", " +
|
||||
"\n]";
|
||||
}
|
||||
|
||||
protected void completeState()
|
||||
{
|
||||
double cx = 0, cy = 0;
|
||||
double mu20, mu11, mu02;
|
||||
double inv_m00 = 0.0;
|
||||
|
||||
if( Math.abs(this.m00) > 0.00000001 )
|
||||
{
|
||||
inv_m00 = 1. / this.m00;
|
||||
cx = this.m10 * inv_m00;
|
||||
cy = this.m01 * inv_m00;
|
||||
}
|
||||
|
||||
// mu20 = m20 - m10*cx
|
||||
mu20 = this.m20 - this.m10 * cx;
|
||||
// mu11 = m11 - m10*cy
|
||||
mu11 = this.m11 - this.m10 * cy;
|
||||
// mu02 = m02 - m01*cy
|
||||
mu02 = this.m02 - this.m01 * cy;
|
||||
|
||||
this.mu20 = mu20;
|
||||
this.mu11 = mu11;
|
||||
this.mu02 = mu02;
|
||||
|
||||
// mu30 = m30 - cx*(3*mu20 + cx*m10)
|
||||
this.mu30 = this.m30 - cx * (3 * mu20 + cx * this.m10);
|
||||
mu11 += mu11;
|
||||
// mu21 = m21 - cx*(2*mu11 + cx*m01) - cy*mu20
|
||||
this.mu21 = this.m21 - cx * (mu11 + cx * this.m01) - cy * mu20;
|
||||
// mu12 = m12 - cy*(2*mu11 + cy*m10) - cx*mu02
|
||||
this.mu12 = this.m12 - cy * (mu11 + cy * this.m10) - cx * mu02;
|
||||
// mu03 = m03 - cy*(3*mu02 + cy*m01)
|
||||
this.mu03 = this.m03 - cy * (3 * mu02 + cy * this.m01);
|
||||
|
||||
|
||||
double inv_sqrt_m00 = Math.sqrt(Math.abs(inv_m00));
|
||||
double s2 = inv_m00*inv_m00, s3 = s2*inv_sqrt_m00;
|
||||
|
||||
this.nu20 = this.mu20*s2;
|
||||
this.nu11 = this.mu11*s2;
|
||||
this.nu02 = this.mu02*s2;
|
||||
this.nu30 = this.mu30*s3;
|
||||
this.nu21 = this.mu21*s3;
|
||||
this.nu12 = this.mu12*s3;
|
||||
this.nu03 = this.mu03*s3;
|
||||
|
||||
}
|
||||
|
||||
public double get_m00() { return this.m00; }
|
||||
public double get_m10() { return this.m10; }
|
||||
public double get_m01() { return this.m01; }
|
||||
public double get_m20() { return this.m20; }
|
||||
public double get_m11() { return this.m11; }
|
||||
public double get_m02() { return this.m02; }
|
||||
public double get_m30() { return this.m30; }
|
||||
public double get_m21() { return this.m21; }
|
||||
public double get_m12() { return this.m12; }
|
||||
public double get_m03() { return this.m03; }
|
||||
public double get_mu20() { return this.mu20; }
|
||||
public double get_mu11() { return this.mu11; }
|
||||
public double get_mu02() { return this.mu02; }
|
||||
public double get_mu30() { return this.mu30; }
|
||||
public double get_mu21() { return this.mu21; }
|
||||
public double get_mu12() { return this.mu12; }
|
||||
public double get_mu03() { return this.mu03; }
|
||||
public double get_nu20() { return this.nu20; }
|
||||
public double get_nu11() { return this.nu11; }
|
||||
public double get_nu02() { return this.nu02; }
|
||||
public double get_nu30() { return this.nu30; }
|
||||
public double get_nu21() { return this.nu21; }
|
||||
public double get_nu12() { return this.nu12; }
|
||||
public double get_nu03() { return this.nu03; }
|
||||
|
||||
public void set_m00(double m00) { this.m00 = m00; }
|
||||
public void set_m10(double m10) { this.m10 = m10; }
|
||||
public void set_m01(double m01) { this.m01 = m01; }
|
||||
public void set_m20(double m20) { this.m20 = m20; }
|
||||
public void set_m11(double m11) { this.m11 = m11; }
|
||||
public void set_m02(double m02) { this.m02 = m02; }
|
||||
public void set_m30(double m30) { this.m30 = m30; }
|
||||
public void set_m21(double m21) { this.m21 = m21; }
|
||||
public void set_m12(double m12) { this.m12 = m12; }
|
||||
public void set_m03(double m03) { this.m03 = m03; }
|
||||
public void set_mu20(double mu20) { this.mu20 = mu20; }
|
||||
public void set_mu11(double mu11) { this.mu11 = mu11; }
|
||||
public void set_mu02(double mu02) { this.mu02 = mu02; }
|
||||
public void set_mu30(double mu30) { this.mu30 = mu30; }
|
||||
public void set_mu21(double mu21) { this.mu21 = mu21; }
|
||||
public void set_mu12(double mu12) { this.mu12 = mu12; }
|
||||
public void set_mu03(double mu03) { this.mu03 = mu03; }
|
||||
public void set_nu20(double nu20) { this.nu20 = nu20; }
|
||||
public void set_nu11(double nu11) { this.nu11 = nu11; }
|
||||
public void set_nu02(double nu02) { this.nu02 = nu02; }
|
||||
public void set_nu30(double nu30) { this.nu30 = nu30; }
|
||||
public void set_nu21(double nu21) { this.nu21 = nu21; }
|
||||
public void set_nu12(double nu12) { this.nu12 = nu12; }
|
||||
public void set_nu03(double nu03) { this.nu03 = nu03; }
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"whitelist":
|
||||
{
|
||||
"": [
|
||||
"adaptiveThreshold",
|
||||
"applyColorMap",
|
||||
"arcLength",
|
||||
"arrowedLine",
|
||||
"bilateralFilter",
|
||||
"blendLinear",
|
||||
"blur",
|
||||
"boxFilter",
|
||||
"calcBackProject",
|
||||
"calcHist",
|
||||
"Canny",
|
||||
"circle",
|
||||
"clipLine",
|
||||
"compareHist",
|
||||
"connectedComponents",
|
||||
"connectedComponentsWithStats",
|
||||
"contourArea",
|
||||
"convertMaps",
|
||||
"cornerHarris",
|
||||
"cornerMinEigenVal",
|
||||
"createCLAHE",
|
||||
"createHanningWindow",
|
||||
"createLineSegmentDetector",
|
||||
"cvtColor",
|
||||
"demosaicing",
|
||||
"dilate",
|
||||
"distanceTransform",
|
||||
"distanceTransformWithLabels",
|
||||
"drawContours",
|
||||
"drawMarker",
|
||||
"drawFrameAxes",
|
||||
"ellipse",
|
||||
"ellipse2Poly",
|
||||
"equalizeHist",
|
||||
"erode",
|
||||
"fillConvexPoly",
|
||||
"fillPoly",
|
||||
"filter2D",
|
||||
"findContours",
|
||||
"findContoursLinkRuns",
|
||||
"floodFill",
|
||||
"fisheye_initUndistortRectifyMap",
|
||||
"GaussianBlur",
|
||||
"getFontScaleFromHeight",
|
||||
"getRectSubPix",
|
||||
"getStructuringElement",
|
||||
"grabCut",
|
||||
"HoughCircles",
|
||||
"HoughLines",
|
||||
"HoughLinesP",
|
||||
"integral",
|
||||
"integral2",
|
||||
"Laplacian",
|
||||
"line",
|
||||
"matchTemplate",
|
||||
"medianBlur",
|
||||
"morphologyEx",
|
||||
"polylines",
|
||||
"preCornerDetect",
|
||||
"putText",
|
||||
"pyrDown",
|
||||
"pyrUp",
|
||||
"rectangle",
|
||||
"remap",
|
||||
"resize",
|
||||
"Scharr",
|
||||
"sepFilter2D",
|
||||
"Sobel",
|
||||
"spatialGradient",
|
||||
"sqrBoxFilter",
|
||||
"stackBlur",
|
||||
"threshold",
|
||||
"warpAffine",
|
||||
"warpPerspective",
|
||||
"warpPolar",
|
||||
"watershed"
|
||||
],
|
||||
"CLAHE": ["apply", "collectGarbage", "getClipLimit", "getTilesGridSize", "setClipLimit", "setTilesGridSize"],
|
||||
"FontFace": ["set", "getName", "setInstance", "getInstance", "getBuiltinFontData"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// FontFace.h
|
||||
//
|
||||
// Created by VP in 2020
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
CV_EXPORTS @interface FontFace : NSObject
|
||||
|
||||
@property(readonly) NSString* name;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@property(readonly) cv::FontFace& nativeRef;
|
||||
#endif
|
||||
|
||||
-(instancetype)initWith:(const NSString*)name;
|
||||
-(instancetype)init;
|
||||
|
||||
#ifdef __cplusplus
|
||||
+(instancetype)fromNative:(cv::FontFace&)fface;
|
||||
#endif
|
||||
|
||||
-(NSString *)description;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// FontFace.mm
|
||||
//
|
||||
// Created by VP in 2020.
|
||||
//
|
||||
|
||||
#import "FontFace.h"
|
||||
|
||||
@implementation FontFace {
|
||||
cv::FontFace native;
|
||||
}
|
||||
|
||||
-(cv::FontFace&)nativeRef {
|
||||
return native;
|
||||
}
|
||||
|
||||
- (NSString*)name {
|
||||
return [NSString stringWithUTF8String:native.getName().c_str()];
|
||||
}
|
||||
|
||||
-(instancetype)init {
|
||||
return [super init];
|
||||
}
|
||||
|
||||
-(instancetype)initWith:(NSString*)name {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.nativeRef.set(std::string(name.UTF8String));
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+(instancetype)fromNative:(cv::FontFace&)fface {
|
||||
FontFace* ff = [[FontFace alloc] init];
|
||||
ff.nativeRef = fface;
|
||||
return ff;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
return [NSString stringWithFormat:@"FontFace [name=%s]", self.nativeRef.getName().c_str()];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// Moments.h
|
||||
//
|
||||
// Created by Giles Payne on 2019/10/06.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
CV_EXPORTS @interface Moments : NSObject
|
||||
|
||||
@property double m00;
|
||||
@property double m10;
|
||||
@property double m01;
|
||||
@property double m20;
|
||||
@property double m11;
|
||||
@property double m02;
|
||||
@property double m30;
|
||||
@property double m21;
|
||||
@property double m12;
|
||||
@property double m03;
|
||||
|
||||
@property double mu20;
|
||||
@property double mu11;
|
||||
@property double mu02;
|
||||
@property double mu30;
|
||||
@property double mu21;
|
||||
@property double mu12;
|
||||
@property double mu03;
|
||||
|
||||
@property double nu20;
|
||||
@property double nu11;
|
||||
@property double nu02;
|
||||
@property double nu30;
|
||||
@property double nu21;
|
||||
@property double nu12;
|
||||
@property double nu03;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@property(readonly) cv::Moments& nativeRef;
|
||||
#endif
|
||||
|
||||
-(instancetype)initWithM00:(double)m00 m10:(double)m10 m01:(double)m01 m20:(double)m20 m11:(double)m11 m02:(double)m02 m30:(double)m30 m21:(double)m21 m12:(double)m12 m03:(double)m03;
|
||||
|
||||
-(instancetype)init;
|
||||
|
||||
-(instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
|
||||
|
||||
#ifdef __cplusplus
|
||||
+(instancetype)fromNative:(cv::Moments&)moments;
|
||||
#endif
|
||||
|
||||
-(void)set:(NSArray<NSNumber*>*)vals;
|
||||
-(void)completeState;
|
||||
-(NSString *)description;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,304 @@
|
||||
//
|
||||
// Moments.mm
|
||||
//
|
||||
// Created by Giles Payne on 2019/10/09.
|
||||
//
|
||||
|
||||
#import "Moments.h"
|
||||
|
||||
@implementation Moments {
|
||||
cv::Moments native;
|
||||
}
|
||||
|
||||
-(cv::Moments&)nativeRef {
|
||||
return native;
|
||||
}
|
||||
|
||||
- (double)m00 {
|
||||
return native.m00;
|
||||
}
|
||||
|
||||
- (void)setM00:(double)val {
|
||||
native.m00 = val;
|
||||
}
|
||||
|
||||
- (double)m10 {
|
||||
return native.m10;
|
||||
}
|
||||
|
||||
- (void)setM10:(double)val {
|
||||
native.m10 = val;
|
||||
}
|
||||
|
||||
- (double)m01 {
|
||||
return native.m01;
|
||||
}
|
||||
|
||||
- (void)setM01:(double)val {
|
||||
native.m01 = val;
|
||||
}
|
||||
|
||||
- (double)m20 {
|
||||
return native.m20;
|
||||
}
|
||||
|
||||
- (void)setM20:(double)val {
|
||||
native.m20 = val;
|
||||
}
|
||||
|
||||
- (double)m11 {
|
||||
return native.m11;
|
||||
}
|
||||
|
||||
- (void)setM11:(double)val {
|
||||
native.m11 = val;
|
||||
}
|
||||
|
||||
- (double)m02 {
|
||||
return native.m02;
|
||||
}
|
||||
|
||||
- (void)setM02:(double)val {
|
||||
native.m02 = val;
|
||||
}
|
||||
|
||||
- (double)m30 {
|
||||
return native.m30;
|
||||
}
|
||||
|
||||
- (void)setM30:(double)val {
|
||||
native.m30 = val;
|
||||
}
|
||||
|
||||
- (double)m21 {
|
||||
return native.m21;
|
||||
}
|
||||
|
||||
- (void)setM21:(double)val {
|
||||
native.m21 = val;
|
||||
}
|
||||
|
||||
- (double)m12 {
|
||||
return native.m12;
|
||||
}
|
||||
|
||||
- (void)setM12:(double)val {
|
||||
native.m12 = val;
|
||||
}
|
||||
|
||||
- (double)m03 {
|
||||
return native.m03;
|
||||
}
|
||||
|
||||
- (void)setM03:(double)val {
|
||||
native.m03 = val;
|
||||
}
|
||||
|
||||
- (double)mu20 {
|
||||
return native.mu20;
|
||||
}
|
||||
|
||||
- (void)setMu20:(double)val {
|
||||
native.mu20 = val;
|
||||
}
|
||||
|
||||
- (double)mu11 {
|
||||
return native.mu11;
|
||||
}
|
||||
|
||||
- (void)setMu11:(double)val {
|
||||
native.mu11 = val;
|
||||
}
|
||||
|
||||
- (double)mu02 {
|
||||
return native.mu02;
|
||||
}
|
||||
|
||||
- (void)setMu02:(double)val {
|
||||
native.mu02 = val;
|
||||
}
|
||||
|
||||
- (double)mu30 {
|
||||
return native.mu30;
|
||||
}
|
||||
|
||||
- (void)setMu30:(double)val {
|
||||
native.mu30 = val;
|
||||
}
|
||||
|
||||
- (double)mu21 {
|
||||
return native.mu21;
|
||||
}
|
||||
|
||||
- (void)setMu21:(double)val {
|
||||
native.mu21 = val;
|
||||
}
|
||||
- (double)mu12 {
|
||||
return native.mu12;
|
||||
}
|
||||
|
||||
- (void)setMu12:(double)val {
|
||||
native.mu12 = val;
|
||||
}
|
||||
|
||||
- (double)mu03 {
|
||||
return native.mu03;
|
||||
}
|
||||
|
||||
- (void)setMu03:(double)val {
|
||||
native.mu03 = val;
|
||||
}
|
||||
|
||||
- (double)nu20 {
|
||||
return native.nu20;
|
||||
}
|
||||
|
||||
- (void)setNu20:(double)val {
|
||||
native.nu20 = val;
|
||||
}
|
||||
|
||||
- (double)nu11 {
|
||||
return native.nu11;
|
||||
}
|
||||
|
||||
- (void)setNu11:(double)val {
|
||||
native.nu11 = val;
|
||||
}
|
||||
|
||||
- (double)nu02 {
|
||||
return native.nu02;
|
||||
}
|
||||
|
||||
- (void)setNu02:(double)val {
|
||||
native.nu02 = val;
|
||||
}
|
||||
|
||||
- (double)nu30 {
|
||||
return native.nu30;
|
||||
}
|
||||
|
||||
- (void)setNu30:(double)val {
|
||||
native.nu30 = val;
|
||||
}
|
||||
|
||||
- (double)nu21 {
|
||||
return native.nu21;
|
||||
}
|
||||
|
||||
- (void)setNu21:(double)val {
|
||||
native.nu21 = val;
|
||||
}
|
||||
|
||||
- (double)nu12 {
|
||||
return native.nu12;
|
||||
}
|
||||
|
||||
- (void)setNu12:(double)val {
|
||||
native.nu12 = val;
|
||||
}
|
||||
|
||||
- (double)nu03 {
|
||||
return native.nu03;
|
||||
}
|
||||
|
||||
- (void)setNu03:(double)val {
|
||||
native.nu03 = val;
|
||||
}
|
||||
|
||||
-(instancetype)initWithM00:(double)m00 m10:(double)m10 m01:(double)m01 m20:(double)m20 m11:(double)m11 m02:(double)m02 m30:(double)m30 m21:(double)m21 m12:(double)m12 m03:(double)m03 {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.m00 = m00;
|
||||
self.m10 = m10;
|
||||
self.m01 = m01;
|
||||
self.m20 = m20;
|
||||
self.m11 = m11;
|
||||
self.m02 = m02;
|
||||
self.m30 = m30;
|
||||
self.m21 = m21;
|
||||
self.m12 = m12;
|
||||
self.m03 = m03;
|
||||
[self completeState];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(instancetype)init {
|
||||
return [self initWithM00:0 m10:0 m01:0 m20:0 m11:0 m02:0 m30:0 m21:0 m12:0 m03:0];
|
||||
}
|
||||
|
||||
-(instancetype)initWithVals:(NSArray<NSNumber*>*)vals {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
[self set:vals];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+(instancetype)fromNative:(cv::Moments&)moments {
|
||||
return [[Moments alloc] initWithM00:moments.m00 m10:moments.m10 m01:moments.m01 m20:moments.m20 m11:moments.m11 m02:moments.m02 m30:moments.m30 m21:moments.m21 m12:moments.m12 m03:moments.m03];
|
||||
}
|
||||
|
||||
-(void)set:(NSArray<NSNumber*>*)vals {
|
||||
self.m00 = (vals != nil && vals.count > 0) ? vals[0].doubleValue : 0;
|
||||
self.m10 = (vals != nil && vals.count > 1) ? vals[1].doubleValue : 0;
|
||||
self.m01 = (vals != nil && vals.count > 2) ? vals[2].doubleValue : 0;
|
||||
self.m20 = (vals != nil && vals.count > 3) ? vals[3].doubleValue : 0;
|
||||
self.m11 = (vals != nil && vals.count > 4) ? vals[4].doubleValue : 0;
|
||||
self.m02 = (vals != nil && vals.count > 5) ? vals[5].doubleValue : 0;
|
||||
self.m30 = (vals != nil && vals.count > 6) ? vals[6].doubleValue : 0;
|
||||
self.m21 = (vals != nil && vals.count > 7) ? vals[7].doubleValue : 0;
|
||||
self.m12 = (vals != nil && vals.count > 8) ? vals[8].doubleValue : 0;
|
||||
self.m03 = (vals != nil && vals.count > 9) ? vals[9].doubleValue : 0;
|
||||
[self completeState];
|
||||
}
|
||||
|
||||
-(void)completeState {
|
||||
double cx = 0, cy = 0;
|
||||
double mu20, mu11, mu02;
|
||||
double inv_m00 = 0.0;
|
||||
|
||||
if (abs(self.m00) > 0.00000001) {
|
||||
inv_m00 = 1. / self.m00;
|
||||
cx = self.m10 * inv_m00;
|
||||
cy = self.m01 * inv_m00;
|
||||
}
|
||||
|
||||
// mu20 = m20 - m10*cx
|
||||
mu20 = self.m20 - self.m10 * cx;
|
||||
// mu11 = m11 - m10*cy
|
||||
mu11 = self.m11 - self.m10 * cy;
|
||||
// mu02 = m02 - m01*cy
|
||||
mu02 = self.m02 - self.m01 * cy;
|
||||
|
||||
self.mu20 = mu20;
|
||||
self.mu11 = mu11;
|
||||
self.mu02 = mu02;
|
||||
|
||||
// mu30 = m30 - cx*(3*mu20 + cx*m10)
|
||||
self.mu30 = self.m30 - cx * (3 * mu20 + cx * self.m10);
|
||||
mu11 += mu11;
|
||||
// mu21 = m21 - cx*(2*mu11 + cx*m01) - cy*mu20
|
||||
self.mu21 = self.m21 - cx * (mu11 + cx * self.m01) - cy * mu20;
|
||||
// mu12 = m12 - cy*(2*mu11 + cy*m10) - cx*mu02
|
||||
self.mu12 = self.m12 - cy * (mu11 + cy * self.m10) - cx * mu02;
|
||||
// mu03 = m03 - cy*(3*mu02 + cy*m01)
|
||||
self.mu03 = self.m03 - cy * (3 * mu02 + cy * self.m01);
|
||||
|
||||
|
||||
double inv_sqrt_m00 = sqrt(abs(inv_m00));
|
||||
double s2 = inv_m00*inv_m00, s3 = s2*inv_sqrt_m00;
|
||||
|
||||
self.nu20 = self.mu20*s2;
|
||||
self.nu11 = self.mu11*s2;
|
||||
self.nu02 = self.mu02*s2;
|
||||
self.nu30 = self.mu30*s3;
|
||||
self.nu21 = self.mu21*s3;
|
||||
self.nu12 = self.mu12*s3;
|
||||
self.nu03 = self.mu03*s3;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
return [NSString stringWithFormat:@"Moments [ \nm00=%lf, \nm10=%lf, m01=%lf, \nm20=%lf, m11=%lf, m02=%lf, \nm30=%lf, m21=%lf, m12=%lf, m03=%lf, \nmu20=%lf, mu11=%lf, mu02=%lf, \nmu30=%lf, mu21=%lf, mu12=%lf, mu03=%lf, \nnu20=%lf, nu11=%lf, nu02=%lf, \nnu30=%lf, nu21=%lf, nu12=%lf, nu03=%lf, \n]", self.m00, self.m10, self.m01, self.m20, self.m11, self.m02, self.m30, self.m21, self.m12, self.m03, self.mu20, self.mu11, self.mu02, self.mu30, self.mu21, self.mu12, self.mu03, self.nu20, self.nu11, self.nu02, self.nu30, self.nu21, self.nu12, self.nu03];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,120 @@
|
||||
{
|
||||
"class_ignore_list": [
|
||||
"FontFace"
|
||||
],
|
||||
"AdditionalImports" : {
|
||||
"Imgproc" : [ "\"imgproc/bindings.hpp\"" ]
|
||||
},
|
||||
"enum_ignore_list" : [
|
||||
"MorphShapes_c",
|
||||
"SmoothMethod_c"
|
||||
],
|
||||
"module_imports": ["Size2i"],
|
||||
"const_ignore_list": [
|
||||
"CV_TM_.+",
|
||||
"CV_COLORCVT_MAX",
|
||||
"CV_.*Bayer.*",
|
||||
"CV_YUV420(i|sp|p)2.+",
|
||||
"CV_L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV)\\d*2L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV).*",
|
||||
"CV_FLOODFILL_.+",
|
||||
"CV_ADAPTIVE_THRESH_.+",
|
||||
"CV_DIST_.+",
|
||||
"CV_HOUGH_.+",
|
||||
"CV_CONTOURS_MATCH_.+",
|
||||
"CV_COMP_.+"
|
||||
],
|
||||
"const_private_list" : [
|
||||
"CV_MOP_.+",
|
||||
"CV_INTER_.+",
|
||||
"CV_THRESH_.+",
|
||||
"CV_INPAINT_.+",
|
||||
"CV_RETR_.+",
|
||||
"CV_CHAIN_APPROX_.+"
|
||||
],
|
||||
"missing_consts" : {
|
||||
"Imgproc" : {
|
||||
"private" : [
|
||||
["IPL_BORDER_CONSTANT", 0 ],
|
||||
["IPL_BORDER_REPLICATE", 1 ],
|
||||
["IPL_BORDER_REFLECT", 2 ],
|
||||
["IPL_BORDER_WRAP", 3 ],
|
||||
["IPL_BORDER_REFLECT_101", 4 ],
|
||||
["IPL_BORDER_TRANSPARENT", 5 ]
|
||||
]
|
||||
}
|
||||
},
|
||||
"func_arg_fix" : {
|
||||
"Imgproc" : {
|
||||
"fillPoly" : { "pts" : {"ctype" : "vector_vector_Point"},
|
||||
"lineType" : {"ctype" : "LineTypes"}},
|
||||
"polylines" : { "pts" : {"ctype" : "vector_vector_Point"},
|
||||
"lineType" : {"ctype" : "LineTypes"} },
|
||||
"fillConvexPoly" : { "points" : {"ctype" : "vector_Point"},
|
||||
"lineType" : {"ctype" : "LineTypes"} },
|
||||
"drawContours" : { "contours" : {"ctype" : "vector_vector_Point"},
|
||||
"lineType" : {"ctype" : "LineTypes"} },
|
||||
"findContours" : { "contours" : {"ctype" : "vector_vector_Point"},
|
||||
"mode" : {"ctype" : "RetrievalModes"},
|
||||
"method" : {"ctype" : "ContourApproximationModes"} },
|
||||
"getStructuringElement" : { "shape" : {"ctype" : "MorphShapes"} },
|
||||
"EMD" : {"lowerBound" : {"defval" : "cv::Ptr<float>()"},
|
||||
"distType" : {"ctype" : "DistanceTypes"}},
|
||||
"createLineSegmentDetector" : { "_refine" : {"ctype" : "LineSegmentDetectorModes"}},
|
||||
"compareHist" : { "method" : {"ctype" : "HistCompMethods"}},
|
||||
"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"}},
|
||||
"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"}}
|
||||
}
|
||||
},
|
||||
"type_dict": {
|
||||
"FontFace": {
|
||||
"objc_type": "FontFace*",
|
||||
"to_cpp": "%(n)s.nativeRef",
|
||||
"from_cpp": "[FontFace fromNative:%(n)s]"
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import cv2 as cv
|
||||
try:
|
||||
from PIL import Image
|
||||
except ImportError:
|
||||
Image = None
|
||||
|
||||
from tests_common import NewOpenCVTests
|
||||
|
||||
class Imgproc_Tests(NewOpenCVTests):
|
||||
|
||||
def test_python_986(self):
|
||||
cntls = []
|
||||
img = np.zeros((100,100,3), dtype=np.uint8)
|
||||
color = (0,0,0)
|
||||
cnts = np.array(cntls, dtype=np.int32).reshape((1, -1, 2))
|
||||
try:
|
||||
cv.fillPoly(img, cnts, color)
|
||||
assert False
|
||||
except:
|
||||
assert True
|
||||
|
||||
def test_filter2d(self):
|
||||
img = self.get_sample('samples/data/lena.jpg', 1)
|
||||
eps = 0.001
|
||||
# compare 2 ways of computing 3x3 blur using the same function
|
||||
kernel = np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]], dtype='float32')
|
||||
img_blur0 = cv.filter2D(img, cv.CV_32F, kernel*(1./9))
|
||||
img_blur1 = cv.filter2Dp(img, kernel, ddepth=cv.CV_32F, scale=1./9)
|
||||
self.assertLess(cv.norm(img_blur0 - img_blur1, cv.NORM_INF), eps)
|
||||
|
||||
def test_resize_pillow(self):
|
||||
if Image is None:
|
||||
self.skipTest("Pillow is not available")
|
||||
|
||||
r = np.random.randint(0, 255, size=(128, 147, 3), dtype="uint8")
|
||||
target_size=[(128,128), (129,129), (160,160)]
|
||||
for ts in target_size:
|
||||
|
||||
pil_result = np.array(Image.fromarray(r).resize(ts, Image.NEAREST))
|
||||
ocv_result = cv.resize(r, dsize=ts, interpolation=cv.INTER_NEAREST_EXACT)
|
||||
status = np.all(pil_result == ocv_result)
|
||||
print(ts, status)
|
||||
self.assertTrue(status, "resize result differs from Pillow for target size %s" % (ts,))
|
||||
Reference in New Issue
Block a user