From 3e9daa46f80b6065707fb487b7b93f394478b21f Mon Sep 17 00:00:00 2001 From: Jakob Schindegger Date: Mon, 4 Sep 2017 22:52:37 +0200 Subject: [PATCH 1/2] Adding getHeight and getWidth methods --- src/VideoCaptureWrap.cc | 18 ++++++++++++++++++ src/VideoCaptureWrap.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/src/VideoCaptureWrap.cc b/src/VideoCaptureWrap.cc index 47eb8d5..c1958b6 100755 --- a/src/VideoCaptureWrap.cc +++ b/src/VideoCaptureWrap.cc @@ -79,6 +79,15 @@ VideoCaptureWrap::VideoCaptureWrap(const std::string& filename) { } } +NAN_METHOD(VideoCaptureWrap::GetWidth) { + Nan::HandleScope scope; + VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap(info.This()); + + int cnt = int(v->cap.get(CV_CAP_PROP_FRAME_WIDTH)); + + info.GetReturnValue().Set(Nan::New(cnt)); +} + NAN_METHOD(VideoCaptureWrap::SetWidth) { Nan::HandleScope scope; VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap(info.This()); @@ -103,6 +112,15 @@ NAN_METHOD(VideoCaptureWrap::GetFrameCount) { info.GetReturnValue().Set(Nan::New(cnt)); } +NAN_METHOD(VideoCaptureWrap::GetHeight) { + Nan::HandleScope scope; + VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap(info.This()); + + int cnt = int(v->cap.get(CV_CAP_PROP_FRAME_HEIGHT)); + + 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 cb01a72..55a73f6 100755 --- a/src/VideoCaptureWrap.h +++ b/src/VideoCaptureWrap.h @@ -17,6 +17,10 @@ public: static NAN_METHOD(Grab); static NAN_METHOD(Retrieve); + // For getting width and height of the input video stream + static NAN_METHOD(GetWidth); + static NAN_METHOD(GetHeight); + // (Optional) For setting width and height of the input video stream static NAN_METHOD(SetWidth); static NAN_METHOD(SetHeight); From 5ebc9b3ced30d8017809629759e7e7b272b703c5 Mon Sep 17 00:00:00 2001 From: Jakob Schindegger Date: Sun, 10 Sep 2017 17:00:31 +0200 Subject: [PATCH 2/2] Adding missing mapping --- src/VideoCaptureWrap.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/VideoCaptureWrap.cc b/src/VideoCaptureWrap.cc index c1958b6..b4e4634 100755 --- a/src/VideoCaptureWrap.cc +++ b/src/VideoCaptureWrap.cc @@ -30,6 +30,8 @@ void VideoCaptureWrap::Init(Local target) { Nan::SetPrototypeMethod(ctor, "read", Read); Nan::SetPrototypeMethod(ctor, "setWidth", SetWidth); Nan::SetPrototypeMethod(ctor, "setHeight", SetHeight); + Nan::SetPrototypeMethod(ctor, "getWidth", GetWidth); + Nan::SetPrototypeMethod(ctor, "getHeight", GetHeight); Nan::SetPrototypeMethod(ctor, "setPosition", SetPosition); Nan::SetPrototypeMethod(ctor, "getFrameAt", GetFrameAt); Nan::SetPrototypeMethod(ctor, "getFrameCount", GetFrameCount);