TechStark / opencv-js

OpenCV JavaScript version for node.js or browser
Apache License 2.0
353 stars 31 forks source link

Error with calcOpticalFlowPyrLK #59

Open namnetko opened 2 months ago

namnetko commented 2 months ago

I'm having trouble with calcOpticalFlowPyrLK. Sometimes it returns an error, sometimes it doesn't. I've double-checked the input data, and it seems to be correct.

Please help me, thank you.

cv.calcOpticalFlowPyrLK(
    preGray,
    curGray,
    p0,
    p1,
    st,
    err,
    winSize,
    maxLevel,
    criteria,
  );

  cv.exceptionFromPtr(err);

error image

ttt43ttt commented 2 months ago

try this

  if (typeof err === "number") {
      throw cv.exceptionFromPtr(err);
  }
namnetko commented 2 months ago

try this

  if (typeof err === "number") {
      throw cv.exceptionFromPtr(err);
  }

it will return an error image

ttt43ttt commented 2 months ago

are the objects (passed as cv.calcOpticalFlowPyrLK parameters) reused between different function calls?

namnetko commented 2 months ago

are the objects (passed as cv.calcOpticalFlowPyrLK parameters) reused between different function calls?

i deleted them and not reused between different function calls

preImg.delete();
  preGray.delete();
  curImg.delete();
  curGray.delete();
  p0.delete();
  p1.delete();
  err.delete();
  mask.delete();
  st.delete()