Skip to content
Open
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
20 changes: 10 additions & 10 deletions cc/core/Mat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ Nan::Persistent<v8::FunctionTemplate> Mat::constructor;

namespace FF {
/**
* 2,3-Dimmentions Macro seters for a single Value
* 2,3-Dimensions Macro seters for a single Value
*/
template <typename type, int n>
static inline void matPutVal(cv::Mat mat, v8::Local<v8::Value> value, const cv::Vec<int, n>& idx) {
mat.at<type>(idx) = (type)value->ToNumber(Nan::GetCurrentContext()).ToLocalChecked()->Value();
}

/**
* 2,3-Dimmentions Macro seters for a Vec<2> Value
* 2,3-Dimensions Macro seters for a Vec<2> Value
*/

template <typename type, int n>
Expand All @@ -40,7 +40,7 @@ static inline void matPutVec2(cv::Mat mat, v8::Local<v8::Value> vector, const cv
(type)FF::DoubleConverter::unwrapUnchecked(Nan::Get(vec, 1).ToLocalChecked()));
}
/**
* 2,3-Dimmentions Macro seters for a Vec<3> Value
* 2,3-Dimensions Macro seters for a Vec<3> Value
*/

template <typename type, int n>
Expand All @@ -52,7 +52,7 @@ static inline void matPutVec3(cv::Mat mat, v8::Local<v8::Value> vector, const cv
(type)FF::DoubleConverter::unwrapUnchecked(Nan::Get(vec, 2).ToLocalChecked()));
}
/**
* 2,3-Dimmentions Macro seters for a Vec<4> Value
* 2,3-Dimensions Macro seters for a Vec<4> Value
*/

template <typename type, int n>
Expand Down Expand Up @@ -475,10 +475,10 @@ NAN_METHOD(Mat::New) {
dim = dim + 1;
rowArray0 = v8::Local<v8::Array>::Cast(Nan::Get(rowArray0, 0).ToLocalChecked());
}
// if multishanel drop one dimmention
// if multishanel drop one Dimension
if (channel > 1)
dim--;
// std::cout << "Create a Mat of " << dim << " dimentions eatch item has " << channel << " channel(s)." << std::endl;
// std::cout << "Create a Mat of " << dim << " dimensions eatch item has " << channel << " channel(s)." << std::endl;

// reset row0
rowArray0 = v8::Local<v8::Array>::Cast(info[0]);
Expand All @@ -490,7 +490,7 @@ NAN_METHOD(Mat::New) {
}
cv::Mat mat = cv::Mat(sizes, type);
self->setNativeObject(mat);
// return tryCatch.throwError("Mat::New - Mat must have at least 2 Dimentions");
// return tryCatch.throwError("Mat::New - Mat must have at least 2 dimensions");
} else if (dim == 2) {
long rows = rowArray0->Length();
long numCols = -1;
Expand Down Expand Up @@ -569,7 +569,7 @@ NAN_METHOD(Mat::New) {
FF_MAT_APPLY_TYPED_OPERATOR(mat, rowArray0, type, FF_MAT_FROM_JS_ARRAY_4D, FF::matPut);
self->setNativeObject(mat);
} else {
return tryCatch.throwError("Mat::New - Support only 4 Dimmention provided payload contains " + std::to_string(dim));
return tryCatch.throwError("Mat::New - Support only 4 dimensions provided payload contains " + std::to_string(dim));
}
}
/* row, col, type
Expand All @@ -578,7 +578,7 @@ NAN_METHOD(Mat::New) {
*/
else if (info[0]->IsNumber() && info[1]->IsNumber() && info[2]->IsInt32()) {
int type = info[2]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value();
if (info.Length() == 3 || info[3]->IsArray() || info[3]->IsNumber()) {
if (info.Length() == 3 || info[3]->IsArray() || info[3]->IsNumber() || info[3]->IsBoolean()) {

cv::Mat mat(info[0]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value(), info[1]->ToInt32(Nan::GetCurrentContext()).ToLocalChecked()->Value(), type);

Expand All @@ -593,7 +593,7 @@ NAN_METHOD(Mat::New) {
}
FF_MAT_APPLY_TYPED_OPERATOR(mat, vec, type, FF_MAT_FILL, FF::matPut);
}
if (info[3]->IsNumber()) {
if (info[3]->IsNumber() || info[3]->IsBoolean()) {
FF_MAT_APPLY_TYPED_OPERATOR(mat, info[3], type, FF_MAT_FILL, FF::matPut);
}
self->setNativeObject(mat);
Expand Down