Skip to content

Commit 86c6fc0

Browse files
Merge pull request #692 from Garfonso/master
add waitKeyEx method
2 parents f21e86e + e4cff82 commit 86c6fc0

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

cc/io/io.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ NAN_MODULE_INIT(Io::Init) {
1616
Nan::SetMethod(target, "imshowWait", ImshowWait);
1717
Nan::SetMethod(target, "imwrite", Imwrite);
1818
Nan::SetMethod(target, "waitKey", WaitKey);
19+
#if CV_VERSION_GREATER_EQUAL(3, 2, 0)
20+
Nan::SetMethod(target, "waitKeyEx", WaitKeyEx);
21+
#endif
1922
Nan::SetMethod(target, "imencode", Imencode);
2023
Nan::SetMethod(target, "imdecode", Imdecode);
2124
Nan::SetMethod(target, "moveWindow", MoveWindow);
@@ -105,6 +108,18 @@ NAN_METHOD(Io::WaitKey) {
105108
info.GetReturnValue().Set(Nan::New(key));
106109
}
107110

111+
#if CV_VERSION_GREATER_EQUAL(3, 2, 0)
112+
NAN_METHOD(Io::WaitKeyEx) {
113+
int key;
114+
if (info[0]->IsNumber()) {
115+
key = cv::waitKeyEx(info[0]->ToNumber(Nan::GetCurrentContext()).ToLocalChecked()->Value());
116+
} else{
117+
key = cv::waitKeyEx();
118+
}
119+
info.GetReturnValue().Set(Nan::New(key));
120+
}
121+
#endif
122+
108123
NAN_METHOD(Io::MoveWindow) {
109124
FF::TryCatch tryCatch("Io::MoveWindow");
110125
std::string winName;

cc/io/io.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class Io {
1616
static NAN_METHOD(Imshow);
1717
static NAN_METHOD(ImshowWait);
1818
static NAN_METHOD(WaitKey);
19+
#if CV_VERSION_GREATER_EQUAL(3, 2, 0)
20+
static NAN_METHOD(WaitKeyEx);
21+
#endif
1922
static NAN_METHOD(MoveWindow);
2023
static NAN_METHOD(DestroyWindow);
2124
static NAN_METHOD(DestroyAllWindows);
@@ -29,4 +32,4 @@ class Io {
2932
static NAN_METHOD(ImdecodeAsync);
3033
};
3134

32-
#endif
35+
#endif

lib/typings/cv.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ export function transformAsync(mat: Mat, m: Mat): Promise<Mat>;
208208
export function undistortPoints(srcPoints: Point2[], cameraMatrix: Mat, distCoeffs: Mat): Point2[];
209209
export function undistortPointsAsync(srcPoints: Point2[], cameraMatrix: Mat, distCoeffs: Mat): Promise<Point2[]>;
210210
export function waitKey(delay?: number): number;
211+
export function waitKeyEx(delay?: number): number;
211212

212213
export type DrawParams = {
213214
thickness?: number;

0 commit comments

Comments
 (0)