forked from justadudewhohacks/opencv4nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphotoBindings.h
More file actions
108 lines (89 loc) · 2.84 KB
/
Copy pathphotoBindings.h
File metadata and controls
108 lines (89 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "CvBinding.h"
#include "photo.h"
#ifndef __FF_PHOTOBINDINGS_H_
#define __FF_PHOTOBINDINGS_H_
namespace PhotoBindings {
struct FastNlMeansDenoisingColoredWorker : public CatchCvExceptionWorker {
public:
cv::Mat src;
float h = 3;
float hColor = 3;
int templateWindowSize = 7;
int searchWindowSize = 21;
cv::Mat returnValue;
std::string executeCatchCvExceptionWorker() {
cv::fastNlMeansDenoisingColored(src, returnValue, h, hColor, templateWindowSize, searchWindowSize);
return "";
}
v8::Local<v8::Value> getReturnValue() {
return Mat::Converter::wrap(returnValue);
}
bool unwrapRequiredArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return (
Mat::Converter::arg(0, &src, info)
);
}
bool unwrapOptionalArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return (
FF::FloatConverter::optArg(1, &h, info) ||
FF::FloatConverter::optArg(2, &hColor, info) ||
FF::IntConverter::optArg(3, &templateWindowSize, info) ||
FF::IntConverter::optArg(4, &searchWindowSize, info)
);
}
bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF::isArgObject(info, 1);
}
bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
v8::Local<v8::Object> opts = info[1]->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
return (
FF::FloatConverter::optProp(&h, "h", opts) ||
FF::FloatConverter::optProp(&hColor, "hColor", opts) ||
FF::IntConverter::optProp(&templateWindowSize, "templateWindowSize", opts) ||
FF::IntConverter::optProp(&searchWindowSize, "searchWindowSize", opts)
);
}
};
struct InpaintWorker : public CatchCvExceptionWorker {
public:
// required function arguments
cv::Mat src;
cv::Mat inpaintMask;
double inpaintRadius;
int flags;
// function return value
cv::Mat dst;
bool unwrapRequiredArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return (
Mat::Converter::arg(0, &src, info) ||
Mat::Converter::arg(1, &inpaintMask, info) ||
FF::DoubleConverter::arg(2, &inpaintRadius, info) ||
FF::IntConverter::arg(3, &flags, info)
);
}
std::string executeCatchCvExceptionWorker() {
cv::inpaint(
src, inpaintMask, dst,
inpaintRadius, flags
);
return "";
}
v8::Local<v8::Value> getReturnValue() {
return Mat::Converter::wrap(dst);
}
};
class SeamlessClone : public CvClassMethodBinding<Mat> {
public:
void createBinding(std::shared_ptr<FF::Value<cv::Mat>> self) {
auto dst = req<Mat::Converter>();
auto mask = req<Mat::Converter>();
auto p = req<Point2::Converter>();
auto flags = req<FF::IntConverter>();
auto blend = ret<Mat::Converter>("blend");
executeBinding = [=]() {
cv::seamlessClone(self->ref(), dst->ref(), mask->ref(), p->ref(), blend->ref(), flags->ref());
};
};
};
}
#endif