Skip to content

Commit 8d82ed9

Browse files
author
Florin
committed
calcHist works!
1 parent ebada99 commit 8d82ed9

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

scripts/calcHist.coffee

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,19 @@ histImg = tmp.zeros sbins * scale, hbins * 10, cv.CV_8UC3
5252
for h in [0..hbins - 1]
5353
for s in [0..sbins - 1]
5454
binVal = hist.at h, s
55-
5655
intensity = Math.round(binVal * 255 / minMax.maxVal)
57-
cv.rectangle histImg, {x: h*scale, y: s*scale}, {x: (h+1)*scale - 1, y: (s+1)*scale - 1}, [255, 0, 0, 0], -1
56+
cv.rectangle histImg, {x: h*scale, y: s*scale}, {x: (h+1)*scale - 1, y: (s+1)*scale - 1}, [intensity, intensity, intensity, intensity], -1
5857

5958
cv.namedWindow "H-S Histogram", 1
6059
cv.imshow "H-S Histogram", histImg
6160

62-
keypress process.stdin
63-
process.stdin.on 'keypress', (char, key) ->
64-
if key.name == 'escape'
65-
console.log 'Stopping.'
66-
process.exit 0
61+
doATick = ->
62+
cv.doTick();
63+
process.nextTick doATick
6764

68-
process.stdin.setRawMode true
69-
process.stdin.resume()
70-
console.log 'Press ESC to stop.'
65+
doATick()
66+
67+
setTimeout ->
68+
process.exit -1
69+
, 1000
7170

src/opencv_manual.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace opencvjs {
1313
METHOD_BEGIN(0);
1414

1515
#ifdef _WIN32
16+
//Todo: Very raw, probably better to process all messages in the queue and then return
1617
MSG msg;
1718
if (GetMessage(&msg, NULL, 0, 0)){
1819
TranslateMessage(&msg);
@@ -29,7 +30,7 @@ namespace opencvjs {
2930
//Experimental - not tested
3031
cv::Mat* _this = bea::Convert<cv::Mat*>::FromJS(args.This(), 0);
3132
int i = bea::Convert<int>::FromJS(args[0], 0);
32-
int j = bea::Optional<int>::FromJS(args, 0, 0);
33+
int j = bea::Optional<int>::FromJS(args, 1, 0);
3334
v8::Handle<v8::Value> retVal;
3435
switch(_this->depth()){
3536
case CV_8U:

src/opencvjs.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3085,7 +3085,7 @@ namespace opencvjs {
30853085
}
30863086

30873087
v8::Handle<v8::Value> JOpenCV::minMaxLoc(const v8::Arguments& args) {
3088-
METHOD_BEGIN(1);
3088+
METHOD_BEGIN(1);
30893089
//minMaxLocRet minMaxLoc(const Mat& a)
30903090
cv::Mat* a = bea::Convert<cv::Mat*>::FromJS(args[0], 0);
30913091
minMaxLocRet fnRetVal;
@@ -3199,6 +3199,7 @@ namespace opencvjs {
31993199
obj->exposeMethod("calcBackProject", calcBackProject);
32003200
obj->exposeMethod("minMaxLoc", minMaxLoc);
32013201
obj->exposeMethod("cvSmooth", cvSmooth);
3202+
obj->exposeMethod("doTick", doTick);
32023203
obj->exposeMethod("discardMats", discardMats);
32033204
obj->exposeMethod("fillPoly", fillPoly);
32043205
obj->exposeMethod("getTextSize", getTextSize);
@@ -3576,6 +3577,7 @@ namespace opencvjs {
35763577
BEA_DEFINE_CONSTANT(target, FONT_HERSHEY_SCRIPT_SIMPLEX);
35773578
BEA_DEFINE_CONSTANT(target, FONT_HERSHEY_SCRIPT_COMPLEX);
35783579
BEA_DEFINE_CONSTANT(target, FONT_ITALIC);
3580+
BEA_DEFINE_CONSTANT(target, CV_FILLED);
35793581
}
35803582

35813583
}

src/opencvjs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ namespace opencvjs {
244244
static v8::Handle<v8::Value> calcBackProject(const v8::Arguments& args);
245245
static v8::Handle<v8::Value> minMaxLoc(const v8::Arguments& args);
246246
static v8::Handle<v8::Value> cvSmooth(const v8::Arguments& args);
247+
static v8::Handle<v8::Value> doTick(const v8::Arguments& args);
247248
static v8::Handle<v8::Value> discardMats(const v8::Arguments& args);
248249
static v8::Handle<v8::Value> fillPoly(const v8::Arguments& args);
249250
static v8::Handle<v8::Value> getTextSize(const v8::Arguments& args);

0 commit comments

Comments
 (0)