简体   繁体   中英

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.

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

 _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.

I am using python 3.4

Variable annotations are new in Python 3.6, see eg what's new and 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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