node-opencv icon indicating copy to clipboard operation
node-opencv copied to clipboard

FindContours causes weird errors

Open oskardahlberg opened this issue 11 years ago • 4 comments

The example works fine but sometimes when I try to call findContours, especially when its many times in a row, my whole application breaks in the weirdest way. The block which in i call it is the last one executed and no error is given.

var c = mat.findContours(); console.log(c.size()) // shows a size callback(null, c) // args evaluated, but not call

I broke it out so now i do every call in its own process and it works fine (except for being very clunky). First i made an asynchrous version but to no luck. The only other thing that i had any luck with was wrapping it in a setTimeout so that i had ~1000 ms between every call.

oskardahlberg avatar Sep 21 '14 19:09 oskardahlberg

Did your PR fix this?

peterbraden avatar Sep 24 '14 18:09 peterbraden

Not really, it just allows me to work around it (running findContours in a fork, serializing, passing to parent, deserializing, ~200 ms at 300x300). I suspect it is a V8 problem. Like it cant balance the load, the thread gets stuck or you know, whatever. My knowledge of V8s inner workings is limited and it is a really strange problem since I can still execute some code. It might be time related but to me it looks like it wont execute beyond the block it was called in.

oskardahlberg avatar Sep 24 '14 18:09 oskardahlberg

Yeah, sounds nasty, my knowledge of v8 internals is very limited too. Glad you found a workaround. I'll leave this open in case someone finds a solution.

peterbraden avatar Sep 24 '14 18:09 peterbraden

I think I'm running into this. On images with a large amount of contours (1500 was enough for me) I can hit it fairly consistently which will cause random silent failures in my program. It seems to be happening when garbage collection happens (which is why it seems random), which I can reproduce with --expose-gc and calling global.gc(). No stack trace produced by the segfault-handler package.

MichaelMcCarrick avatar Oct 09 '17 18:10 MichaelMcCarrick