@@ -59,6 +59,7 @@ void Matrix::Init(Local<Object> target) {
59
59
Nan::SetPrototypeMethod (ctor, " gaussianBlur" , GaussianBlur);
60
60
Nan::SetPrototypeMethod (ctor, " medianBlur" , MedianBlur);
61
61
Nan::SetPrototypeMethod (ctor, " bilateralFilter" , BilateralFilter);
62
+ Nan::SetPrototypeMethod (ctor, " sobel" , Sobel);
62
63
Nan::SetPrototypeMethod (ctor, " copy" , Copy);
63
64
Nan::SetPrototypeMethod (ctor, " flip" , Flip);
64
65
Nan::SetPrototypeMethod (ctor, " roi" , ROI);
@@ -1155,6 +1156,36 @@ NAN_METHOD(Matrix::BilateralFilter) {
1155
1156
info.GetReturnValue ().Set (Nan::Null ());
1156
1157
}
1157
1158
1159
+ NAN_METHOD (Matrix::Sobel) {
1160
+ Nan::HandleScope scope;
1161
+
1162
+ if (info.Length () < 3 )
1163
+ Nan::ThrowError (" Need more arguments: sobel(ddepth, xorder, yorder, ksize=3, scale=1.0, delta=0.0, borderType=CV_BORDER_DEFAULT)" );
1164
+
1165
+ int ddepth = info[0 ]->IntegerValue ();
1166
+ int xorder = info[1 ]->IntegerValue ();
1167
+ int yorder = info[2 ]->IntegerValue ();
1168
+
1169
+ int ksize = 3 ;
1170
+ if (info.Length () > 3 ) ksize = info[3 ]->IntegerValue ();
1171
+ double scale = 1 ;
1172
+ if (info.Length () > 4 ) scale = info[4 ]->NumberValue ();
1173
+ double delta = 0 ;
1174
+ if (info.Length () > 5 ) delta = info[5 ]->NumberValue ();
1175
+ int borderType = cv::BORDER_DEFAULT;
1176
+ if (info.Length () > 6 ) borderType = info[6 ]->IntegerValue ();
1177
+
1178
+ Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This ());
1179
+
1180
+ Local<Object> result_to_return =
1181
+ Nan::New (Matrix::constructor)->GetFunction ()->NewInstance ();
1182
+ Matrix *result = Nan::ObjectWrap::Unwrap<Matrix>(result_to_return);
1183
+
1184
+ cv::Sobel (self->mat , result->mat , ddepth, xorder, yorder, ksize, scale, delta, borderType);
1185
+
1186
+ info.GetReturnValue ().Set (result_to_return);
1187
+ }
1188
+
1158
1189
NAN_METHOD (Matrix::Copy) {
1159
1190
Nan::HandleScope scope;
1160
1191
0 commit comments