From e88d2d6b8a83a268f2a899ff5699648eec697855 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Mon, 11 Mar 2013 15:41:36 -0700 Subject: [PATCH] Blocking waitKey for development --- smoke/smoketest.js | 6 +++--- src/HighGUI.cc | 13 +++++++++++++ src/HighGUI.h | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/smoke/smoketest.js b/smoke/smoketest.js index 0be6aff..d6566a0 100755 --- a/smoke/smoketest.js +++ b/smoke/smoketest.js @@ -3,9 +3,9 @@ var cv = require('../lib/opencv') var win = new cv.NamedWindow("foo"); cv.readImage('./examples/stuff.png', function(e, im){ win.show(im); - setTimeout(function(){ - win.destroy(); - }, 1000) + console.log(win.blockingWaitKey(0), "!!") + win.destroy(); + }) diff --git a/src/HighGUI.cc b/src/HighGUI.cc index cbd1d3e..c793123 100644 --- a/src/HighGUI.cc +++ b/src/HighGUI.cc @@ -19,6 +19,7 @@ NamedWindow::Init(Handle target) { NODE_SET_PROTOTYPE_METHOD(constructor, "show", Show); NODE_SET_PROTOTYPE_METHOD(constructor, "destroy", Destroy); + NODE_SET_PROTOTYPE_METHOD(constructor, "blockingWaitKey", BlockingWaitKey); target->Set(String::NewSymbol("NamedWindow"), constructor->GetFunction()); }; @@ -65,3 +66,15 @@ NamedWindow::Destroy(const v8::Arguments& args){ cv::destroyWindow(self->winname); return scope.Close(args.Holder()); } + + +Handle +NamedWindow::BlockingWaitKey(const v8::Arguments& args){ + SETUP_FUNCTION(NamedWindow) + int time = 0; + if (args.Length() > 0){ + time = args[1]->IntegerValue(); + } + int res = cv::waitKey(time); + return scope.Close(Number::New(res)); +} diff --git a/src/HighGUI.h b/src/HighGUI.h index fa26bd3..61b5033 100644 --- a/src/HighGUI.h +++ b/src/HighGUI.h @@ -15,5 +15,6 @@ class NamedWindow: public node::ObjectWrap { JSFUNC(Show); JSFUNC(Destroy); + JSFUNC(BlockingWaitKey); };