Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cv.split #1

Open
morgangiraud opened this issue Oct 7, 2012 · 7 comments
Open

cv.split #1

morgangiraud opened this issue Oct 7, 2012 · 7 comments

Comments

@morgangiraud
Copy link

Hello,
i've been trying to follow that opencv tutorials : http://docs.opencv.org/doc/tutorials/imgproc/histograms/histogram_calculation/histogram_calculation.html
which should give me some nice histograms plot but, by just following the exact same steps, i couldn't achieve it.

I'm not exactly sure how the binding work for the calcHist function but at least it seems that cv.split(Mat, []) is not filling the array.

Can you have a look on this ?

@codeboost
Copy link
Owner

Did you try this:
var a = []
cv.split(Mat, a);
?

@morgangiraud
Copy link
Author

here is the code i used : (coffee)

###########################
cv = require 'opencv-node'

src = cv.imread '../test.jpg', 1
console.log src.channels # output 3

plane = []
cv.split src, plane
console.log plane # output []

setTimeout () ->
console.log plane # output []
, 3000
###########################

Also, i can't use "console.log Mat", it always crash. D'ont know if it is linked.

@codeboost
Copy link
Owner

Yes, that was a bug in opencv-node. Actually, I've somehow used an older, unfinished version of the code to publish opencv-node so it had more issues.

Now I've updated opencv-node to version 0.2.3, use

npm update -g opencv-node

to update.

If you look in the scripts directory, there's a effects.coffee which does some effects on running video.
Let me know if it works.

@codeboost
Copy link
Owner

Also, console.log Mat works without crashing now, but doing this would output a looong array of bytes which is not very interesting.
For debug purposes, I suggest you write your own logMat() function, which would look something like this:

logMat = (mat) -> console.log "#{mat.wdith}x#{mat.height}x#{mat.type}"

@morgangiraud
Copy link
Author

Great, everything works for console.log and cv.split. Thanks for the fix !

Now trying to get something out of cv.calcHist function.

Here is my code:
###################################
cv = require 'opencv-node'

src = cv.imread '../test.jpg', 1
histSize = 256
range = {start:0, end:256}
uniform = true
accumulate = true
b_hist = new cv.Mat
console.log b_hist.rows #output 0
mask = new cv.Mat
planes = []

planes = cv.split src
console.log planes[0].rows #output 471 !

cv.calcHist planes[0], 1, 0, mask, b_hist, 1, histSize, range, uniform, accumulate
console.log b_hist.rows #output 0
######################################

The result should be in b_hist but just like with split before, the matrix doesn't change.
Probably the same problem as the split function had.

Last question, is it possible to keep the original definition of the function split ? (i mean cv.split mat, array instead of array cv.split mat ?)

@codeboost
Copy link
Owner

Ahh.. you're hitting where it hurts. Seems like calcHist, calcBackProject and 3 other functions are not ported. I did this thing like 2 years ago and I've forgotten about it. But let me see what I can do. Maybe someone else also needs them ;).

Re: split -> I'll try.

@morgangiraud
Copy link
Author

Thanks a lot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants