Add SetPosition method

Allows video read stream to advance to a particular frame
This commit is contained in:
John Ludwig 2014-06-19 12:10:12 -07:00
parent e8e8170b46
commit 17f59cee5f
2 changed files with 22 additions and 2 deletions

View File

@ -36,6 +36,7 @@ VideoCaptureWrap::Init(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(constructor, "read", Read);
NODE_SET_PROTOTYPE_METHOD(constructor, "setWidth", SetWidth);
NODE_SET_PROTOTYPE_METHOD(constructor, "setHeight", SetHeight);
NODE_SET_PROTOTYPE_METHOD(constructor, "setPosition", SetPosition);
target->Set(String::NewSymbol("VideoCapture"), constructor->GetFunction());
};
@ -115,6 +116,22 @@ VideoCaptureWrap::SetHeight(const Arguments &args){
return Undefined();
}
Handle<Value>
VideoCaptureWrap::SetPosition(const Arguments &args){
HandleScope scope;
VideoCaptureWrap *v = ObjectWrap::Unwrap<VideoCaptureWrap>(args.This());
if(args.Length() != 1)
return scope.Close(Undefined());
int pos = args[0]->IntegerValue();
v->cap.set(CV_CAP_PROP_POS_FRAMES, pos);
return Undefined();
}
Handle<Value>
VideoCaptureWrap::Read(const Arguments &args) {

View File

@ -14,8 +14,11 @@ class VideoCaptureWrap: public node::ObjectWrap {
static Handle<Value> Read(const v8::Arguments&);
//(Optional) For setting width and height of the input video stream
static Handle<Value> SetWidth(const v8::Arguments&);
static Handle<Value> SetHeight(const v8::Arguments&);
static Handle<Value> SetWidth(const v8::Arguments&);
static Handle<Value> SetHeight(const v8::Arguments&);
// to set frame position
static Handle<Value> SetPosition(const v8::Arguments&);
static Handle<Value> GetFrameAt(const v8::Arguments&);