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

RuntimeError: function signature mismatch #3

Open
stephanschulz opened this issue Dec 7, 2020 · 2 comments
Open

RuntimeError: function signature mismatch #3

stephanschulz opened this issue Dec 7, 2020 · 2 comments

Comments

@stephanschulz
Copy link

stephanschulz commented Dec 7, 2020

Again i want to thank you for making your code available.
I am posting my problems not as a complained but to hopefully help towards a stable version.

I am trying to make this rPPG heart beat detection working with your p5 opencv implementation.
https://github.com/prouast/heartbeat-js
The original heartbeat-js works and does NOT crash after running for a few minutes.
But when i use p5.js-cv i get the bellow crash message after a couple of minutes.

  • i am defining a polygon area in the camera image
  • then create a mask mat
  • get the average color
  • then it is being send through a bunch of PPG functions to find the person heart beat.

Here is a minimal example taking a fixed region of interest polygon and sends it to the PPG functions.
https://www.dropbox.com/s/xjk3je8fpxx0nmy/hand-rppg.zip?dl=0

The crash happens in 'cv.split(a_signal, s);' inside 'function detrend(a_signal, lambda)'

Maybe you have seen something similar before.
Thanks a bunch.

014602b2:0x8aec7 Uncaught RuntimeError: function signature mismatch
    at <anonymous>:wasm-function[1778]:0x8aec7
    at <anonymous>:wasm-function[2040]:0xb357a
    at <anonymous>:wasm-function[2455]:0xdcc39
    at <anonymous>:wasm-function[640]:0x1b4f7
    at <anonymous>:wasm-function[875]:0x27ae0
    at dynCall_viii (<anonymous>:wasm-function[9632]:0x4840ad)
    at Module.dynCall_viii (http://127.0.0.1:56289/libs/opencv.js:9107:46)
    at dynCall_viii_918 (eval at makeDynCaller (http://127.0.0.1:56289/libs/opencv.js:1:1), <anonymous>:4:12)
    at Object.split (eval at new_ (http://127.0.0.1:56289/libs/opencv.js:6901:29), <anonymous>:9:1)
    at detrend (http://127.0.0.1:56289/heartbeat.js:370:8)

Screen Shot 2020-12-07 at 3 57 04 PM

@stephanschulz
Copy link
Author

i tried a few things, all of which did not help but they caused the console to report the crash at different lines. this kind of suggests a memory leak.

  • used the online opencv.js via <script language="javascript" type="text/javascript" src="https://docs.opencv.org/master/opencv.js"></script>
  • commented out // detrend(a_signal, fps);
  • commented out all // p5.cv.drawMat

But then i noticed how very often .delete() is used by the original code.
so i looked around for cv.Mats that i do not delete and constantly redefine.
cleaning that up seems to have solved it.
for example mask = cv.Mat.zeros(videoHeight, videoWidth, cv.CV_8UC1); was called on every frame.

@orgicus
Copy link
Owner

orgicus commented Dec 8, 2020

Hi @stephanschulz

Thank you for contributing such well documented issues.
Indeed I believe this point to memory leak and manually calling delete() on Mat instances when done is the way forward.
(There may be other leaks lurking too, but Mat by far will munch on most memory unless managed with delete())

I was pondering on manually cleaning up (for example after drawMat),
but that means I would end up making too many decisions on behalf of the user just to hide this need.
It would also be dificult figuring out when to delete a Mat and especially when not to delete a Mat on behalf of the user behind the scenes.

In terms of API design it is a bit of a tricky one.
I may modify the examples to use delete() and emphasise it's importance.

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