Closed Afrokillaa closed 2 years ago
Hi,
Sorry, I haven't found out the cause, but it might be something with the matrix sizes and the solvers. Try input images with even-numbered width and height. ( so 100x50 is probably good, 99x51 is problematic )
I'm sorry, but I can't fix this.
You can try to get help from David Dowd, he made the original image morpher. https://github.com/ddowd97/Morphing
If you can use Node.js instead of Python for your project, take a look at this: https://github.com/jankovicsandras/autoimagemorphjs
Here are some comments from the code with more details:
# - LinAlgError ? Image dimensions should be even numbers?
# related: https://stackoverflow.com/questions/44305456/why-am-i-getting-linalgerror-singular-matrix-from-grangercausalitytests
# File "batchautomorph.py", line 151, in interpolatePoints
# righth = np.linalg.solve(tempRightMatrix, targetVertices)
# File "<__array_function__ internals>", line 5, in solve
# File "numpy\linalg\linalg.py",
# line 403, in solve
# r = gufunc(a, b, signature=signature, extobj=extobj)
# File "numpy\linalg\linalg.py",
# line 97, in _raise_linalgerror_singular
# raise LinAlgError("Singular matrix")
# numpy.linalg.LinAlgError: Singular matrix
Not an actual solution, but a temporary workaround is to add noise:
try:
lefth = np.linalg.solve(tempLeftMatrix, targetVertices)
except:
lefth = np.linalg.solve(tempLeftMatrix + 0.00001*np.random.rand(6, 6), targetVertices)
try:
righth = np.linalg.solve(tempRightMatrix, targetVertices)
except:
righth = np.linalg.solve(tempRightMatrix + 0.00001*np.random.rand(6, 6), targetVertices)
Hi there, wanted to use this library to morph my images, but kept getting the same linalgError as you mentioned. It always happens after frame29 when it goes over to the next image. Any idea why this happens and how to fix it?