diff --git a/src/VideoCaptureWrap.cc b/src/VideoCaptureWrap.cc index 30113b7..d3e6c98 100755 --- a/src/VideoCaptureWrap.cc +++ b/src/VideoCaptureWrap.cc @@ -38,6 +38,7 @@ void VideoCaptureWrap::Init(Local target) { Nan::SetPrototypeMethod(ctor, "getFrameAt", GetFrameAt); Nan::SetPrototypeMethod(ctor, "getFrameCount", GetFrameCount); Nan::SetPrototypeMethod(ctor, "getFPS", GetFPS); + Nan::SetPrototypeMethod(ctor, "setFPS", SetFPS); Nan::SetPrototypeMethod(ctor, "release", Release); Nan::SetPrototypeMethod(ctor, "ReadSync", ReadSync); Nan::SetPrototypeMethod(ctor, "grab", Grab); @@ -127,6 +128,21 @@ NAN_METHOD(VideoCaptureWrap::GetFPS) { info.GetReturnValue().Set(Nan::New(fps)); } +NAN_METHOD(VideoCaptureWrap::SetFPS) { + Nan::HandleScope scope; + VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap(info.This()); + + if (info.Length() > 0) { + if (info[0]->IsNumber()) { + int fps = info[0]->IntegerValue(); + v->cap.set(CV_CAP_PROP_FPS, fps); + } + } + + int fps = int(v->cap.get(CV_CAP_PROP_FPS)); + + info.GetReturnValue().Set(Nan::New(fps)); +} NAN_METHOD(VideoCaptureWrap::GetHeight) { Nan::HandleScope scope; diff --git a/src/VideoCaptureWrap.h b/src/VideoCaptureWrap.h index bb7d11f..dc1c3da 100755 --- a/src/VideoCaptureWrap.h +++ b/src/VideoCaptureWrap.h @@ -32,6 +32,7 @@ public: static NAN_METHOD(GetFrameCount); static NAN_METHOD(GetFPS); + static NAN_METHOD(SetFPS); static NAN_METHOD(GetFrameAt);