from model import * from mimages import * from mlist import * # We can represent a sequence of images as a list of JPEG file names. # # c_pythonlist c_integer c_image (getframe) # / # / # c_pythonlist c_integer c_object / (concrete_getitem) # \ \ \ / # c_pythonlist c_integer c_string # getframe = Operation([c_pythonlist, c_integer, c_image]) getframe[0, 0, pathname+jpegimage] = concrete_getitem[0, 0, stringobject] # Let's generalize and call video a sequence of images. # # c_sequence c_index c_item # \ \ \ # c_video c_index c_image # | | | # c_pythonlist c_integer c_image # c_video = Concept() videoframes = Morphism(c_video, c_sequence, "A video contains a sequence of frames.") simplelistvideo = Morphism(c_pythonlist, c_video, "A video implemented as a list of images.") imageitem = Morphism(c_image, c_item) getvideoframe = Operation([c_video, c_index, c_image]) getvideoframe[simplelistvideo, integerindex, 0] = getframe getitem[videoframes, 0, imageitem] = getvideoframe ### test ### if __name__ == '__main__': import model; model.Abstract.DEBUG = True x2 = frames('testing') i1 = c_framenumber(25) print getframe(x2, i1)