VideoCaptureWrap: Add setFPS - returns FPS read back.

This commit is contained in:
Simon Hailes 2017-11-02 19:47:34 +00:00
parent a58656270f
commit f2e1fc3e1e
2 changed files with 17 additions and 0 deletions

View File

@ -38,6 +38,7 @@ void VideoCaptureWrap::Init(Local<Object> target) {
Nan::SetPrototypeMethod(ctor, "getFrameAt", GetFrameAt); Nan::SetPrototypeMethod(ctor, "getFrameAt", GetFrameAt);
Nan::SetPrototypeMethod(ctor, "getFrameCount", GetFrameCount); Nan::SetPrototypeMethod(ctor, "getFrameCount", GetFrameCount);
Nan::SetPrototypeMethod(ctor, "getFPS", GetFPS); Nan::SetPrototypeMethod(ctor, "getFPS", GetFPS);
Nan::SetPrototypeMethod(ctor, "setFPS", SetFPS);
Nan::SetPrototypeMethod(ctor, "release", Release); Nan::SetPrototypeMethod(ctor, "release", Release);
Nan::SetPrototypeMethod(ctor, "ReadSync", ReadSync); Nan::SetPrototypeMethod(ctor, "ReadSync", ReadSync);
Nan::SetPrototypeMethod(ctor, "grab", Grab); Nan::SetPrototypeMethod(ctor, "grab", Grab);
@ -127,6 +128,21 @@ NAN_METHOD(VideoCaptureWrap::GetFPS) {
info.GetReturnValue().Set(Nan::New<Number>(fps)); info.GetReturnValue().Set(Nan::New<Number>(fps));
} }
NAN_METHOD(VideoCaptureWrap::SetFPS) {
Nan::HandleScope scope;
VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap<VideoCaptureWrap>(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<Number>(fps));
}
NAN_METHOD(VideoCaptureWrap::GetHeight) { NAN_METHOD(VideoCaptureWrap::GetHeight) {
Nan::HandleScope scope; Nan::HandleScope scope;

View File

@ -32,6 +32,7 @@ public:
static NAN_METHOD(GetFrameCount); static NAN_METHOD(GetFrameCount);
static NAN_METHOD(GetFPS); static NAN_METHOD(GetFPS);
static NAN_METHOD(SetFPS);
static NAN_METHOD(GetFrameAt); static NAN_METHOD(GetFrameAt);