如何在四个段中裁剪图像后,在simpleCV中同时显示多个窗口

时间:2014-06-10 05:33:29

标签: python simplecv

我写了一段代码,从视频中获取图片" vd.mpg"并在1/4中裁剪图像,而我在最后调用show()方法,它只显示一个用于播放视频直播的窗口我想在给定代码中进行一些更改,以便我能够将所有同时裁剪视频的1/4部分

from SimpleCV import *
from SimpleCV import VirtualCamera
#from pylab import *
#from pylab import plot, show
#from time import *
vir = VirtualCamera("vd.mpg", "video")
while True:
    previous = vir.getImage()
    cropped_1 = previous.crop(0,0,320,240)
    cropped_2 = previous.crop(320,0,320,240)
    cropped_3 = previous.crop(0,240,320,240)
    cropped_4 = previous.crop(320,240,320,240) 
    cropped_1.show()
    cropped_2.show()
    cropped_3.show()
    cropped_4.show()

请帮助我在给定的代码中做出哪些更改。提前致谢。

1 个答案:

答案 0 :(得分:2)

from SimpleCV import *
crops = ((0,0,320,240),(320,0,320,240),(0,240,320,240),(320,240,320,240))
cam=VirtualCamera('vd.mpg','video')
while True:
    imgs=[]
    img=cam.getImage()
    for crop in crops:
        imgs.append(img.crop(crop[0],crop[1],crop[2],crop[3]))
    row1=imgs[0].sideBySide(imgs[1])
    row2=imgs[2].sideBySide(imgs[3])
    outputimg=row1.sideBySide(row2, 'top')
    outputimg.show()