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

error: (-28:Unknown error code -28) The input arrays should have at least 4 corresponding point sets to calculate Homography in function 'findHomography' #299

Closed
utility-aagrawal opened this issue Feb 16, 2024 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@utility-aagrawal
Copy link

Hi,

Would you know why I am getting this error? I see in the code here that you check for minimum 4 pairs of points before findHomography but still getting the error:

File "/home/aagrawal/face_detection/real_videos/open_source_face_detection.py", line 232, in main
coord_transformation = motion_estimator.update(frame) #, mask)
File "/home/aagrawal/face_detection/face_venv/lib/python3.10/site-packages/norfair/camera_motion.py", line 396, in update
update_prvs, coord_transformations = self.transformations_getter(
File "/home/aagrawal/face_detection/face_venv/lib/python3.10/site-packages/norfair/camera_motion.py", line 216, in call
homography_matrix, points_used = cv2.findHomography(
cv2.error: OpenCV(4.9.0) /io/opencv/modules/calib3d/src/fundam.cpp:385: error: (-28:Unknown error code -28) The input arrays should have at least 4 corresponding point sets to calculate Homography in function 'findHomography'

@utility-aagrawal utility-aagrawal added the help wanted Extra attention is needed label Feb 16, 2024
@aguscas
Copy link
Collaborator

aguscas commented Feb 16, 2024

The reason might be because that bug was fixed not long ago, but the fix is still not part of the latest release. Maybe try installing Norfair from the master branch:

pip install git+https://github.com/tryolabs/norfair.git@master#egg=norfair

Tell me if this fixes the issue.

@utility-aagrawal
Copy link
Author

Thanks a lot, @aguscas !

Installing from master seemed to work. I do get the following warning though:

image

Does this mean that transformation will be skipped for the frame in case of this issue but everything else will work fine?

@aguscas
Copy link
Collaborator

aguscas commented Feb 16, 2024

Everything should work fine. That means that the coord_transformation will not be updated in that frame (the MotionEstimator will return the latest transformation it could estimate). As long as that doesn't happen often it shouldn't be a problem with the coord_transformation, since typically a single frame shouldn't affect that much at the coordinate_transformation.

@utility-aagrawal
Copy link
Author

Makes sense! Closing this issue. Again, thanks so much for your help!

@aguscas
Copy link
Collaborator

aguscas commented Feb 16, 2024

If you want to avoid having that warning (so that you always estimate the transformation), you can also try setting the max_points argument of the MotionEstimator to a higher value (so that it tries sampling more points), or the min_distance argument to a smaller value (so that we allow to sample points that are closer to each other).

@utility-aagrawal
Copy link
Author

For now, it's not an issue for me but I'll experiment with those two parameters. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants