@@ -66,7 +66,7 @@ void BackgroundSubtractorWrap::Init(Local<Object> target) {
66
66
Nan::SetPrototypeMethod (ctor, " noiseSigma" , NoiseSigma);
67
67
Nan::SetPrototypeMethod (ctor, " backgroundRatio" , BackgroundRatio);
68
68
69
- target->Set (Nan::New (" BackgroundSubtractor" ).ToLocalChecked (), ctor->GetFunction ());
69
+ target->Set (Nan::New (" BackgroundSubtractor" ).ToLocalChecked (), ctor->GetFunction ( Nan::GetCurrentContext () ). ToLocalChecked ( ));
70
70
}
71
71
72
72
NAN_METHOD (BackgroundSubtractorWrap::New) {
@@ -242,28 +242,28 @@ NAN_METHOD(BackgroundSubtractorWrap::ApplyMOG) {
242
242
if (info.Length () == 0 ) {
243
243
argv[0 ] = Nan::New (" Input image missing" ).ToLocalChecked ();
244
244
argv[1 ] = Nan::Null ();
245
- cb->Call (Nan::GetCurrentContext ()->Global (), 2 , argv);
245
+ cb->Call ( Nan::GetCurrentContext (), Nan::GetCurrentContext ()->Global (), 2 , argv);
246
246
return ;
247
247
}
248
248
249
249
if (NULL == self->subtractor ){
250
250
argv[0 ] = Nan::New (" BackgroundSubtractor not created" ).ToLocalChecked ();
251
251
argv[1 ] = Nan::Null ();
252
- cb->Call (Nan::GetCurrentContext ()->Global (), 2 , argv);
252
+ cb->Call ( Nan::GetCurrentContext (), Nan::GetCurrentContext ()->Global (), 2 , argv);
253
253
return ;
254
254
}
255
255
256
256
257
257
try {
258
258
cv::Mat mat;
259
259
if (Buffer::HasInstance (info[0 ])) {
260
- uint8_t *buf = (uint8_t *) Buffer::Data (info[0 ]-> ToObject ());
261
- unsigned len = Buffer::Length (info[0 ]-> ToObject ());
260
+ uint8_t *buf = (uint8_t *) Buffer::Data (Nan::To<v8::Object>( info[0 ]). ToLocalChecked ());
261
+ unsigned len = Buffer::Length (Nan::To<v8::Object>( info[0 ]). ToLocalChecked ());
262
262
cv::Mat *mbuf = new cv::Mat (len, 1 , CV_64FC1, buf);
263
263
mat = cv::imdecode (*mbuf, -1 );
264
264
// mbuf->release();
265
265
} else {
266
- Matrix *_img = Nan::ObjectWrap::Unwrap<Matrix>(info[0 ]-> ToObject ());
266
+ Matrix *_img = Nan::ObjectWrap::Unwrap<Matrix>(Nan::To<v8::Object>( info[0 ]). ToLocalChecked ());
267
267
mat = (_img->mat ).clone ();
268
268
}
269
269
@@ -290,7 +290,7 @@ NAN_METHOD(BackgroundSubtractorWrap::ApplyMOG) {
290
290
argv[1 ] = fgMask;
291
291
292
292
Nan::TryCatch try_catch;
293
- cb->Call (Nan::GetCurrentContext ()->Global (), 2 , argv);
293
+ cb->Call ( Nan::GetCurrentContext (), Nan::GetCurrentContext ()->Global (), 2 , argv);
294
294
295
295
if (try_catch.HasCaught ()) {
296
296
Nan::FatalException (try_catch);
@@ -386,18 +386,18 @@ NAN_METHOD(BackgroundSubtractorWrap::Apply) {
386
386
if (info.Length () == 0 ) {
387
387
argv[0 ] = Nan::New (" Input image missing" ).ToLocalChecked ();
388
388
argv[1 ] = Nan::Null ();
389
- cb->Call (Nan::GetCurrentContext ()->Global (), 2 , argv);
389
+ cb->Call ( Nan::GetCurrentContext (), Nan::GetCurrentContext ()->Global (), 2 , argv);
390
390
return ;
391
391
}
392
392
if (NULL == self->subtractor ){
393
393
argv[0 ] = Nan::New (" BackgroundSubtractor not created" ).ToLocalChecked ();
394
394
argv[1 ] = Nan::Null ();
395
- cb->Call (Nan::GetCurrentContext ()->Global (), 2 , argv);
395
+ cb->Call ( Nan::GetCurrentContext (), Nan::GetCurrentContext ()->Global (), 2 , argv);
396
396
return ;
397
397
}
398
398
399
399
Nan::Callback *callback = new Nan::Callback (cb.As <Function>());
400
- Matrix *_img = Nan::ObjectWrap::Unwrap<Matrix>(info[0 ]-> ToObject ());
400
+ Matrix *_img = Nan::ObjectWrap::Unwrap<Matrix>(Nan::To<v8::Object>( info[0 ]). ToLocalChecked ());
401
401
Nan::AsyncQueueWorker (new AsyncBackgroundSubtractorWorker ( callback, self, _img));
402
402
return ;
403
403
} else { // synchronous - return the image
@@ -406,13 +406,13 @@ NAN_METHOD(BackgroundSubtractorWrap::Apply) {
406
406
Local<Object> fgMask;
407
407
cv::Mat mat;
408
408
if (Buffer::HasInstance (info[0 ])) {
409
- uint8_t *buf = (uint8_t *) Buffer::Data (info[0 ]-> ToObject ());
410
- unsigned len = Buffer::Length (info[0 ]-> ToObject ());
409
+ uint8_t *buf = (uint8_t *) Buffer::Data (Nan::To<v8::Object>( info[0 ]). ToLocalChecked ());
410
+ unsigned len = Buffer::Length (Nan::To<v8::Object>( info[0 ]). ToLocalChecked ());
411
411
cv::Mat *mbuf = new cv::Mat (len, 1 , CV_64FC1, buf);
412
412
mat = cv::imdecode (*mbuf, -1 );
413
413
// mbuf->release();
414
414
} else {
415
- Matrix *_img = Nan::ObjectWrap::Unwrap<Matrix>(info[0 ]-> ToObject ());
415
+ Matrix *_img = Nan::ObjectWrap::Unwrap<Matrix>(Nan::To<v8::Object>( info[0 ]). ToLocalChecked ());
416
416
mat = (_img->mat ).clone ();
417
417
}
418
418
@@ -456,7 +456,7 @@ NAN_METHOD(BackgroundSubtractorWrap::History) {
456
456
// only support for V3+ with opencv-contrib
457
457
#ifdef HAVE_OPENCV_BGSEGM
458
458
if (info.Length () > 0 ) {
459
- mog->setHistory (info[0 ]-> NumberValue ());
459
+ mog->setHistory (info[0 ]. As <Number>()-> Value ());
460
460
}
461
461
info.GetReturnValue ().Set (mog->getHistory ());
462
462
#else
@@ -473,7 +473,7 @@ NAN_METHOD(BackgroundSubtractorWrap::BackgroundRatio) {
473
473
// only support for V3+ with opencv-contrib
474
474
#ifdef HAVE_OPENCV_BGSEGM
475
475
if (info.Length () > 0 ) {
476
- mog->setBackgroundRatio (info[0 ]-> NumberValue ());
476
+ mog->setBackgroundRatio (info[0 ]. As <Number>()-> Value ());
477
477
}
478
478
info.GetReturnValue ().Set (mog->getBackgroundRatio ());
479
479
#else
@@ -490,7 +490,7 @@ NAN_METHOD(BackgroundSubtractorWrap::NoiseSigma) {
490
490
// only support for V3+ with opencv-contrib
491
491
#ifdef HAVE_OPENCV_BGSEGM
492
492
if (info.Length () > 0 ) {
493
- mog->setNoiseSigma (info[0 ]-> NumberValue ());
493
+ mog->setNoiseSigma (info[0 ]. As <Number>()-> Value ());
494
494
}
495
495
info.GetReturnValue ().Set (mog->getNoiseSigma ());
496
496
#else
@@ -507,7 +507,7 @@ NAN_METHOD(BackgroundSubtractorWrap::Mixtures) {
507
507
// only support for V3+ with opencv-contrib
508
508
#ifdef HAVE_OPENCV_BGSEGM
509
509
if (info.Length () > 0 ) {
510
- mog->setNMixtures (info[0 ]-> NumberValue ());
510
+ mog->setNMixtures (info[0 ]. As <Number>()-> Value ());
511
511
}
512
512
info.GetReturnValue ().Set (mog->getNMixtures ());
513
513
#else
0 commit comments