From ca36b462ce6b87243489effabd9cf65b6fe3bba5 Mon Sep 17 00:00:00 2001 From: Matthias Klan Date: Tue, 8 Dec 2015 14:54:35 +0100 Subject: [PATCH] Implement getFrameAt getFrameAt takes the position of the video in milliseconds --- src/VideoCaptureWrap.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/VideoCaptureWrap.cc b/src/VideoCaptureWrap.cc index 8bfc453..e0d06c2 100755 --- a/src/VideoCaptureWrap.cc +++ b/src/VideoCaptureWrap.cc @@ -32,6 +32,7 @@ void VideoCaptureWrap::Init(Local target) { Nan::SetPrototypeMethod(ctor, "setWidth", SetWidth); Nan::SetPrototypeMethod(ctor, "setHeight", SetHeight); Nan::SetPrototypeMethod(ctor, "setPosition", SetPosition); + Nan::SetPrototypeMethod(ctor, "getFrameAt", GetFrameAt); Nan::SetPrototypeMethod(ctor, "close", Close); Nan::SetPrototypeMethod(ctor, "ReadSync", ReadSync); Nan::SetPrototypeMethod(ctor, "grab", Grab); @@ -121,6 +122,20 @@ NAN_METHOD(VideoCaptureWrap::SetPosition) { return; } +NAN_METHOD(VideoCaptureWrap::GetFrameAt) { + Nan::HandleScope scope; + VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap(info.This()); + + if(info.Length() != 1) + return; + + int pos = info[0]->IntegerValue(); + + v->cap.set(CV_CAP_PROP_POS_MSEC, pos); + + return; +} + NAN_METHOD(VideoCaptureWrap::Close) { Nan::HandleScope scope; VideoCaptureWrap *v = Nan::ObjectWrap::Unwrap(info.This());