python和多维列表的组合(opencv)

python和多维列表的组合(opencv),python,list,opencv,merge,Python,List,Opencv,Merge,我对python/opencv有点陌生,有点困惑。我想我的问题与opencv无关,只是python的问题。因此,我将在不使用opencv的情况下对其进行解释: 我有一个3维列表: for contour in contours: contour = cv2.approxPolyDP(contour,10,True) print "--------------------------" print contour print "-------------------

我对python/opencv有点陌生,有点困惑。我想我的问题与opencv无关,只是python的问题。因此,我将在不使用opencv的情况下对其进行解释: 我有一个3维列表:

for contour in contours:
    contour = cv2.approxPolyDP(contour,10,True)
    print "--------------------------"
    print contour
    print "--------------------------"
我明白了:

--------------------------
[[[168 377]]

 [[250 404]]]
--------------------------
--------------------------
[[[332 153]]

 [[419 216]]]
--------------------------
但是,我真正想要的是:

--------------------------
[[[168 377]]

 [[250 404]]

 [[332 153]]

 [[419 216]]]
--------------------------
当我自己建立列表时,它也在工作,它应该:

>>> np.array([[[168,377],[250,404],[332,153],[419,216]]])
array([[[168, 377],
        [250, 404],
        [332, 153],
        [419, 216]]])
我知道。。。尺寸不一样。我不知道为什么opencv可以处理这个问题!?(这些是
cv2.findContours
有人知道如何重新排列这个列表吗?或者是一个有用的文档。
感谢并问候:)

它们是numpy数组,如果您使用numpy作为关键字搜索或在numpy文档上搜索,您可以查找许多有用的内容。虽然发布的内容可能会解决问题,但最好提供一些解释。他们可以帮助未来的读者。谢谢Zaw!这就解决了所描述的问题。但不幸的是,这不是我的“真正”问题;)要将此新组合数组用作连续轮廓,必须将其用作
cv2.drawContours(绘图[np.vstack(组合)],0,颜色,1)
res = []
for contour in contours:
    contour = cv2.approxPolyDP(contour,10,True)
    print "--------------------------"
    print contour
    print "--------------------------"
    res.append(contour)
print np.vstack(res)
for i in range(2):
    tempcnts = cv2.findContours(gray, cv2.RETR_EXTERNAL,
                            cv2.CHAIN_APPROX_SIMPLE)
    tempcnts = imutils.grab_contours(tempcnts)
    # tempcnts = cv2.approxPolyDP(tempcnts, 10, True)
    print("--------------------------")
    print(tempcnts)
    print("--------------------------")
    if i==0:
        cnts=tempcnts
    else:
        cnts[0]=np.append(cnts[0], tempcnts[0],0)
print("--------------------------")
print("--------------------------")
print("--------------------------")
print(cnts)
print("--------------------------")
print("--------------------------")
print("--------------------------")