Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit e681da0

Browse files
added bunch of bindings to HOGDescriptor
1 parent 9b08201 commit e681da0

File tree

6 files changed

+584
-0
lines changed

6 files changed

+584
-0
lines changed

cc/AbstractConverter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class AbstractConverter {
5252
return ConverterType::wrap(val);
5353
}
5454

55+
static bool unwrap(T* val, v8::Local<v8::Value> jsVal) {
56+
return ConverterType::unwrap(vec, jsVal);
57+
}
58+
5559
static bool optProp(T* val, const char* prop, v8::Local<v8::Object> opts) {
5660
Nan::TryCatch tryCatch;
5761
if (

cc/modules/objdetect/DetectionROI.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "DetectionROI.h"
2+
3+
Nan::Persistent<v8::FunctionTemplate> DetectionROI::constructor;
4+
5+
NAN_MODULE_INIT(DetectionROI::Init) {
6+
v8::Local<v8::FunctionTemplate> ctor = Nan::New<v8::FunctionTemplate>(DetectionROI::New);
7+
v8::Local<v8::ObjectTemplate> instanceTemplate = ctor->InstanceTemplate();
8+
9+
constructor.Reset(ctor);
10+
ctor->SetClassName(FF_NEW_STRING("DetectionROI"));
11+
instanceTemplate->SetInternalFieldCount(1);
12+
13+
Nan::SetAccessor(instanceTemplate, FF_NEW_STRING("scale"), scaleGet, scaleSet);
14+
Nan::SetAccessor(instanceTemplate, FF_NEW_STRING("locations"), locationsGet, locationsSet);
15+
Nan::SetAccessor(instanceTemplate, FF_NEW_STRING("confidences"), confidencesGet, confidencesSet);
16+
17+
target->Set(FF_NEW_STRING("DetectionROI"), ctor->GetFunction());
18+
};
19+
20+
NAN_METHOD(DetectionROI::New) {
21+
DetectionROI* self = new DetectionROI();
22+
self->Wrap(info.Holder());
23+
FF_RETURN(info.Holder());
24+
};

cc/modules/objdetect/DetectionROI.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include "Converters.h"
2+
#include <opencv2/objdetect.hpp>
3+
#include "Point.h"
4+
5+
#ifndef __FF_DETECTIONROI_H__
6+
#define __FF_DETECTIONROI_H__
7+
8+
class DetectionROI : public Nan::ObjectWrap {
9+
public:
10+
cv::DetectionROI detectionROI;
11+
12+
static NAN_MODULE_INIT(Init);
13+
static NAN_METHOD(New);
14+
15+
static FF_GETTER(DetectionROI, scaleGet, detectionROI.scale);
16+
static FF_SETTER_NUMBER(DetectionROI, scale, detectionROI.scale);
17+
static NAN_GETTER(locationsGet) {
18+
FF_VAL val = ObjectArrayConverter<Point2, cv::Point2d, cv::Point>::wrap(Converter::unwrap(info.This()).locations);
19+
FF_RETURN(val);
20+
}
21+
22+
static NAN_SETTER(locationsSet) {
23+
std::vector<cv::Point> locations;
24+
if (!ObjectArrayConverter<Point2, cv::Point2d, cv::Point>::unwrap(&locations, value)) {
25+
return Nan::ThrowError("expected locations to be an Array of type Point2");
26+
}
27+
}
28+
29+
static NAN_GETTER(confidencesGet) {
30+
FF_RETURN(DoubleArrayConverter::wrap(Converter::unwrap(info.This()).confidences));
31+
}
32+
33+
static NAN_SETTER(confidencesSet) {
34+
std::vector<double> confidences;
35+
if (!DoubleArrayConverter::unwrap(&confidences, value)) {
36+
return Nan::ThrowError("expected confidences to be an Array of type Number");
37+
}
38+
}
39+
40+
static Nan::Persistent<v8::FunctionTemplate> constructor;
41+
42+
cv::DetectionROI* getNativeObjectPtr() { return &detectionROI; }
43+
cv::DetectionROI getNativeObject() { return detectionROI; }
44+
45+
typedef InstanceConverter<DetectionROI, cv::DetectionROI> Converter;
46+
47+
static const char* getClassName() {
48+
return "DetectionROI";
49+
}
50+
};
51+
52+
#endif

0 commit comments

Comments
 (0)