mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
resize(async): seems we can get an assert in Unwrap if image has 0,0, size, so catch and report as a callback error.
This commit is contained in:
parent
fdd0c97a3c
commit
ab0bd505d2
@ -1919,22 +1919,35 @@ public:
|
|||||||
Nan::HandleScope scope;
|
Nan::HandleScope scope;
|
||||||
|
|
||||||
if (success){
|
if (success){
|
||||||
Local<Object> im_to_return= Nan::NewInstance(Nan::GetFunction(Nan::New(Matrix::constructor)).ToLocalChecked()).ToLocalChecked();
|
try{
|
||||||
Matrix *img = Nan::ObjectWrap::Unwrap<Matrix>(im_to_return);
|
Local<Object> im_to_return= Nan::NewInstance(Nan::GetFunction(Nan::New(Matrix::constructor)).ToLocalChecked()).ToLocalChecked();
|
||||||
img->mat = dest->mat;
|
Matrix *img = Nan::ObjectWrap::Unwrap<Matrix>(im_to_return);
|
||||||
delete dest;
|
img->mat = dest->mat;
|
||||||
|
delete dest;
|
||||||
//delete dest;
|
|
||||||
|
|
||||||
Local<Value> argv[] = {
|
|
||||||
Nan::Null(), // err
|
|
||||||
im_to_return //result
|
|
||||||
};
|
|
||||||
|
|
||||||
Nan::TryCatch try_catch;
|
//delete dest;
|
||||||
callback->Call(2, argv);
|
|
||||||
if (try_catch.HasCaught()) {
|
Local<Value> argv[] = {
|
||||||
Nan::FatalException(try_catch);
|
Nan::Null(), // err
|
||||||
|
im_to_return //result
|
||||||
|
};
|
||||||
|
|
||||||
|
Nan::TryCatch try_catch;
|
||||||
|
callback->Call(2, argv);
|
||||||
|
if (try_catch.HasCaught()) {
|
||||||
|
Nan::FatalException(try_catch);
|
||||||
|
}
|
||||||
|
} catch (...){
|
||||||
|
Local<Value> argv[] = {
|
||||||
|
Nan::New("C++ exception wrapping response").ToLocalChecked(), // err
|
||||||
|
Nan::Null() // result
|
||||||
|
};
|
||||||
|
|
||||||
|
Nan::TryCatch try_catch;
|
||||||
|
callback->Call(2, argv);
|
||||||
|
if (try_catch.HasCaught()) {
|
||||||
|
Nan::FatalException(try_catch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
delete dest;
|
delete dest;
|
||||||
@ -2022,11 +2035,15 @@ NAN_METHOD(Matrix::Resize) {
|
|||||||
Nan::AsyncQueueWorker(new ResizeASyncWorker(callback, self, size, fx, fy, interpolation));
|
Nan::AsyncQueueWorker(new ResizeASyncWorker(callback, self, size, fx, fy, interpolation));
|
||||||
info.GetReturnValue().Set(Nan::Null());
|
info.GetReturnValue().Set(Nan::Null());
|
||||||
} else {
|
} else {
|
||||||
Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This());
|
try{
|
||||||
cv::Mat res = cv::Mat(x, y, CV_32FC3);
|
Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This());
|
||||||
cv::resize(self->mat, res, cv::Size(x, y), 0, 0, interpolation);
|
cv::Mat res = cv::Mat(x, y, CV_32FC3);
|
||||||
~self->mat;
|
cv::resize(self->mat, res, cv::Size(x, y), 0, 0, interpolation);
|
||||||
self->mat = res;
|
~self->mat;
|
||||||
|
self->mat = res;
|
||||||
|
} catch (...){
|
||||||
|
return Nan::ThrowError("c++ Exception processing resize");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user