Tag Archives: xxx/labelKeypoint/utils/qt.py:81: RuntimeWarning: invalid value encountered in double_scalars

xxx/labelKeypoint/utils/qt.py:81: RuntimeWarning: invalid value encountered in double_scalars

This article gives you a comprehensive understanding of Java object serialization and deserialization>>>

Original code:

return np.linalg.norm(np.cross(p2 - p1, p1 - p3))/np.linalg.norm(p2 - p1)

Error reported:

xxx/labelKeypoint/utils/qt.py:81: RuntimeWarning: invalid value encountered in double_scalars

The problem of denominator 0 is ignored in stackoverflow. The modification code is as follows:

    if np.linalg.norm(p2 - p1) == 0:
        return np.linalg.norm(np.cross(p2 - p1, p1 - p3))
    else:
        return np.linalg.norm(np.cross(p2 - p1, p1 - p3))/np.linalg.norm(p2 - p1)

Solve the problem of error reporting