def capture_continuous(self, output, format=None, use_video_port=False, resize=None, splitter_port=0, burst=False, bayer=False, **options):
    "\n        Capture images continuously from the camera as an infinite iterator.\n\n        This method returns an infinite iterator of images captured\n        continuously from the camera. If *output* is a string, each captured\n        image is stored in a file named after *output* after substitution of\n        two values with the :meth:`~str.format` method. Those two values are:\n\n        * ``{counter}`` - a simple incrementor that starts at 1 and increases\n          by 1 for each image taken\n\n        * ``{timestamp}`` - a :class:`~datetime.datetime` instance\n\n        The table below contains several example values of *output* and the\n        sequence of filenames those values could produce:\n\n        .. tabularcolumns:: |p{80mm}|p{40mm}|p{10mm}|\n\n        +--------------------------------------------+--------------------------------------------+-------+\n        | *output* Value                             | Filenames                                  | Notes |\n        +============================================+============================================+=======+\n        | ``'image{counter}.jpg'``                   | image1.jpg, image2.jpg, image3.jpg, ...    |       |\n        +--------------------------------------------+--------------------------------------------+-------+\n        | ``'image{counter:02d}.jpg'``               | image01.jpg, image02.jpg, image03.jpg, ... |       |\n        +--------------------------------------------+--------------------------------------------+-------+\n        | ``'image{timestamp}.jpg'``                 | image2013-10-05 12:07:12.346743.jpg,       | (1)   |\n        |                                            | image2013-10-05 12:07:32.498539, ...       |       |\n        +--------------------------------------------+--------------------------------------------+-------+\n        | ``'image{timestamp:%H-%M-%S-%f}.jpg'``     | image12-10-02-561527.jpg,                  |       |\n        |                                            | image12-10-14-905398.jpg                   |       |\n        +--------------------------------------------+--------------------------------------------+-------+\n        | ``'{timestamp:%H%M%S}-{counter:03d}.jpg'`` | 121002-001.jpg, 121013-002.jpg,            | (2)   |\n        |                                            | 121014-003.jpg, ...                        |       |\n        +--------------------------------------------+--------------------------------------------+-------+\n\n        1. Note that because timestamp's default output includes colons (:),\n           the resulting filenames are not suitable for use on Windows. For\n           this reason (and the fact the default contains spaces) it is\n           strongly recommended you always specify a format when using\n           ``{timestamp}``.\n\n        2. You can use both ``{timestamp}`` and ``{counter}`` in a single\n           format string (multiple times too!) although this tends to be\n           redundant.\n\n        If *output* is not a string, but has a ``write`` method, it is assumed\n        to be a file-like object and each image is simply written to this\n        object sequentially. In this case you will likely either want to write\n        something to the object between the images to distinguish them, or\n        clear the object between iterations. If *output* is not a string, and\n        has no ``write`` method, it is assumed to be a writeable object\n        supporting the buffer protocol; each image is simply written to the\n        buffer sequentially.\n\n        The *format*, *use_video_port*, *splitter_port*, *resize*, and\n        *options* parameters are the same as in :meth:`capture`.\n\n        If *use_video_port* is ``False`` (the default), the *burst* parameter\n        can be used to make still port captures faster.  Specifically, this\n        prevents the preview from switching resolutions between captures which\n        significantly speeds up consecutive captures from the still port. The\n        downside is that this mode is currently has several bugs; the major\n        issue is that if captures are performed too quickly some frames will\n        come back severely underexposed. It is recommended that users avoid the\n        *burst* parameter unless they absolutely require it and are prepared to\n        work around such issues.\n\n        For example, to capture 60 images with a one second delay between them,\n        writing the output to a series of JPEG files named image01.jpg,\n        image02.jpg, etc. one could do the following::\n\n            import time\n            import picamera\n            with picamera.PiCamera() as camera:\n                camera.start_preview()\n                try:\n                    for i, filename in enumerate(\n                            camera.capture_continuous('image{counter:02d}.jpg')):\n                        print(filename)\n                        time.sleep(1)\n                        if i == 59:\n                            break\n                finally:\n                    camera.stop_preview()\n\n        Alternatively, to capture JPEG frames as fast as possible into an\n        in-memory stream, performing some processing on each stream until\n        some condition is satisfied::\n\n            import io\n            import time\n            import picamera\n            with picamera.PiCamera() as camera:\n                stream = io.BytesIO()\n                for foo in camera.capture_continuous(stream, format='jpeg'):\n                    # Truncate the stream to the current position (in case\n                    # prior iterations output a longer image)\n                    stream.truncate()\n                    stream.seek(0)\n                    if process(stream):\n                        break\n\n        .. versionchanged:: 1.0\n            The *resize* parameter was added, and raw capture formats can now\n            be specified directly\n\n        .. versionchanged:: 1.3\n            The *splitter_port* parameter was added\n\n        .. versionchanged:: 1.11\n            Support for buffer outputs was added.\n        "
    if use_video_port:
        if burst:
            raise PiCameraValueError('burst is only valid with still port captures')
        if bayer:
            raise PiCameraValueError('bayer is only valid with still port captures')
    with self._encoders_lock:
        (camera_port, output_port) = self._get_ports(use_video_port, splitter_port)
        format = self._get_image_format(output, format)
        encoder = self._get_image_encoder(camera_port, output_port, format, resize, **options)
        if use_video_port:
            self._encoders[splitter_port] = encoder
    try:
        if burst:
            camera_port.params[mmal.MMAL_PARAMETER_CAMERA_BURST_CAPTURE] = True
        try:
            if isinstance(output, bytes):
                output = output.decode('utf-8')
            if isinstance(output, str):
                counter = 1
                while True:
                    filename = output.format(counter=counter, timestamp=datetime.datetime.now())
                    if bayer:
                        camera_port.params[mmal.MMAL_PARAMETER_ENABLE_RAW_CAPTURE] = True
                    encoder.start(filename)
                    if (not encoder.wait(self.CAPTURE_TIMEOUT)):
                        raise PiCameraRuntimeError('Timed out waiting for capture to end')
                    (yield filename)
                    counter += 1
            else:
                while True:
                    if bayer:
                        camera_port.params[mmal.MMAL_PARAMETER_ENABLE_RAW_CAPTURE] = True
                    encoder.start(output)
                    if (not encoder.wait(self.CAPTURE_TIMEOUT)):
                        raise PiCameraRuntimeError('Timed out waiting for capture to end')
                    (yield output)
        finally:
            if burst:
                camera_port.params[mmal.MMAL_PARAMETER_CAMERA_BURST_CAPTURE] = False
    finally:
        encoder.close()
        with self._encoders_lock:
            if use_video_port:
                del self._encoders[splitter_port]
Capture images continuously from the camera as an infinite iterator.

This method returns an infinite iterator of images captured
continuously from the camera. If *output* is a string, each captured
image is stored in a file named after *output* after substitution of
two values with the :meth:`~str.format` method. Those two values are:

* ``{counter}`` - a simple incrementor that starts at 1 and increases
  by 1 for each image taken

* ``{timestamp}`` - a :class:`~datetime.datetime` instance

The table below contains several example values of *output* and the
sequence of filenames those values could produce:

.. tabularcolumns:: |p{80mm}|p{40mm}|p{10mm}|

+--------------------------------------------+--------------------------------------------+-------+
| *output* Value                             | Filenames                                  | Notes |
+============================================+============================================+=======+
| ``'image{counter}.jpg'``                   | image1.jpg, image2.jpg, image3.jpg, ...    |       |
+--------------------------------------------+--------------------------------------------+-------+
| ``'image{counter:02d}.jpg'``               | image01.jpg, image02.jpg, image03.jpg, ... |       |
+--------------------------------------------+--------------------------------------------+-------+
| ``'image{timestamp}.jpg'``                 | image2013-10-05 12:07:12.346743.jpg,       | (1)   |
|                                            | image2013-10-05 12:07:32.498539, ...       |       |
+--------------------------------------------+--------------------------------------------+-------+
| ``'image{timestamp:%H-%M-%S-%f}.jpg'``     | image12-10-02-561527.jpg,                  |       |
|                                            | image12-10-14-905398.jpg                   |       |
+--------------------------------------------+--------------------------------------------+-------+
| ``'{timestamp:%H%M%S}-{counter:03d}.jpg'`` | 121002-001.jpg, 121013-002.jpg,            | (2)   |
|                                            | 121014-003.jpg, ...                        |       |
+--------------------------------------------+--------------------------------------------+-------+

1. Note that because timestamp's default output includes colons (:),
   the resulting filenames are not suitable for use on Windows. For
   this reason (and the fact the default contains spaces) it is
   strongly recommended you always specify a format when using
   ``{timestamp}``.

2. You can use both ``{timestamp}`` and ``{counter}`` in a single
   format string (multiple times too!) although this tends to be
   redundant.

If *output* is not a string, but has a ``write`` method, it is assumed
to be a file-like object and each image is simply written to this
object sequentially. In this case you will likely either want to write
something to the object between the images to distinguish them, or
clear the object between iterations. If *output* is not a string, and
has no ``write`` method, it is assumed to be a writeable object
supporting the buffer protocol; each image is simply written to the
buffer sequentially.

The *format*, *use_video_port*, *splitter_port*, *resize*, and
*options* parameters are the same as in :meth:`capture`.

If *use_video_port* is ``False`` (the default), the *burst* parameter
can be used to make still port captures faster.  Specifically, this
prevents the preview from switching resolutions between captures which
significantly speeds up consecutive captures from the still port. The
downside is that this mode is currently has several bugs; the major
issue is that if captures are performed too quickly some frames will
come back severely underexposed. It is recommended that users avoid the
*burst* parameter unless they absolutely require it and are prepared to
work around such issues.

For example, to capture 60 images with a one second delay between them,
writing the output to a series of JPEG files named image01.jpg,
image02.jpg, etc. one could do the following::

    import time
    import picamera
    with picamera.PiCamera() as camera:
        camera.start_preview()
        try:
            for i, filename in enumerate(
                    camera.capture_continuous('image{counter:02d}.jpg')):
                print(filename)
                time.sleep(1)
                if i == 59:
                    break
        finally:
            camera.stop_preview()

Alternatively, to capture JPEG frames as fast as possible into an
in-memory stream, performing some processing on each stream until
some condition is satisfied::

    import io
    import time
    import picamera
    with picamera.PiCamera() as camera:
        stream = io.BytesIO()
        for foo in camera.capture_continuous(stream, format='jpeg'):
            # Truncate the stream to the current position (in case
            # prior iterations output a longer image)
            stream.truncate()
            stream.seek(0)
            if process(stream):
                break

.. versionchanged:: 1.0
    The *resize* parameter was added, and raw capture formats can now
    be specified directly

.. versionchanged:: 1.3
    The *splitter_port* parameter was added

.. versionchanged:: 1.11
    Support for buffer outputs was added.
def capture_continuous(self, output, format=None, use_video_port=False, resize=None, splitter_port=0, burst=False, bayer=False, **options):
    "\n        Capture images continuously from the camera as an infinite iterator.\n\n        This method returns an infinite iterator of images captured\n        continuously from the camera. If *output* is a string, each captured\n        image is stored in a file named after *output* after substitution of\n        two values with the :meth:`~str.format` method. Those two values are:\n\n        * ``{counter}`` - a simple incrementor that starts at 1 and increases\n          by 1 for each image taken\n\n        * ``{timestamp}`` - a :class:`~datetime.datetime` instance\n\n        The table below contains several example values of *output* and the\n        sequence of filenames those values could produce:\n\n        .. tabularcolumns:: |p{80mm}|p{40mm}|p{10mm}|\n\n        +--------------------------------------------+--------------------------------------------+-------+\n        | *output* Value                             | Filenames                                  | Notes |\n        +============================================+============================================+=======+\n        | ``'image{counter}.jpg'``                   | image1.jpg, image2.jpg, image3.jpg, ...    |       |\n        +--------------------------------------------+--------------------------------------------+-------+\n        | ``'image{counter:02d}.jpg'``               | image01.jpg, image02.jpg, image03.jpg, ... |       |\n        +--------------------------------------------+--------------------------------------------+-------+\n        | ``'image{timestamp}.jpg'``                 | image2013-10-05 12:07:12.346743.jpg,       | (1)   |\n        |                                            | image2013-10-05 12:07:32.498539, ...       |       |\n        +--------------------------------------------+--------------------------------------------+-------+\n        | ``'image{timestamp:%H-%M-%S-%f}.jpg'``     | image12-10-02-561527.jpg,                  |       |\n        |                                            | image12-10-14-905398.jpg                   |       |\n        +--------------------------------------------+--------------------------------------------+-------+\n        | ``'{timestamp:%H%M%S}-{counter:03d}.jpg'`` | 121002-001.jpg, 121013-002.jpg,            | (2)   |\n        |                                            | 121014-003.jpg, ...                        |       |\n        +--------------------------------------------+--------------------------------------------+-------+\n\n        1. Note that because timestamp's default output includes colons (:),\n           the resulting filenames are not suitable for use on Windows. For\n           this reason (and the fact the default contains spaces) it is\n           strongly recommended you always specify a format when using\n           ``{timestamp}``.\n\n        2. You can use both ``{timestamp}`` and ``{counter}`` in a single\n           format string (multiple times too!) although this tends to be\n           redundant.\n\n        If *output* is not a string, but has a ``write`` method, it is assumed\n        to be a file-like object and each image is simply written to this\n        object sequentially. In this case you will likely either want to write\n        something to the object between the images to distinguish them, or\n        clear the object between iterations. If *output* is not a string, and\n        has no ``write`` method, it is assumed to be a writeable object\n        supporting the buffer protocol; each image is simply written to the\n        buffer sequentially.\n\n        The *format*, *use_video_port*, *splitter_port*, *resize*, and\n        *options* parameters are the same as in :meth:`capture`.\n\n        If *use_video_port* is ``False`` (the default), the *burst* parameter\n        can be used to make still port captures faster.  Specifically, this\n        prevents the preview from switching resolutions between captures which\n        significantly speeds up consecutive captures from the still port. The\n        downside is that this mode is currently has several bugs; the major\n        issue is that if captures are performed too quickly some frames will\n        come back severely underexposed. It is recommended that users avoid the\n        *burst* parameter unless they absolutely require it and are prepared to\n        work around such issues.\n\n        For example, to capture 60 images with a one second delay between them,\n        writing the output to a series of JPEG files named image01.jpg,\n        image02.jpg, etc. one could do the following::\n\n            import time\n            import picamera\n            with picamera.PiCamera() as camera:\n                camera.start_preview()\n                try:\n                    for i, filename in enumerate(\n                            camera.capture_continuous('image{counter:02d}.jpg')):\n                        print(filename)\n                        time.sleep(1)\n                        if i == 59:\n                            break\n                finally:\n                    camera.stop_preview()\n\n        Alternatively, to capture JPEG frames as fast as possible into an\n        in-memory stream, performing some processing on each stream until\n        some condition is satisfied::\n\n            import io\n            import time\n            import picamera\n            with picamera.PiCamera() as camera:\n                stream = io.BytesIO()\n                for foo in camera.capture_continuous(stream, format='jpeg'):\n                    # Truncate the stream to the current position (in case\n                    # prior iterations output a longer image)\n                    stream.truncate()\n                    stream.seek(0)\n                    if process(stream):\n                        break\n\n        .. versionchanged:: 1.0\n            The *resize* parameter was added, and raw capture formats can now\n            be specified directly\n\n        .. versionchanged:: 1.3\n            The *splitter_port* parameter was added\n\n        .. versionchanged:: 1.11\n            Support for buffer outputs was added.\n        "
    if use_video_port:
        if burst:
            raise PiCameraValueError('burst is only valid with still port captures')
        if bayer:
            raise PiCameraValueError('bayer is only valid with still port captures')
    with self._encoders_lock:
        (camera_port, output_port) = self._get_ports(use_video_port, splitter_port)
        format = self._get_image_format(output, format)
        encoder = self._get_image_encoder(camera_port, output_port, format, resize, **options)
        if use_video_port:
            self._encoders[splitter_port] = encoder
    try:
        if burst:
            camera_port.params[mmal.MMAL_PARAMETER_CAMERA_BURST_CAPTURE] = True
        try:
            if isinstance(output, bytes):
                output = output.decode('utf-8')
            if isinstance(output, str):
                counter = 1
                while True:
                    filename = output.format(counter=counter, timestamp=datetime.datetime.now())
                    if bayer:
                        camera_port.params[mmal.MMAL_PARAMETER_ENABLE_RAW_CAPTURE] = True
                    encoder.start(filename)
                    if (not encoder.wait(self.CAPTURE_TIMEOUT)):
                        raise PiCameraRuntimeError('Timed out waiting for capture to end')
                    (yield filename)
                    counter += 1
            else:
                while True:
                    if bayer:
                        camera_port.params[mmal.MMAL_PARAMETER_ENABLE_RAW_CAPTURE] = True
                    encoder.start(output)
                    if (not encoder.wait(self.CAPTURE_TIMEOUT)):
                        raise PiCameraRuntimeError('Timed out waiting for capture to end')
                    (yield output)
        finally:
            if burst:
                camera_port.params[mmal.MMAL_PARAMETER_CAMERA_BURST_CAPTURE] = False
    finally:
        encoder.close()
        with self._encoders_lock:
            if use_video_port:
                del self._encoders[splitter_port]