Skip to content

Commit

Permalink
Merge pull request #422 from oyyd/fix-clang-warnings
Browse files Browse the repository at this point in the history
fix compiler warnings
  • Loading branch information
justadudewhohacks authored Oct 8, 2018
2 parents 069a26d + 5c247af commit 563e69c
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 45 deletions.
14 changes: 7 additions & 7 deletions cc/core/Mat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ NAN_METHOD(Mat::New) {
FF_ARR rowArray = FF_ARR::Cast(info[0]);
int type = info[1]->Int32Value();

int numCols = -1;
long numCols = -1;
for (uint i = 0; i < rowArray->Length(); i++) {
if (!rowArray->Get(i)->IsArray()) {
return Nan::ThrowError(Nan::New("Mat::New - Column should be an array, at column: " + std::to_string(i)).ToLocalChecked());
Expand All @@ -172,7 +172,7 @@ NAN_METHOD(Mat::New) {
// TODO by Vec
if (info[3]->IsArray()) {
FF_ARR vec = FF_ARR::Cast(info[3]);
if (mat.channels() != vec->Length()) {
if (mat.channels() != (long)vec->Length()) {
return Nan::ThrowError(FF_NEW_STRING(
std::string("Mat::New - number of channels (") + std::to_string(mat.channels())
+ std::string(") do not match fill vector length ") + std::to_string(vec->Length()))
Expand Down Expand Up @@ -274,7 +274,7 @@ NAN_METHOD(Mat::Set) {
int cn = matSelf.channels();
if (info[2]->IsArray()) {
FF_ARR vec = FF_ARR::Cast(info[2]);
FF_ASSERT_CHANNELS(cn, vec->Length(), "Mat::Set");
FF_ASSERT_CHANNELS(cn, (long)vec->Length(), "Mat::Set");
FF_MAT_APPLY_TYPED_OPERATOR(matSelf, vec, matSelf.type(), FF_MAT_SET, FF::matPut);
}
else if (FF_IS_INSTANCE(Vec2::constructor, info[2])) {
Expand Down Expand Up @@ -342,13 +342,13 @@ NAN_METHOD(Mat::Norm) {
double norm;

// optional args
bool hasOptArgsObj = FF_HAS_ARG(i) && info[i]->IsObject();
bool hasOptArgsObj = FF_HAS_ARG((long)i) && info[i]->IsObject();
FF_OBJ optArgs = hasOptArgsObj ? info[i]->ToObject() : FF_NEW_OBJ();
FF_GET_UINT_IFDEF(optArgs, uint normType, "normType", cv::NORM_L2);
FF_GET_INSTANCE_IFDEF(optArgs, cv::Mat mask, "mask", Mat::constructor, FF_UNWRAP_MAT_AND_GET, Mat, cv::noArray().getMat());
if (!hasOptArgsObj) {
FF_ARG_UINT_IFDEF(i, normType, normType);
FF_ARG_INSTANCE_IFDEF(i + 1, mask, Mat::constructor, FF_UNWRAP_MAT_AND_GET, mask);
FF_ARG_UINT_IFDEF((long)i, normType, normType);
FF_ARG_INSTANCE_IFDEF((long)(i + 1), mask, Mat::constructor, FF_UNWRAP_MAT_AND_GET, mask);
}

if (withSrc2) {
Expand Down Expand Up @@ -411,7 +411,7 @@ NAN_METHOD(Mat::Row) {
row->Set(c, jsVec);
}
} else {
return Nan::ThrowError(Nan::New("not implemented yet - mat type:" + mat.type()).ToLocalChecked());
return Nan::ThrowError(Nan::New("not implemented yet - mat type:" + std::to_string(mat.type())).ToLocalChecked());
}
} catch(std::exception &e) {
return Nan::ThrowError(e.what());
Expand Down
16 changes: 8 additions & 8 deletions cc/core/MatBindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -866,10 +866,10 @@ namespace MatBindings {
return (
IntConverter::optArg(4, &borderType, info) ||
(
self.channels() == 1 && DoubleConverter::optArg(5, &v1, info) ||
self.channels() == 2 && Vec2::Converter::optArg(5, &v2, info) ||
self.channels() == 3 && Vec3::Converter::optArg(5, &v3, info) ||
self.channels() == 4 && Vec4::Converter::optArg(5, &v4, info)
(self.channels() == 1 && DoubleConverter::optArg(5, &v1, info)) ||
(self.channels() == 2 && Vec2::Converter::optArg(5, &v2, info)) ||
(self.channels() == 3 && Vec3::Converter::optArg(5, &v3, info)) ||
(self.channels() == 4 && Vec4::Converter::optArg(5, &v4, info))
)
);
}
Expand All @@ -883,10 +883,10 @@ namespace MatBindings {
return (
IntConverter::optProp(&borderType, "borderType", opts) ||
(
self.channels() == 1 && DoubleConverter::optProp(&v1, "value", opts) ||
self.channels() == 2 && Vec2::Converter::optProp(&v2, "value", opts) ||
self.channels() == 3 && Vec3::Converter::optProp(&v3, "value", opts) ||
self.channels() == 4 && Vec4::Converter::optProp(&v4, "value", opts)
(self.channels() == 1 && DoubleConverter::optProp(&v1, "value", opts)) ||
(self.channels() == 2 && Vec2::Converter::optProp(&v2, "value", opts)) ||
(self.channels() == 3 && Vec3::Converter::optProp(&v3, "value", opts)) ||
(self.channels() == 4 && Vec4::Converter::optProp(&v4, "value", opts))
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion cc/core/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ NAN_METHOD(Core::Partition) {
v8::Local<v8::Function> cb = v8::Local<v8::Function>::Cast(info[1]);
FF_VAL data0 = jsData->Get(0);

int numLabels;
int numLabels = 0;
std::vector<int> labels;
if (FF_IS_INSTANCE(Point2::constructor, data0)) {
std::vector<cv::Point2d> pts;
Expand Down
46 changes: 23 additions & 23 deletions cc/modules/dnn/dnnBindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,76 @@ namespace DnnBindings {
struct ReadNetFromTensorflowWorker : public CatchCvExceptionWorker {
public:
std::string modelFile;

cv::dnn::Net net;

std::string executeCatchCvExceptionWorker() {
net = cv::dnn::readNetFromTensorflow(modelFile);
if (net.empty()) {
return std::string("failed to load net: " + modelFile).data();
}
return "";
}

v8::Local<v8::Value> getReturnValue() {
return Net::Converter::wrap(net);
}

bool unwrapRequiredArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return (
StringConverter::arg(0, &modelFile, info)
);
}
};

struct ReadNetFromCaffeWorker : public CatchCvExceptionWorker {
public:
std::string prototxt;
std::string modelFile = "";

cv::dnn::Net net;

std::string executeCatchCvExceptionWorker() {
net = cv::dnn::readNetFromCaffe(prototxt, modelFile);
if (net.empty()) {
return std::string("failed to prototxt: " + prototxt + ", modelFile: " + modelFile).data();
}
return "";
}

v8::Local<v8::Value> getReturnValue() {
return Net::Converter::wrap(net);
}

bool unwrapRequiredArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return (
StringConverter::arg(0, &prototxt, info)
);
}

bool unwrapOptionalArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return (
StringConverter::optArg(1, &modelFile, info)
);
}
};

struct BlobFromImageWorker : public CatchCvExceptionWorker {
public:
bool isSingleImage;
BlobFromImageWorker(bool isSingleImage = true) {
this->isSingleImage = isSingleImage;
}

cv::Mat image;
std::vector<cv::Mat> images;
double scalefactor = 1.0;
cv::Size2d size = cv::Size2d();
cv::Vec3d mean = cv::Vec3d();
bool swapRB = true;

cv::Mat returnValue;

std::string executeCatchCvExceptionWorker() {
if (isSingleImage) {
returnValue = cv::dnn::blobFromImage(image, scalefactor, size, mean, swapRB);
Expand All @@ -87,18 +87,18 @@ namespace DnnBindings {
}
return "";
}

v8::Local<v8::Value> getReturnValue() {
return Mat::Converter::wrap(returnValue);
}

bool unwrapRequiredArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return (
isSingleImage && Mat::Converter::arg(0, &image, info) ||
!isSingleImage && ObjectArrayConverter<Mat, cv::Mat>::arg(0, &images, info)
(isSingleImage && Mat::Converter::arg(0, &image, info)) ||
(!isSingleImage && ObjectArrayConverter<Mat, cv::Mat>::arg(0, &images, info))
);
}

bool unwrapOptionalArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return (
DoubleConverter::optArg(1, &scalefactor, info) ||
Expand All @@ -107,11 +107,11 @@ namespace DnnBindings {
BoolConverter::optArg(4, &swapRB, info)
);
}

bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF_ARG_IS_OBJECT(1);
}

bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
v8::Local<v8::Object> opts = info[1]->ToObject();
return (
Expand All @@ -122,8 +122,8 @@ namespace DnnBindings {
);
}
};


}

#endif
#endif
2 changes: 1 addition & 1 deletion cc/modules/face/LBPHFaceRecognizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ NAN_METHOD(LBPHFaceRecognizer::New) {
FF_RETURN(info.Holder());
};

#endif HAVE_FACE
#endif // HAVE_FACE
3 changes: 1 addition & 2 deletions cc/modules/features2d/descriptorMatchingKnn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ void DescriptorMatchingKnn::matchKnn(Nan::NAN_METHOD_ARGS_TYPE info, std::string
#else
void DescriptorMatchingKnn::matchKnn(Nan::NAN_METHOD_ARGS_TYPE info, int matcherType) {
#endif
MatchKnnWorker worker();
FF::SyncBinding(
std::make_shared<MatchKnnWorker>(cv::DescriptorMatcher::create(matcherType)),
"MSERDetector::MatchKnn",
Expand All @@ -154,4 +153,4 @@ void DescriptorMatchingKnn::matchKnnAsync(Nan::NAN_METHOD_ARGS_TYPE info, int ma
"MSERDetector::MatchKnnAsync",
info
);
}
}
2 changes: 1 addition & 1 deletion cc/modules/imgproc/Contour.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ NAN_METHOD(Contour::MatchShapes) {
FF_ARG_UINT(1, uint method);

// parameter not supported
double parameter;
double parameter = 0.0;
double cmp = cv::matchShapes(
FF_UNWRAP_CONTOUR_AND_GET(info.This()),
contour2,
Expand Down
4 changes: 2 additions & 2 deletions cc/modules/tracking/MultiTracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ NAN_METHOD(MultiTracker::Update) {
FF_UNWRAP(info.This(), MultiTracker)->tracker.update(image, rects);

FF_ARR jsRects = FF_NEW_ARRAY(rects.size());
for (int i = 0; i < rects.size(); i++) {
for (unsigned long i = 0; i < rects.size(); i++) {
FF_OBJ jsRect = FF_NEW_INSTANCE(Rect::constructor);
FF_UNWRAP_RECT_AND_GET(jsRect) = rects.at(i);
jsRects->Set(i, jsRect);
Expand All @@ -116,4 +116,4 @@ NAN_METHOD(MultiTracker::Update) {

#endif

#endif
#endif

0 comments on commit 563e69c

Please sign in to comment.