def __init__(self, s, st): """ **SUMMARY** The constructor takes a source, and source type. **PARAMETERS** * *s* - the source of the imagery. * *st* - the type of the virtual camera. Valid strings include: * "image" - a single still image. * "video" - a video file. * "imageset" - a SimpleCV image set. **EXAMPLE** >>> vc = VirtualCamera("img.jpg", "image") >>> vc = VirtualCamera("video.mpg", "video") >>> vc = VirtualCamera("./path_to_images/", "imageset") """ self.source = s self.sourcetype = st self.counter = 0 if (self.sourcetype == "imageset"): self.source = ImageSet() if (type(s) == list): self.source.load(*s) else: self.source.load(s) if (self.sourcetype == 'video'): self.capture = cv.CaptureFromFile(self.source)
class VirtualCamera(FrameSource): """ The virtual camera lets you test algorithms or functions by providing a Camera object which is not a physically connected device. Currently, VirtualCamera supports "image", "imageset" and "video" source types. For image, pass the filename or URL to the image For the video, the filename For imageset, you can pass either a path or a list of [path, extension] """ source = "" sourcetype = "" def __init__(self, s, st): """ The constructor takes a source, and source type. ie: VirtualCamera("img.jpg", "image") or VirtualCamera("video.mpg", "video") """ self.source = s self.sourcetype = st self.counter = 0 if self.sourcetype == "imageset": self.source = ImageSet() if type(s) == list: self.source.load(*s) else: self.source.load(s) if self.sourcetype == "video": self.capture = cv.CaptureFromFile(self.source) def getImage(self): """ Retrieve the next frame of the video, or just a copy of the image """ if self.sourcetype == "image": return Image(self.source, self) if self.sourcetype == "imageset": img = self.source[self.counter % len(self.source)] self.counter = self.counter + 1 return img if self.sourcetype == "video": return Image(cv.QueryFrame(self.capture), self)
def __init__(self, s, st): """ **SUMMARY** The constructor takes a source, and source type. **PARAMETERS** * *s* - the source of the imagery. * *st* - the type of the virtual camera. Valid strings include: * "image" - a single still image. * "video" - a video file. * "imageset" - a SimpleCV image set. **EXAMPLE** >>> vc = VirtualCamera("img.jpg", "image") >>> vc = VirtualCamera("video.mpg", "video") """ self.source = s self.sourcetype = st self.counter = 0 if (self.sourcetype == "imageset"): self.source = ImageSet() if (type(s) == list): self.source.load(*s) else: self.source.load(s) if (self.sourcetype == 'video'): self.capture = cv.CaptureFromFile(self.source)
def __init__(self, s, st): """ **SUMMARY** The constructor takes a source, and source type. **PARAMETERS** * *s* - the source of the imagery. * *st* - the type of the virtual camera. Valid strings include: * "image" - a single still image. * "video" - a video file. * "imageset" - a SimpleCV image set. **EXAMPLE** >>> vc = VirtualCamera("img.jpg", "image") >>> vc = VirtualCamera("video.mpg", "video") >>> vc = VirtualCamera("./path_to_images/", "imageset") """ self.source = s self.sourcetype = st self.counter = 0 if not (self.sourcetype == "video" or self.sourcetype == "image" or self.sourcetype == "imageset"): print 'Error: In VirtualCamera(), Incorrect Source option. "%s" \nUsage:' % self.sourcetype print '\tVirtualCamera("filename","video")' print '\tVirtualCamera("filename","image")' print '\tVirtualCamera("./path_to_images","imageset")' return None if (type(self.source) == list): for source_file in self.source: if not os.path.exists(source_file): print 'Error: In VirtualCamera()\n\t"%s" was not found.' % source_file return None else: if not os.path.exists(self.source): print 'Error: In VirtualCamera()\n\t"%s" was not found.' % self.source return None if (self.sourcetype == "imageset"): self.source = ImageSet() if (type(s) == list): self.source.load(*s) else: self.source.load(s) if (self.sourcetype == 'video'): self.capture = cv.CaptureFromFile(self.source)
def __init__(self, s, st): """ The constructor takes a source, and source type. ie: VirtualCamera("img.jpg", "image") or VirtualCamera("video.mpg", "video") """ self.source = s self.sourcetype = st self.counter = 0 if (self.sourcetype == "imageset"): self.source = ImageSet() if (type(s) == list): self.source.load(*s) else: self.source.load(s) if (self.sourcetype == 'video'): self.capture = cv.CaptureFromFile(self.source)
class VirtualCamera(FrameSource): """ **SUMMARY** The virtual camera lets you test algorithms or functions by providing a Camera object which is not a physically connected device. Currently, VirtualCamera supports "image", "imageset" and "video" source types. **USAGE** * For image, pass the filename or URL to the image * For the video, the filename * For imageset, you can pass either a path or a list of [path, extension] """ source = "" sourcetype = "" def __init__(self, s, st): """ **SUMMARY** The constructor takes a source, and source type. **PARAMETERS** * *s* - the source of the imagery. * *st* - the type of the virtual camera. Valid strings include: * "image" - a single still image. * "video" - a video file. * "imageset" - a SimpleCV image set. **EXAMPLE** >>> vc = VirtualCamera("img.jpg", "image") >>> vc = VirtualCamera("video.mpg", "video") >>> vc = VirtualCamera("./path_to_images/", "imageset") """ self.source = s self.sourcetype = st self.counter = 0 if not (self.sourcetype == "video" or self.sourcetype == "image" or self.sourcetype == "imageset"): print 'Error: In VirtualCamera(), Incorrect Source option. "%s" \nUsage:' % self.sourcetype print '\tVirtualCamera("filename","video")' print '\tVirtualCamera("filename","image")' print '\tVirtualCamera("./path_to_images","imageset")' return None if (type(self.source) == list): for source_file in self.source: if not os.path.exists(source_file): print 'Error: In VirtualCamera()\n\t"%s" was not found.' % source_file return None else: if not os.path.exists(self.source): print 'Error: In VirtualCamera()\n\t"%s" was not found.' % self.source return None if (self.sourcetype == "imageset"): self.source = ImageSet() if (type(s) == list): self.source.load(*s) else: self.source.load(s) if (self.sourcetype == 'video'): self.capture = cv.CaptureFromFile(self.source) def getImage(self): """ **SUMMARY** Retrieve an Image-object from the virtual camera. **RETURNS** A SimpleCV Image from the camera. **EXAMPLES** >>> cam = VirtualCamera() >>> while True: >>> cam.getImage().show() """ if (self.sourcetype == 'image'): return Image(self.source, self) if (self.sourcetype == 'imageset'): img = self.source[self.counter % len(self.source)] self.counter = self.counter + 1 return img if (self.sourcetype == 'video'): return Image(cv.QueryFrame(self.capture), self)
class VirtualCamera(FrameSource): """ **SUMMARY** The virtual camera lets you test algorithms or functions by providing a Camera object which is not a physically connected device. Currently, VirtualCamera supports "image", "imageset" and "video" source types. **USAGE** * For image, pass the filename or URL to the image * For the video, the filename * For imageset, you can pass either a path or a list of [path, extension] """ source = "" sourcetype = "" def __init__(self, s, st): """ **SUMMARY** The constructor takes a source, and source type. **PARAMETERS** * *s* - the source of the imagery. * *st* - the type of the virtual camera. Valid strings include: * "image" - a single still image. * "video" - a video file. * "imageset" - a SimpleCV image set. **EXAMPLE** >>> vc = VirtualCamera("img.jpg", "image") >>> vc = VirtualCamera("video.mpg", "video") >>> vc = VirtualCamera("./path_to_images/", "imageset") """ self.source = s self.sourcetype = st self.counter = 0 if (self.sourcetype == "imageset"): self.source = ImageSet() if (type(s) == list): self.source.load(*s) else: self.source.load(s) if (self.sourcetype == 'video'): self.capture = cv.CaptureFromFile(self.source) def getImage(self): """ **SUMMARY** Retrieve an Image-object from the virtual camera. **RETURNS** A SimpleCV Image from the camera. **EXAMPLES** >>> cam = VirtualCamera() >>> while True: >>> cam.getImage().show() """ if (self.sourcetype == 'image'): return Image(self.source, self) if (self.sourcetype == 'imageset'): img = self.source[self.counter % len(self.source)] self.counter = self.counter + 1 return img if (self.sourcetype == 'video'): return Image(cv.QueryFrame(self.capture), self)