gpt4 book ai didi

python - numpy python openCv 重新映射

转载 作者:行者123 更新时间:2023-11-28 05:58:00 25 4
gpt4 key购买 nike

我需要将一个函数从 opencv c++ 切换到 opencv python。C++ 版本是:(只是我遇到问题的部分)

map_x.at<float>(j,i) = pc.x;
map_y.at<float>(j,i) = pc.y;


remap(frame, unDistFrame, map_x, map_y, CV_INTER_LINEAR, 0, Scalar(0, 0, 0));

在 python 中,我有:

    rows,cols,channels = frame.shape

map_x = np.array((rows,cols, channels), np.uint8) # (that is: height, width,numchannels)
map_y = np.array((rows,cols, channels), np.uint8)
frameUnDist = np.array((rows,cols, channels), np.uint8)



for i in xrange(rows):
for j in xrange(cols):
p1 = [i, j]

p1_a = sendToFunction(params, p1)

np.insert(map_x, p1_a[0])
np.insert(map_y, p1_a[1])

cv2.remap(frame, frameUndist, map_x, map_y, flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, fillval=(0, 0, 0, 0))

插入行显然是错误的,因为我没有指定插入值的位置。我应该怎么做?

谢谢。

最佳答案

在 python OpenCV 中,Mats 实际上是 numpy 数组,所以你可以只使用 map_x[j,i] = pc.x

关于python - numpy python openCv 重新映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33802221/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com