Skip to content

Wrapping add array operation, for additive blends. #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions src/MatOp.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include "MatOp.h"

//Usage: cv.add(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1)
Handle<Value>
MatOp::Add(const v8::Arguments& args){
HandleScope scope;

Matrix *src1 = ObjectWrap::Unwrap<Matrix>(args[0]->ToObject());
Matrix *src2 = ObjectWrap::Unwrap<Matrix>(args[1]->ToObject());
Matrix *dst = ObjectWrap::Unwrap<Matrix>(args[2]->ToObject());
Matrix *mask = args.Length() < 4 ? new Matrix() : ObjectWrap::Unwrap<Matrix>(args[3]->ToObject());
int dtype = args.Length() < 5 ? -1 : args[4]->Uint32Value();

cv::add(src1->mat, src2->mat, dst->mat, mask->mat, dtype);

return scope.Close(v8::Null());
}

/*

Handle<Value>
Matrix::Divide(const v8::Arguments& args) {
HandleScope scope;

Matrix *self = ObjectWrap::Unwrap<Matrix>(args.This());

Matrix *src1 = ObjectWrap::Unwrap<Matrix>(args[0]->ToObject());
cv::bitwise_not(src1->mat, self->mat);

return scope.Close(v8::Null());
}

Handle<Value>
Matrix::Multiply(const v8::Arguments& args) {
HandleScope scope;

Matrix *self = ObjectWrap::Unwrap<Matrix>(args.This());

Matrix *src1 = ObjectWrap::Unwrap<Matrix>(args[0]->ToObject());
cv::bitwise_not(src1->mat, self->mat);

return scope.Close(v8::Null());
}

Handle<Value>
Matrix::Subtract(const v8::Arguments& args) {
HandleScope scope;

Matrix *self = ObjectWrap::Unwrap<Matrix>(args.This());

Matrix *src1 = ObjectWrap::Unwrap<Matrix>(args[0]->ToObject());
cv::bitwise_not(src1->mat, self->mat);

return scope.Close(v8::Null());
}

Handle<Value>
Matrix::Add(const v8::Arguments& args) {
HandleScope scope;

Matrix *self = ObjectWrap::Unwrap<Matrix>(args.This());

Matrix *src1 = ObjectWrap::Unwrap<Matrix>(args[0]->ToObject());
cv::bitwise_not(src1->mat, self->mat);

return scope.Close(v8::Null());
}*/
9 changes: 9 additions & 0 deletions src/MatOp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

#include <cv.h>
#include "Matrix.h"

class MatOp {
public:
static Handle<Value> Add(const v8::Arguments&);
};

4 changes: 2 additions & 2 deletions src/OpenCV.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "OpenCV.h"
#include "Matrix.h"
#include "MatOp.h"

void
OpenCV::Init(Handle<Object> target) {
Expand All @@ -12,11 +13,10 @@ OpenCV::Init(Handle<Object> target) {
target->Set(String::NewSymbol("version"), String::New(out, n));

NODE_SET_METHOD(target, "readImage", ReadImage);
NODE_SET_METHOD(target, "add", MatOp::Add);

}



Handle<Value>
OpenCV::ReadImage(const Arguments &args) {
HandleScope scope;
Expand Down