Vmtkcenterlines -seedselector pointlist problem
近期想找出模型的中心線
Vmtkcenterlines -seedselector pointlist problem
近期想找出模型的中心線
發現有個小套件可以協助完成
這個東西就是VMTK
只是功能實作完成後
卻發現一直報錯 出現下述的錯誤
TypeError: ‘float’ object cannot be interpreted as an integer
原來是這個套件本身在Python的版本上,邏輯上會有所不同,在 Python 2 中,整數除以整數會產生一個整數,而在 Python 3 中,兩個數位之間的結果會產生一個浮點數,而與操作數的類型無關,為此,需要整數除法,無論操作數的類型如何,它會傳回一個整數
而在這個vmtkCenterlines.py下,原本的為
for i in range(len(self.SourcePoints)/3):
把它改成這樣即可
for i in range(len(self.SourcePoints)//3):
這個檔案路徑預設在
C:\ProgramData\VMTK\lib\site-packages\vmtk\vmtkcenterlines.py
但是我本身是用Anaconda建置虛擬環境,故在這個地方
C:\Users\<Username>\AppData\Local\anaconda3\pkgs\vmtk-1.4.0-py36_vc14hc29f2d6_1\Lib\site-packages\vmtk\vmtkcenterlines.py

記得要改這兩行啊~
메타데이터
- post_id
- e0be1ecc62e8
- slug
- vmtkcenterlines-seedselector-pointlist-problem-e0be1ecc62e8
- url
- https://medium.com/@kerryli_3669/vmtkcenterlines-seedselector-pointlist-problem-e0be1ecc62e8
- canonical_url
- https://medium.com/@kerryli_3669/vmtkcenterlines-seedselector-pointlist-problem-e0be1ecc62e8
- author_url
- https://medium.com/@kerryli_3669
- status
- ok
- fetched_at
- 2026-06-14 11:28:49