forked from udarrr/opencv4nodejs-prebuilt-install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVideoWriterBindings.h
134 lines (106 loc) · 2.86 KB
/
VideoWriterBindings.h
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "VideoWriter.h"
#ifndef __FF_VIDEOWRITERBINDINGS_H_
#define __FF_VIDEOWRITERBINDINGS_H_
namespace VideoWriterBindings {
struct NewWorker : CatchCvExceptionWorker {
public:
std::string fileName;
int fourccCode;
double fps;
cv::Size2d frameSize;
bool isColor = true;
bool unwrapRequiredArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return (
FF::StringConverter::arg(0, &fileName, info) ||
FF::IntConverter::arg(1, &fourccCode, info) ||
FF::DoubleConverter::arg(2, &fps, info) ||
Size::Converter::arg(3, &frameSize, info)
);
}
bool unwrapOptionalArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF::BoolConverter::optArg(4, &isColor, info);
}
std::string executeCatchCvExceptionWorker() {
return "";
}
};
struct GetWorker : public CatchCvExceptionWorker {
public:
cv::VideoWriter self;
GetWorker(cv::VideoWriter self) {
this->self = self;
}
int prop;
double val;
bool unwrapRequiredArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return (
FF::IntConverter::arg(0, &prop, info)
);
}
std::string executeCatchCvExceptionWorker() {
val = self.get(prop);
return "";
}
v8::Local<v8::Value> getReturnValue() {
return FF::DoubleConverter::wrap(val);
}
};
struct SetWorker : public CatchCvExceptionWorker {
public:
cv::VideoWriter self;
SetWorker(cv::VideoWriter self) {
this->self = self;
}
// required fn args
int prop;
double value;
bool ret;
std::string executeCatchCvExceptionWorker() {
ret = this->self.set(prop, value);
return "";
}
bool unwrapRequiredArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return (
FF::IntConverter::arg(0, &prop, info) ||
FF::DoubleConverter::arg(1, &value, info)
);
}
v8::Local<v8::Value> getReturnValue() {
return Nan::New(ret);
}
};
struct FourccWorker : CatchCvExceptionWorker {
public:
std::string fourcc;
int code;
std::string executeCatchCvExceptionWorker() {
code = cv::VideoWriter::fourcc(fourcc.at(0), fourcc.at(1), fourcc.at(2), fourcc.at(3));
return "";
}
v8::Local<v8::Value> getReturnValue() {
return FF::IntConverter::wrap(code);
}
bool unwrapRequiredArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF::StringConverter::arg(0, &fourcc, info);
}
};
struct WriteWorker : CatchCvExceptionWorker {
public:
cv::VideoWriter writer;
WriteWorker(cv::VideoWriter writer) {
this->writer = writer;
}
cv::Mat frame;
std::string executeCatchCvExceptionWorker() {
writer.write(frame);
return "";
}
v8::Local<v8::Value> getReturnValue() {
return FF::BoolConverter::wrap(true);
}
bool unwrapRequiredArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return Mat::Converter::arg(0, &frame, info);
}
};
}
#endif