错误 python 说试图创建结构列表的语法无效
error with python saying invalid syntax trying to create list of struct
在相机切除的关键帧中,我试图创建一个出现在帧中的点列表,然后尝试创建一个包含后续帧中相应点的列表,以继续跟踪视频中的点求出它们之间的K矩阵。
我有以下 class 来存储每个帧的点并为每个帧创建一个点列表并沿着所有帧跟踪它们。
class PointsCorrespondence:
"""
Stores the point of a specific index.
"""
# A point is represented as (coordinate X, coordinate Y)
Point = (float, float)
# A point with corresponding same point is represented as (coordinates, index of the corresponding point or -1 if there is no corresponding point).
PointWithCorrespondence = (Point, int)
# Contains the points represented as one list of notable points for each frame.
_pointsPerFrame : [[PointWithCorrespondence]]
def __init__(self, pointsPerFrame : [[PointWithCorrespondence]]):
self._pointsPerFrame = pointsPerFrame
当我尝试 运行 此代码将点存储在其中时,出现以下错误:
Traceback (most recent call last): File "main.py", line 4, in
import pointTracking File "/home/k/Desktop/CV/project/insertc/project12345/pointTracking.py",
line 17
_pointsPerFrame : [[PointWithCorrespondence]]
^ SyntaxError: invalid syntax
实际上我不知道为什么会出现该错误,我尝试了很多方法来检查 python 语法样式。
我正在使用 python 3.4
变量注释是 Python 3.6 中的新增内容,请参见例如what's new and PEP-526;您将需要升级才能使用此语法。请注意,您正在为其他两个 class 属性分配 values,而不是注释 types;这大概是无意的。
在相机切除的关键帧中,我试图创建一个出现在帧中的点列表,然后尝试创建一个包含后续帧中相应点的列表,以继续跟踪视频中的点求出它们之间的K矩阵。
我有以下 class 来存储每个帧的点并为每个帧创建一个点列表并沿着所有帧跟踪它们。
class PointsCorrespondence:
"""
Stores the point of a specific index.
"""
# A point is represented as (coordinate X, coordinate Y)
Point = (float, float)
# A point with corresponding same point is represented as (coordinates, index of the corresponding point or -1 if there is no corresponding point).
PointWithCorrespondence = (Point, int)
# Contains the points represented as one list of notable points for each frame.
_pointsPerFrame : [[PointWithCorrespondence]]
def __init__(self, pointsPerFrame : [[PointWithCorrespondence]]):
self._pointsPerFrame = pointsPerFrame
当我尝试 运行 此代码将点存储在其中时,出现以下错误:
Traceback (most recent call last): File "main.py", line 4, in import pointTracking File "/home/k/Desktop/CV/project/insertc/project12345/pointTracking.py", line 17
_pointsPerFrame : [[PointWithCorrespondence]] ^ SyntaxError: invalid syntax
实际上我不知道为什么会出现该错误,我尝试了很多方法来检查 python 语法样式。
我正在使用 python 3.4
变量注释是 Python 3.6 中的新增内容,请参见例如what's new and PEP-526;您将需要升级才能使用此语法。请注意,您正在为其他两个 class 属性分配 values,而不是注释 types;这大概是无意的。