python错误说无效语法试图创建结构列表

问题描述 投票:0回答:1

在相机切除中的关键帧中,我试图创建一个出现在帧中的点列表,然后尝试创建一个包含以下帧中相应点的列表,以跟踪视频中的点以找到之间的K矩阵他们。

我有以下类来存储每个帧的点,并为每个帧创建一个点列表并沿所有帧跟踪它们。

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

当我尝试运行此代码来存储其中的点时,我收到以下错误:

回溯(最近一次调用最后一次):文件“main.py”,第4行,在导入点跟踪文件“/home/k/Desktop/CV/project/insertc/project12345/pointTracking.py”,第17行

_pointsPerFrame : [[PointWithCorrespondence]]
                ^ SyntaxError: invalid syntax

实际上我不知道为什么我有这个错误,我尝试了很多东西来检查python语法风格。

我正在使用python 3.4

python python-3.x opencv computer-vision camera-calibration
1个回答
1
投票

变量注释是Python 3.6中的新增功能,请参阅例如what's newPEP-526;您需要升级才能使用此语法。请注意,您要将值(而不是注释类型)分配给其他两个类属性;这可能是无意的。

© www.soinside.com 2019 - 2024. All rights reserved.