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

AttributeError: 'tuple' object has no attribute 'sort' #801

Open
dacrypt opened this issue Feb 20, 2023 · 0 comments
Open

AttributeError: 'tuple' object has no attribute 'sort' #801

dacrypt opened this issue Feb 20, 2023 · 0 comments

Comments

@dacrypt
Copy link

dacrypt commented Feb 20, 2023

ImageAlignment-FeatureBased python3 align.py 
Reading reference image :  form.jpg
Reading image to align :  scanned-form.jpg
Aligning images ...
Traceback (most recent call last):
  File "align.py", line 69, in <module>
    imReg, h = alignImages(im, imReference)
  File "align.py", line 26, in alignImages
    matches.sort(key=lambda x: x.distance, reverse=False)
AttributeError: 'tuple' object has no attribute 'sort'

It is not clear what the input matches is, and how it is being passed to the alignImages() function. However, the error message suggests that matches is a tuple, and tuples do not have a sort() method.

The error message suggests that you are trying to call the sort method on a tuple object, which is not possible because tuples are immutable and do not have a sort method.

It seems that in your code, the variable matches is a tuple, and you are trying to sort it using a lambda function. To fix this error, you can convert the matches tuple to a list using the list() function, like this:

matches = list(matches)
matches.sort(key=lambda x: x.distance, reverse=False)
Alternatively, you can modify the function that returns the matches tuple to return a list instead.
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

1 participant