Skip to content

Commit b740255

Browse files
committed
Merge pull request #366 from sirotenko/master
Added getFrameCount method to VideoCapture
2 parents 964da8e + a451393 commit b740255

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/VideoCaptureWrap.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ void VideoCaptureWrap::Init(Local<Object> target) {
3333
Nan::SetPrototypeMethod(ctor, "setHeight", SetHeight);
3434
Nan::SetPrototypeMethod(ctor, "setPosition", SetPosition);
3535
Nan::SetPrototypeMethod(ctor, "getFrameAt", GetFrameAt);
36+
Nan::SetPrototypeMethod(ctor, "getFrameCount", GetFrameCount);
3637
Nan::SetPrototypeMethod(ctor, "close", Close);
3738
Nan::SetPrototypeMethod(ctor, "ReadSync", ReadSync);
3839
Nan::SetPrototypeMethod(ctor, "grab", Grab);
@@ -94,6 +95,15 @@ NAN_METHOD(VideoCaptureWrap::SetWidth) {
9495
return;
9596
}
9697

98+
NAN_METHOD(VideoCaptureWrap::GetFrameCount) {
99+
Nan::HandleScope scope;
100+
VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap<VideoCaptureWrap>(info.This());
101+
102+
int cnt = int(v->cap.get(CV_CAP_PROP_FRAME_COUNT));
103+
104+
info.GetReturnValue().Set(Nan::New<Number>(cnt));
105+
}
106+
97107
NAN_METHOD(VideoCaptureWrap::SetHeight) {
98108
Nan::HandleScope scope;
99109
VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap<VideoCaptureWrap>(info.This());

src/VideoCaptureWrap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class VideoCaptureWrap: public Nan::ObjectWrap {
2323

2424
// to set frame position
2525
static NAN_METHOD(SetPosition);
26+
static NAN_METHOD(GetFrameCount);
2627

2728
static NAN_METHOD(GetFrameAt);
2829

0 commit comments

Comments
 (0)