简体   繁体   English

python错误,尝试创建结构列表时语法无效

[英]error with python saying invalid syntax trying to create list of struct

In key frames in Camera resectioning, I am trying to create a list of points that appears in a frame and then try to create a list containing the corresponding points in the following frames to keep tracking the points along the video to find the K matrix between them. 在“相机后方交会”的关键帧中,我试图创建一个出现在帧中的点的列表,然后尝试创建一个包含以下帧中相应点的列表,以保持跟踪视频中的点以找到之间的K矩阵。他们。

I have the following class to store the points from each frame and to create a list of points for each frame and tracking them along all frames. 我有以下课程存储每个框架中的点,并为每个框架创建一个点列表,并沿所有框架跟踪它们。

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

when I try to run this code to store the points inside it, I got the following error: 当我尝试运行此代码以在其中存储点时,出现以下错误:

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 追溯(最近一次通话最后一次):导入pointTracking文件中的文件“ main.py”,第4行,行17中的“ /home/k/Desktop/CV/project/insertc/project12345/pointTracking.py”

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

actually I don't know why I got that error, and I tried many things to check the python syntax styles. 实际上,我不知道为什么会收到该错误,因此我尝试了很多方法来检查python语法样式。

I am using python 3.4 我正在使用python 3.4

Variable annotations are new in Python 3.6, see eg what's new and PEP-526 ; 变量注释是Python 3.6中的新增功能 ,请参见例如新功能PEP-526 you will need to upgrade to use this syntax. 您将需要升级才能使用此语法。 Note that you're assigning values , not annotating types , to the other two class attributes; 注意,您正在为其他两个类属性分配 ,而不是注释类型 this is presumably unintentional. 这大概是无意的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM