reshape, crop = {
1: ((1952, 3264), (1944, 3240)),
2: ((2480, 4128), (2464, 4100)),
}
offset = {1: 6404096, 2: 10270208,}[ver]
#where ver is defined as a dictionary
ver = {
'RP_ov5647': 1,
'RP_imx219': 2,
}[camera.exif_tags['IFD0.Model']]
这些是什么样的结构?ver
报告为int类型。我很困惑。
在offset
的作业中[ver]是如何工作的?你知道吗
让我们看看这里。。。你知道吗
这里是用键
1
和2
定义字典。每个键都有一个元组。我相信真正的代码中有更多的条目,在最后一项上用逗号表示。然而,这个对象的大部分会丢失到垃圾收集中。对reshape
和crop
的元组赋值将导致只存储密钥。所以这个结果是一样的:没用就有趣。下一个。。。你知道吗
所以这里定义了另一个字典,其中包含键
1
和2
以及与它们相关联的长整数值。然后它用ver
索引这个字典,并将这个索引处的值赋给offset
。因为ver
还没有定义,这实际上会导致一个异常。假设在前面的代码之前给出了以下代码:我们还有一本字典。这一次键是
'RP_ov5647'
和'RP_imx219'
,值是1
和2
。此词典的索引值为camera.exif_tags['IFD0.Model']
。假设camera.exif_tags
是具有键控索引的对象,其中一个索引是'IFD0.Model'
,结果值是'RP_ov5647'
或'RP_imx219'
,则ver
将被分配1
或2
。你知道吗因此,1或2将用于索引我们的上述偏移量值,从而导致偏移量被指定为
6404096
或10270208
简而言之,这都是一堆语法上有效的东西。谢谢分享。你知道吗
首先,您的初始语句不会做(我认为)您想做的事情:赋值左边有两个变量,右边只有一个值一个字典。我想你最后错过了
[ver]
。如前所述,该语句将构建字典,提取键(1,2),并将这些键赋给变量,而忽略维度元组。你知道吗上面的变量
ver
是在字典中查找的整数。你知道吗这段代码似乎是从模型名开始设计的,并根据该模型查找适当的参数。让我们按正确的顺序看代码,并使用几个中间变量。你知道吗
在所有这些之后,我们得到了
shaping
和crop
对于这个相机模型具有适当的尺寸,并且offset
在输入流中具有适当的像素偏移(我假设)。你知道吗这就是你需要的吗?你知道吗
相关问题 更多 >
编程相关推荐