#include "macros.h" #include "CvBinding.h" #include "../FeatureDetector.h" #ifndef __FF_AGASTDETECTOR_H__ #define __FF_AGASTDETECTOR_H__ class AGASTDetector : public FeatureDetector, public FF::ObjectWrapTemplate> { public: static Nan::Persistent constructor; static const char* getClassName() { return "AGASTDetector"; } cv::Ptr getDetector() { return self; } #if CV_VERSION_GREATER_EQUAL(4, 0, 0) class DetectorType : public FF::EnumWrap { public: typedef cv::AgastFeatureDetector::DetectorType Type; static const char* getClassName() { return "AGASTDetectorType"; } static std::vector getEnumValues() { return { Type::AGAST_5_8, Type::AGAST_7_12d, Type::AGAST_7_12s, Type::OAST_9_16 }; } static std::vector getEnumMappings() { return { "AGAST_5_8", "AGAST_7_12d", "AGAST_7_12s", "OAST_9_16" }; } }; #endif FF_GETTER_CUSTOM(threshold, FF::DoubleConverter, self->getThreshold()); FF_GETTER_CUSTOM(nonmaxSuppression, FF::BoolConverter, self->getNonmaxSuppression()); #if CV_VERSION_GREATER_EQUAL(4, 0, 0) FF_GETTER_CUSTOM(type, AGASTDetector::DetectorType::Converter, self->getType()); #else FF_GETTER_CUSTOM(type, FF::IntConverter, self->getType()); #endif static NAN_MODULE_INIT(Init); static NAN_METHOD(New); class NewBinding : public CvBinding { public: void construct(Nan::NAN_METHOD_ARGS_TYPE info) { FF::TryCatch tryCatch("AGASTDetector::New"); FF_ASSERT_CONSTRUCT_CALL(); auto threshold = opt("threshold", 10); auto nonmaxSuppression = opt("nonmaxSuppression", true); #if CV_VERSION_GREATER_EQUAL(4, 0, 0) auto type = opt("type", cv::AgastFeatureDetector::OAST_9_16); #else auto type = opt("type", cv::AgastFeatureDetector::OAST_9_16); #endif if (applyUnwrappers(info)) { return tryCatch.reThrow(); } AGASTDetector* self = new AGASTDetector(); self->setNativeObject(cv::AgastFeatureDetector::create( threshold->ref(), nonmaxSuppression->ref(), type->ref() )); self->Wrap(info.Holder()); info.GetReturnValue().Set(info.Holder()); }; }; }; #endif