Skip to content

Error in SegmentPlugin.py due to changes in Python 3 #3

@marcellillyes

Description

@marcellillyes

Hi Eric,

Thank you for the great software, I am very excited to be using it for my PhD project!

I have noticed an issue in the latest release (v0.5.0) when trying to generate a mesh object, which I believe is due to the change in how Python 3 handles the zip() function and division / operator.

The first problem I ran into was in Line 1429 of the SegmentPlugin.py script:

contours=zip(*segobj.enumContours())[0]

Here I received the following error:
TypeError: 'zip' object is not subscriptable

After reading up about it, it turns out that in Python 2, the zip() function returns a list, while Python 3 returns an iterable object, as described in this thread.

After implementing the solutions described here, the next error occurred in Line 460:

invertring=[midring[(clen/2+i)%clen] for i in range(clen)]

returning the error:
TypeError: list indices must be integers or slices, not float

Again, there has been a change in how Python 3 handles the / operator as discussed here.

I changed the single, true division operator / which returns a float, to a floor division // ,which returns an integer.

After doing this, I was able to generate the mesh object from the segmentation contours.

EDIT: I see now that you have implemented this as well in the experimental branch, but thought logging this would be useful for anyone trying to use this feature.

Cheers and all the best!

Marcell

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions