@@ -29,6 +29,8 @@ NAN_MODULE_INIT(Imgproc::Init) {
29
29
Nan::SetMethod (target, " calcHist" , CalcHist);
30
30
Nan::SetMethod (target, " plot1DHist" , Plot1DHist);
31
31
Nan::SetMethod (target, " fitLine" , FitLine);
32
+ Nan::SetMethod (target, " getAffineTransform" , GetAffineTransform);
33
+ Nan::SetMethod (target, " getPerspectiveTransform" , GetPerspectiveTransform);
32
34
#if CV_VERSION_MINOR > 1
33
35
Nan::SetMethod (target, " canny" , Canny);
34
36
#endif
@@ -61,6 +63,45 @@ NAN_METHOD(Imgproc::GetRotationMatrix2D) {
61
63
FF_RETURN (jsRotationMat);
62
64
}
63
65
66
+ NAN_METHOD (Imgproc::GetAffineTransform) {
67
+ FF_METHOD_CONTEXT (" GetAffineTransform" );
68
+
69
+ FF_ARG_ARRAY (0 , FF_ARR jsSrcPoints);
70
+ FF_ARG_ARRAY (1 , FF_ARR jsDstPoints);
71
+
72
+ // TODO FF_ARG_UNPACK_ARRAY_INSTANCE
73
+ Nan::TryCatch tryCatch;
74
+ std::vector<cv::Point2f> srcPoints, dstPoints;
75
+ Point::unpackJSPoint2Array<float >(srcPoints, jsSrcPoints);
76
+ Point::unpackJSPoint2Array<float >(dstPoints, jsDstPoints);
77
+ if (tryCatch.HasCaught ()) {
78
+ return info.GetReturnValue ().Set (tryCatch.ReThrow ());
79
+ }
80
+
81
+ FF_OBJ jsMat = FF_NEW_INSTANCE (Mat::constructor);
82
+ FF_UNWRAP_MAT_AND_GET (jsMat) = cv::getAffineTransform (srcPoints, dstPoints);
83
+ FF_RETURN (jsMat);
84
+ }
85
+
86
+ NAN_METHOD (Imgproc::GetPerspectiveTransform) {
87
+ FF_METHOD_CONTEXT (" GetPerspectiveTransform" );
88
+
89
+ FF_ARG_ARRAY (0 , FF_ARR jsSrcPoints);
90
+ FF_ARG_ARRAY (1 , FF_ARR jsDstPoints);
91
+
92
+ // TODO FF_ARG_UNPACK_ARRAY_INSTANCE
93
+ Nan::TryCatch tryCatch;
94
+ std::vector<cv::Point2f> srcPoints, dstPoints;
95
+ Point::unpackJSPoint2Array<float >(srcPoints, jsSrcPoints);
96
+ Point::unpackJSPoint2Array<float >(dstPoints, jsDstPoints);
97
+ if (tryCatch.HasCaught ()) {
98
+ return info.GetReturnValue ().Set (tryCatch.ReThrow ());
99
+ }
100
+
101
+ FF_OBJ jsMat = FF_NEW_INSTANCE (Mat::constructor);
102
+ FF_UNWRAP_MAT_AND_GET (jsMat) = cv::getPerspectiveTransform (srcPoints, dstPoints);
103
+ FF_RETURN (jsMat);
104
+ }
64
105
65
106
NAN_METHOD (Imgproc::CalcHist) {
66
107
FF_METHOD_CONTEXT (" CalcHist" );
@@ -230,4 +271,4 @@ NAN_METHOD(Imgproc::Canny) {
230
271
231
272
FF_RETURN (jsMat);
232
273
}
233
- #endif
274
+ #endif
0 commit comments