【发布时间】:2018-06-11 11:42:53
【问题描述】:
在相机切除的关键帧中,我试图创建一个出现在帧中的点列表,然后尝试创建一个包含以下帧中对应点的列表,以继续跟踪视频中的点以找到它们之间的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
当我尝试运行此代码来存储其中的点时,出现以下错误:
Traceback(最近一次调用最后一次):文件“main.py”,第 4 行,在 导入点跟踪文件“/home/k/Desktop/CV/project/insertc/project12345/pointTracking.py”, 第 17 行
_pointsPerFrame : [[PointWithCorrespondence]] ^ SyntaxError: invalid syntax
其实我不知道为什么会出现这个错误,我尝试了很多方法来检查 python 语法样式。
我正在使用 python 3.4
【问题讨论】:
-
你是想在那里定义types,还是values?这很令人困惑。您使用的是哪个版本的 Python?
-
我在 ubuntu 14.04 上使用 python 3.4.3 默认版本
-
这只是我将用来存储我的观点的变量的初始化
-
嗯:1. 这是一个类属性,你实际上不需要“初始化”来设置一个实例属性;和 2. 你似乎混淆了将 values 分配给这些属性(例如,
(float, float)是一个双元组文字,内置 float 类作为两个元素)与指定 types,所以请澄清预期的行为。你的队友也在用 3.4.x 吗?
标签: python python-3.x opencv computer-vision camera-calibration