From cf8d9143f85f23139ebb5002cabc300bb6d57377 Mon Sep 17 00:00:00 2001 From: Mikhail Sirotenko Date: Sun, 7 Feb 2016 01:56:27 +0000 Subject: [PATCH 1/2] Added NumFrames method to VideoCapture --- src/VideoCaptureWrap.cc | 10 ++++++++++ src/VideoCaptureWrap.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/VideoCaptureWrap.cc b/src/VideoCaptureWrap.cc index e0d06c2..12b0afc 100755 --- a/src/VideoCaptureWrap.cc +++ b/src/VideoCaptureWrap.cc @@ -33,6 +33,7 @@ void VideoCaptureWrap::Init(Local target) { Nan::SetPrototypeMethod(ctor, "setHeight", SetHeight); Nan::SetPrototypeMethod(ctor, "setPosition", SetPosition); Nan::SetPrototypeMethod(ctor, "getFrameAt", GetFrameAt); + Nan::SetPrototypeMethod(ctor, "nFrames", NumFrames); Nan::SetPrototypeMethod(ctor, "close", Close); Nan::SetPrototypeMethod(ctor, "ReadSync", ReadSync); Nan::SetPrototypeMethod(ctor, "grab", Grab); @@ -94,6 +95,15 @@ NAN_METHOD(VideoCaptureWrap::SetWidth) { return; } +NAN_METHOD(VideoCaptureWrap::NumFrames) { + Nan::HandleScope scope; + VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap(info.This()); + + int cnt = int(v->cap.get(CV_CAP_PROP_FRAME_COUNT)); + + info.GetReturnValue().Set(Nan::New(cnt)); +} + NAN_METHOD(VideoCaptureWrap::SetHeight) { Nan::HandleScope scope; VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap(info.This()); diff --git a/src/VideoCaptureWrap.h b/src/VideoCaptureWrap.h index 3cb5a04..1fbb3bf 100755 --- a/src/VideoCaptureWrap.h +++ b/src/VideoCaptureWrap.h @@ -23,6 +23,7 @@ public: // to set frame position static NAN_METHOD(SetPosition); + static NAN_METHOD(NumFrames); static NAN_METHOD(GetFrameAt); From a45139326d6012c40912fefa7e2450181b1047d5 Mon Sep 17 00:00:00 2001 From: Mikhail Sirotenko Date: Sun, 7 Feb 2016 09:31:29 -0500 Subject: [PATCH 2/2] Renamed numFrame method to correspond to OpenCV naming --- src/VideoCaptureWrap.cc | 4 ++-- src/VideoCaptureWrap.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/VideoCaptureWrap.cc b/src/VideoCaptureWrap.cc index 12b0afc..6ea7b13 100755 --- a/src/VideoCaptureWrap.cc +++ b/src/VideoCaptureWrap.cc @@ -33,7 +33,7 @@ void VideoCaptureWrap::Init(Local target) { Nan::SetPrototypeMethod(ctor, "setHeight", SetHeight); Nan::SetPrototypeMethod(ctor, "setPosition", SetPosition); Nan::SetPrototypeMethod(ctor, "getFrameAt", GetFrameAt); - Nan::SetPrototypeMethod(ctor, "nFrames", NumFrames); + Nan::SetPrototypeMethod(ctor, "getFrameCount", GetFrameCount); Nan::SetPrototypeMethod(ctor, "close", Close); Nan::SetPrototypeMethod(ctor, "ReadSync", ReadSync); Nan::SetPrototypeMethod(ctor, "grab", Grab); @@ -95,7 +95,7 @@ NAN_METHOD(VideoCaptureWrap::SetWidth) { return; } -NAN_METHOD(VideoCaptureWrap::NumFrames) { +NAN_METHOD(VideoCaptureWrap::GetFrameCount) { Nan::HandleScope scope; VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap(info.This()); diff --git a/src/VideoCaptureWrap.h b/src/VideoCaptureWrap.h index 1fbb3bf..bf28790 100755 --- a/src/VideoCaptureWrap.h +++ b/src/VideoCaptureWrap.h @@ -23,7 +23,7 @@ public: // to set frame position static NAN_METHOD(SetPosition); - static NAN_METHOD(NumFrames); + static NAN_METHOD(GetFrameCount); static NAN_METHOD(GetFrameAt);