Search code examples
pythonsimplecv

How to show multiple windows simultaneously in simpleCV after cropping image in four segments


I have write down a code which is getting images from a video "vd.mpg" and cropping images in 1/4 , while i am calling show() method at the end its showing only one window for live streaming of cropped video i want to make some changes in the given code so that i can be able to visualize all the 1/4 part of cropped video simultaneously

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()

Please help me what changes should i make in the given code. thanks in advance.


Solution

  • 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()