mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Use JSTHROW* macros and fix coding style
Replace Nan::ThrowError by JSTHROW and Nan::ThrowTypeError by JSTHROW_TYPE.
This commit is contained in:
parent
1d126caba5
commit
9b6c9a934c
@ -2,9 +2,12 @@ var cv = require('../lib/opencv');
|
||||
|
||||
// Load the image
|
||||
cv.readImage('./files/note.png', function(err, im) {
|
||||
console.log('plop');
|
||||
if (err) { throw err; }
|
||||
if (im.width() < 1 || im.height() < 1) { throw new Error('Image has no size'); }
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
if (im.width() < 1 || im.height() < 1) {
|
||||
throw new Error('Image has no size');
|
||||
}
|
||||
|
||||
im.cvtColor('CV_BGR2GRAY');
|
||||
var bw = im.adaptiveThreshold(255, 0, 0, 15, 2);
|
||||
|
||||
@ -172,14 +172,14 @@ NAN_METHOD(ImgProc::GetStructuringElement) {
|
||||
|
||||
// Arg 0 is the element shape
|
||||
if (!info[0]->IsNumber()) {
|
||||
Nan::ThrowTypeError("'shape' argument must be a number");
|
||||
JSTHROW_TYPE("'shape' argument must be a number");
|
||||
}
|
||||
int shape = info[0]->NumberValue();
|
||||
|
||||
// Arg 1 is the size of the structuring element
|
||||
cv::Size ksize;
|
||||
if (!info[1]->IsArray()) {
|
||||
Nan::ThrowTypeError("'ksize' argument must be a 2 double array");
|
||||
JSTHROW_TYPE("'ksize' argument must be a 2 double array");
|
||||
}
|
||||
Local<Object> v8sz = info[1]->ToObject();
|
||||
ksize = cv::Size(v8sz->Get(0)->IntegerValue(), v8sz->Get(1)->IntegerValue());
|
||||
@ -196,7 +196,7 @@ NAN_METHOD(ImgProc::GetStructuringElement) {
|
||||
info.GetReturnValue().Set(outMatrixWrap);
|
||||
} catch (cv::Exception &e) {
|
||||
const char *err_msg = e.what();
|
||||
Nan::ThrowError(err_msg);
|
||||
JSTHROW(err_msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user