Merge pull request #142 from jhludwig/Video-SetPosition

Add SetPosition method
This commit is contained in:
Peter Braden 2014-06-20 09:27:33 +02:00
commit 86560fd68b
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, "read", Read);
NODE_SET_PROTOTYPE_METHOD(constructor, "setWidth", SetWidth); NODE_SET_PROTOTYPE_METHOD(constructor, "setWidth", SetWidth);
NODE_SET_PROTOTYPE_METHOD(constructor, "setHeight", SetHeight); NODE_SET_PROTOTYPE_METHOD(constructor, "setHeight", SetHeight);
NODE_SET_PROTOTYPE_METHOD(constructor, "setPosition", SetPosition);
target->Set(String::NewSymbol("VideoCapture"), constructor->GetFunction()); target->Set(String::NewSymbol("VideoCapture"), constructor->GetFunction());
}; };
@ -115,6 +116,22 @@ VideoCaptureWrap::SetHeight(const Arguments &args){
return Undefined(); 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> Handle<Value>
VideoCaptureWrap::Read(const Arguments &args) { VideoCaptureWrap::Read(const Arguments &args) {

View File

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