mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Merge branch 'master' into rmbackground
This commit is contained in:
commit
6750f4ff64
@ -29,7 +29,7 @@ BackgroundSubtractorWrap::New(const Arguments &args) {
|
||||
JSTHROW_TYPE("Cannot Instantiate without new")
|
||||
|
||||
//Create MOG by default
|
||||
cv::Ptr<cv::BackgroundSubtractor> bg = cv::createBackgroundSubtractorMOG(200, 5, 0.7, 0);
|
||||
cv::Ptr<cv::BackgroundSubtractor> bg;
|
||||
BackgroundSubtractorWrap *pt = new BackgroundSubtractorWrap(bg);
|
||||
|
||||
pt->Wrap(args.This());
|
||||
@ -55,9 +55,7 @@ BackgroundSubtractorWrap::CreateMOG(const Arguments &args) {
|
||||
|
||||
Local<Object> n = BackgroundSubtractorWrap::constructor->GetFunction()->NewInstance();
|
||||
|
||||
cv::Ptr<cv::BackgroundSubtractor> bg = cv::createBackgroundSubtractorMOG(
|
||||
history, nmixtures, backgroundRatio, noiseSigma
|
||||
);
|
||||
cv::Ptr<cv::BackgroundSubtractor> bg;
|
||||
BackgroundSubtractorWrap *pt = new BackgroundSubtractorWrap(bg);
|
||||
|
||||
pt->Wrap(n);
|
||||
@ -106,7 +104,7 @@ BackgroundSubtractorWrap::ApplyMOG(const Arguments &args) {
|
||||
}
|
||||
|
||||
cv::Mat _fgMask;
|
||||
self->subtractor->apply(mat, _fgMask);
|
||||
self->subtractor->operator()(mat, _fgMask);
|
||||
|
||||
img->mat = _fgMask;
|
||||
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
#include "Matrix.h"
|
||||
#include "OpenCV.h"
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
void AsyncRead(uv_work_t *req);
|
||||
void AfterAsyncRead(uv_work_t *req);
|
||||
@ -31,6 +34,8 @@ VideoCaptureWrap::Init(Handle<Object> target) {
|
||||
//Local<ObjectTemplate> proto = constructor->PrototypeTemplate();
|
||||
|
||||
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());
|
||||
};
|
||||
@ -77,6 +82,38 @@ VideoCaptureWrap::VideoCaptureWrap(const std::string& filename){
|
||||
|
||||
}
|
||||
|
||||
Handle<Value>
|
||||
VideoCaptureWrap::SetWidth(const Arguments &args){
|
||||
|
||||
HandleScope scope;
|
||||
VideoCaptureWrap *v = ObjectWrap::Unwrap<VideoCaptureWrap>(args.This());
|
||||
|
||||
if(args.Length() != 1)
|
||||
return scope.Close(Undefined());
|
||||
|
||||
int w = args[0]->IntegerValue();
|
||||
|
||||
if(v->cap.isOpened())
|
||||
v->cap.set(CV_CAP_PROP_FRAME_WIDTH, w);
|
||||
|
||||
return scope.Close(Undefined());
|
||||
}
|
||||
|
||||
Handle<Value>
|
||||
VideoCaptureWrap::SetHeight(const Arguments &args){
|
||||
|
||||
HandleScope scope;
|
||||
VideoCaptureWrap *v = ObjectWrap::Unwrap<VideoCaptureWrap>(args.This());
|
||||
|
||||
if(args.Length() != 1)
|
||||
return scope.Close(Undefined());
|
||||
|
||||
int h = args[0]->IntegerValue();
|
||||
|
||||
v->cap.set(CV_CAP_PROP_FRAME_HEIGHT, h);
|
||||
|
||||
return Undefined();
|
||||
}
|
||||
|
||||
Handle<Value>
|
||||
VideoCaptureWrap::Read(const Arguments &args) {
|
||||
|
||||
@ -13,6 +13,10 @@ 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> GetFrameAt(const v8::Arguments&);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user