From 12e3c6e25ce5f0e67a58eb03f3d60d8d464bafb0 Mon Sep 17 00:00:00 2001 From: boelroy Date: Tue, 17 Jan 2017 16:13:20 +0800 Subject: [PATCH] add the type function in Matrix class --- src/Matrix.cc | 7 +++++++ src/Matrix.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/Matrix.cc b/src/Matrix.cc index 72d54bd..0d3665f 100755 --- a/src/Matrix.cc +++ b/src/Matrix.cc @@ -35,6 +35,7 @@ void Matrix::Init(Local target) { Nan::SetPrototypeMethod(ctor, "pixel", Pixel); Nan::SetPrototypeMethod(ctor, "width", Width); Nan::SetPrototypeMethod(ctor, "height", Height); + Nan::SetPrototypeMethod(ctor, "type", Type); Nan::SetPrototypeMethod(ctor, "size", Size); Nan::SetPrototypeMethod(ctor, "clone", Clone); Nan::SetPrototypeMethod(ctor, "crop", Crop); @@ -497,6 +498,12 @@ NAN_METHOD(Matrix::Size) { info.GetReturnValue().Set(arr); } +NAN_METHOD(Matrix::Type) { + SETUP_FUNCTION(Matrix) + + info.GetReturnValue().Set(Nan::New(self->mat.type())); +} + NAN_METHOD(Matrix::Clone) { SETUP_FUNCTION(Matrix) diff --git a/src/Matrix.h b/src/Matrix.h index ee337e6..03fc112 100755 --- a/src/Matrix.h +++ b/src/Matrix.h @@ -36,6 +36,7 @@ public: JSFUNC(Size) JSFUNC(Width) JSFUNC(Height) + JSFUNC(Type) JSFUNC(Channels) JSFUNC(Clone) JSFUNC(Ellipse)