【发布时间】:2022-11-23 20:49:01
【问题描述】:
谁能教我怎么换
具有形状 [n,5] 的边界框坐标的 numpy 数组,格式为:
[[x11, y11, x12, y12, classid1],
[x21, y21, x22, y22, classid2],
...
[xn1, yn1, xn2, yn2, classid3]]
翻转 x 和 y 坐标的新 numpy 数组。
import numpy as np
coords = np.array([[1, 2, 13, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20],
[21, 22, 23, 24, 25]])
返回的 swapped_coords 应在每一行中交换 x 和 y 坐标。
我上网查了一下,大部分只包含2个元素。 x在哪里?你在哪里?如何兑换?我很困惑。
【问题讨论】:
-
您正在寻找的是移调,而不是交换。
coords.transpose() -
或者只是
coords.T -
你的意思是,例如
[1,2,13,4,5]应该变成[2,1,13,4,5]? -
您能否发布您对提供的示例矩阵期望的结果?不清楚
swapped x and y coordinates in each of the rows是什么意思 你的意思是交换第一个结束第二个元素? -
请阐明您的具体问题或提供更多详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。