小编Con*_*mer的帖子

两个输入图像都必须在函数错误中具有 CV_8UC1

我打算从教程here做一个立体图像,但是编译器报告错误cv2.createStereoBM,我发现这是OpenCV版本的问题。

我跟着这个改变cv2.createStereoBMcv2.StereoBM。它运行良好,但以下代码:

disparity = stereo.compute(frame0,frame1)
Run Code Online (Sandbox Code Playgroud)

显示错误:

两个输入图像在函数 cv::findStereoCorrespondenceBM 中都必须有 CV_8UC1

谁能帮我这个?

环境是 Python 2.7,OpenCV 2.4.11。

我的代码是:

cap0 = cv2.VideoCapture(0)
cap1 = cv2.VideoCapture(1)
while (cap0.isOpened() and cap1.isOpened()):
    ret0, frame0 = cap0.read()
    frame0_new=cv2.cvtColor(frame0, cv2.COLOR_BGR2GRAY)

    ret1, frame1 = cap1.read()
    frame1_new=cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)


    stereo = cv2.StereoBM(cv2.STEREO_BM_BASIC_PRESET,ndisparities=16, SADWindowSize=15)

    disparity = stereo.compute(frame0,frame1)
Run Code Online (Sandbox Code Playgroud)

opencv numpy python-2.7

5
推荐指数
1
解决办法
6073
查看次数

python中有二维字典吗?

我正要创建一个像这样的矩阵:

\n\n
    33  12  23  42  11  32  43  22\n33  \xe2\x88\x92   1   1   1   0   0   1   1\n12  1   \xe2\x88\x92   1   1   0   0   1   1\n23  1   1   \xe2\x88\x92   1   1   1   0   0\n42  1   1   1   \xe2\x88\x92   1   1   0   0\n11  0   0   1   1   \xe2\x88\x92   1   1   1\n32  0   0   1   1   1   \xe2\x88\x92   1   1\n43  1   1   0   0   1   1   \xe2\x88\x92   1\n22  1   1   0   0   1   1   1   \xe2\x88\x92\n
Run Code Online (Sandbox Code Playgroud)\n\n

我想通过水平或垂直标题进行查询,所以我通过\xef\xbc\x9a创建了矩阵

\n\n
a = np.matrix('99 …
Run Code Online (Sandbox Code Playgroud)

python numpy

5
推荐指数
1
解决办法
3226
查看次数

在现有的 xml 文件中添加元素 python

我有一个现有的 xml 文件,如下所示:

<vehicleTravelTimeMeasurements>
        <vehicleTravelTimeMeasurement name="ckkkkkkkkkk" no="2">
            <start link="1" pos="3.864983"/>
            <end link="3" pos="23.275375"/>
        </vehicleTravelTimeMeasurement>
        <vehicleTravelTimeMeasurement name="" no="3">
            <start link="1" pos="3.864983"/>
            <end link="2" pos="13.275375"/>
        </vehicleTravelTimeMeasurement>
</vehicleTravelTimeMeasurements>
Run Code Online (Sandbox Code Playgroud)

我尝试使用 xml.etree.cElementTree 构建与上面所示相同的格式,并将它们正确添加到 xml 中:

new = ET.Element("vehicleTravelTimeMeasurement", name = "kkk", no = "4")
newsub1 =  ET.Element("start", link = "1", pos="3.88888")
newsub2 = ET.Element("end",link = "3", pos = "3.88888")
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题吗?

先感谢您!

python xml celementtree

4
推荐指数
1
解决办法
1万
查看次数

计算重复平均值python

我有一个二维数组:

 [[2,1],[2,32],[4,4512],[1,34],[2,323],[2,42],[1,23],[4,123]...]
Run Code Online (Sandbox Code Playgroud)

最后,我想计算平均值并得到数组,如 [ [1,mean],[2,mean],[3,mean]...],

有人有好的解决方案吗?我用了:

for i in range(len(array)):
    temp =[]
    for j in range(len(array)):
        if Table[i][0] == Table[j][0]:
                temp.append(Table[j])
Run Code Online (Sandbox Code Playgroud)

然后计算 的平均值temp,但效率不高。

有没有人有使用pandas库的解决方案?

python arrays python-2.7 pandas

2
推荐指数
1
解决办法
1195
查看次数

标签 统计

python ×3

numpy ×2

python-2.7 ×2

arrays ×1

celementtree ×1

opencv ×1

pandas ×1

xml ×1