From 4b7822b4df64fee3b91c57be1d4566dcc231d761 Mon Sep 17 00:00:00 2001 From: Dennis Van Roeyen Date: Fri, 18 Aug 2017 14:51:35 +0200 Subject: [PATCH] added getFPS to VideoCapture --- src/VideoCaptureWrap.cc | 11 +++++++++++ src/VideoCaptureWrap.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/VideoCaptureWrap.cc b/src/VideoCaptureWrap.cc index 47eb8d5..aa4cd8d 100755 --- a/src/VideoCaptureWrap.cc +++ b/src/VideoCaptureWrap.cc @@ -33,6 +33,7 @@ void VideoCaptureWrap::Init(Local target) { Nan::SetPrototypeMethod(ctor, "setPosition", SetPosition); Nan::SetPrototypeMethod(ctor, "getFrameAt", GetFrameAt); Nan::SetPrototypeMethod(ctor, "getFrameCount", GetFrameCount); + Nan::SetPrototypeMethod(ctor, "getFPS", GetFPS); Nan::SetPrototypeMethod(ctor, "release", Release); Nan::SetPrototypeMethod(ctor, "ReadSync", ReadSync); Nan::SetPrototypeMethod(ctor, "grab", Grab); @@ -103,6 +104,16 @@ NAN_METHOD(VideoCaptureWrap::GetFrameCount) { info.GetReturnValue().Set(Nan::New(cnt)); } + +NAN_METHOD(VideoCaptureWrap::GetFPS) { + Nan::HandleScope scope; + VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap(info.This()); + + int fps = int(v->cap.get(CV_CAP_PROP_FPS)); + + info.GetReturnValue().Set(Nan::New(fps)); +} + 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 cb01a72..ce77a83 100755 --- a/src/VideoCaptureWrap.h +++ b/src/VideoCaptureWrap.h @@ -25,6 +25,8 @@ public: static NAN_METHOD(SetPosition); static NAN_METHOD(GetFrameCount); + static NAN_METHOD(GetFPS); + static NAN_METHOD(GetFrameAt); // release the stream