Added setWidth and setHeight for VideoCapture issue #126

This commit is contained in:
Salman 2014-05-03 16:30:13 +05:00
parent 3be5877116
commit 28750d1275
2 changed files with 31 additions and 0 deletions

View File

@ -2,6 +2,9 @@
#include "Matrix.h" #include "Matrix.h"
#include "OpenCV.h" #include "OpenCV.h"
#include <iostream>
using namespace std;
void AsyncRead(uv_work_t *req); void AsyncRead(uv_work_t *req);
void AfterAsyncRead(uv_work_t *req); void AfterAsyncRead(uv_work_t *req);
@ -31,6 +34,8 @@ VideoCaptureWrap::Init(Handle<Object> target) {
//Local<ObjectTemplate> proto = constructor->PrototypeTemplate(); //Local<ObjectTemplate> proto = constructor->PrototypeTemplate();
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, "setHeight", SetHeight);
target->Set(String::NewSymbol("VideoCapture"), constructor->GetFunction()); target->Set(String::NewSymbol("VideoCapture"), constructor->GetFunction());
}; };
@ -77,6 +82,28 @@ VideoCaptureWrap::VideoCaptureWrap(const std::string& filename){
} }
Handle<Value>
VideoCaptureWrap::SetWidth(const Arguments &args){
HandleScope scope;
VideoCaptureWrap *v = ObjectWrap::Unwrap<VideoCaptureWrap>(args.This());
if(v->cap.isOpened())
v->cap.set(CV_CAP_PROP_FRAME_WIDTH, 320);
return Undefined();
}
Handle<Value>
VideoCaptureWrap::SetHeight(const Arguments &args){
HandleScope scope;
VideoCaptureWrap *v = ObjectWrap::Unwrap<VideoCaptureWrap>(args.This());
v->cap.set(CV_CAP_PROP_FRAME_HEIGHT, 240);
return Undefined();
}
Handle<Value> Handle<Value>
VideoCaptureWrap::Read(const Arguments &args) { VideoCaptureWrap::Read(const Arguments &args) {

View File

@ -13,6 +13,10 @@ 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
static Handle<Value> SetWidth(const v8::Arguments&);
static Handle<Value> SetHeight(const v8::Arguments&);
static Handle<Value> GetFrameAt(const v8::Arguments&); static Handle<Value> GetFrameAt(const v8::Arguments&);