File tree Expand file tree Collapse file tree 2 files changed +26
-10
lines changed
Expand file tree Collapse file tree 2 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,8 @@ for h in [0..hbins - 1]
5151cv .namedWindow " H-S Histogram" , 1
5252cv .imshow " H-S Histogram" , histImg
5353
54- doATick = ->
55- cv .doTick ();
56- process .nextTick doATick
5754
58- doATick ()
59-
60- setTimeout ->
61- process .exit - 1
62- , 5000
55+ cv .closeOnEsc ()
6356
57+ # Important on Windows, if you have windows which display stuff.
58+ cv .runMessageLoop ()
Original file line number Diff line number Diff line change 11# This should be done in the C++ addon ?
2- opencvjs = require ' ../build/Release /addon.node'
2+ opencvjs = require ' ../build/Debug /addon.node'
33
44_ = require ' underscore'
55cv = opencvjs .OpenCV
@@ -8,4 +8,25 @@ Mat = opencvjs.Mat
88_ .extend module .exports , opencvjs
99delete module .exports .OpenCV
1010
11- _ .extend module .exports , opencvjs .OpenCV
11+ _ .extend module .exports , opencvjs .OpenCV
12+
13+ # Run the message loop on windows. This is required, otherwise the window painting will not work in Windows.
14+ module .exports .runMessageLoop = ->
15+ # I doubt this is the most efficient way to do it, but it seems to do the job for the moment
16+ doTick = ->
17+ cv .doTick (); # calls GetMessage(), TranslateMessage() and DispatchMessage()
18+ process .nextTick doTick
19+
20+ if require (' os' ).type ().toLowerCase ().indexOf (" windows" ) is 0
21+ doTick ()
22+
23+
24+ # This is used
25+ module .exports .closeOnEsc = ->
26+ require (' keypress' ) process .stdin
27+ process .stdin .on ' keypress' , (char , key ) ->
28+ if key .name == ' escape'
29+ console .log ' Stopping.'
30+ process .exit 0
31+ process .stdin .setRawMode true
32+ process .stdin .resume ()
You can’t perform that action at this time.
0 commit comments