Commit 802f5ba0 authored by Joel Collins's avatar Joel Collins
Browse files

Started updating documentation

parent be74b92b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
#

# You can set these variables from the command line.
SPHINXOPTS    =
SPHINXOPTS    = -a -E
SPHINXBUILD   = sphinx-build
SOURCEDIR     = source
BUILDDIR      = build
+6 −16
Original line number Diff line number Diff line
HTTP API
========

Summary
-------
.. qrefflask:: openflexure_microscope.api.app:app
   :undoc-endpoints: index
   :undoc-static:
   :endpoints:
Live documentation
------------------

Full, interactive Swagger documentation for your microscopes web API is available from the microscope itself. From any browser, go to ``http://{your microscope IP address}/api/v2/swagger-ui``.

Details
-------
Default views
-------------
.. autoflask:: openflexure_microscope.api.app:app
   :undoc-endpoints: index
   :undoc-static:
   :endpoints:
   :order: path

Example Requests
----------------

.. toctree::
   :maxdepth: 2

   ./apirequests.rst
 No newline at end of file

docs/source/apirequests.rst

deleted100644 → 0
+0 −108
Original line number Diff line number Diff line
Introduction
------------

In these examples, our microscope is located at the IP ``192.168.1.126``, running on port 5000.


New Image Capture
-----------------

Temprary capture, using video port.

CURL
++++
.. code-block:: none

   curl -X POST -H "Content-Type: application/json" -d \\
   '{"temporary": true, "use_video_port": true}' http://192.168.1.126:5000/api/v1/camera/capture

HTTPie
++++++
.. code-block:: none

   http POST http://192.168.1.126:5000/api/v1/camera/capture temporary:=true use_video_port:=true

Python Requests
+++++++++++++++
.. code-block:: python

   json_payload = {
        "keep_on_disk": keep_on_disk,
        "use_video_port": use_video_port
   }
   requests.post('http://192.168.1.126:5000/api/v1/camera/capture', json=json_payload)

Update Config
-------------

Example, changing picamera shutter speed to 2000, and the JPEG quality to 90.

CURL
++++
.. code-block:: none

   curl -X POST -H "Content-Type: application/json" -d \\
   '{"camera_settings": {"picamera_settings": {"shutter_speed": 2000}, "jpeg_quality": 90}}' http://192.168.1.126:5000/api/v1/config

HTTPie
++++++
.. code-block:: none

   http POST http://192.168.1.126:5000/api/v1/config camera_settings:='{"jpeg_quality": 90, "picamera_settings": {"shutter_speed": 2000}}' 

Python Requests
+++++++++++++++
.. code-block:: python

   json_payload = {
       camera_settings: {
            "jpeg_quality": 90,
            "picamera_settings": {"shutter_speed": 2000}
        }
   }
   requests.post('http://192.168.1.126:5000/api/v1/config', json=json_payload)

Read Config
-----------

CURL
++++
.. code-block:: none

   curl http://192.168.1.126:5000/api/v1/config

HTTPie
++++++
.. code-block:: none

   http GET http://192.168.1.126:5000/api/v1/config

Python Requests
+++++++++++++++
.. code-block:: python

   requests.get('http://192.168.1.126:5000/api/v1/config')

Recalibrate Picamera
--------------------

Starts the automatic recalibration plugin

CURL
++++
.. code-block:: none

   curl -X POST -H "Content-Type: application/json" \\
   http://192.168.1.126:5000/api/v1/plugin/default/camera_calibration/recalibrate

HTTPie
++++++
.. code-block:: none

   http POST http://192.168.1.126:5000/api/v1/plugin/default/camera_calibration/recalibrate

Python Requests
+++++++++++++++
.. code-block:: python

   requests.post('http://192.168.1.126:5000/api/v1/plugin/default/camera_calibration/recalibrate')
 No newline at end of file
+28 −2
Original line number Diff line number Diff line
Camera Class
=======================================================
============

.. toctree::
   :maxdepth: 2
@@ -7,3 +7,29 @@ Camera Class
   picamera.rst
   basecamera.rst
   capture.rst

Capturing from a camera object
------------------------------

In the cases of both a Raspberry Pi Streaming Camera, and a Mock Camera (attached if no real camera can be found), the camera's ``capture`` method takes as it's first positional argument either a string describing a file path to save to, or any Python file-like object.

The :class:`openflexure_microscope.camera.capture.CaptureObject` class works by providing a file path string, but adds additional functionality around storing and retreiving EXIF metadata in compatible files.

If, for your application, you do not require this functionality, you can pass a simple string or file-like object. For example, to take an image that will be stored in-memory, processed rapidly, and then discarded, you could use a BytesIO stream:

.. code-block:: python

    import io
    from PIL import Image
    ...

    with microscope.camera.lock, io.BytesIO() as stream:

        microscope.camera.capture(
            stream,
            use_video_port=True,
            bayer=False,
        )

        stream.seek(0)
        image = Image.open(stream)
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ Capture Object

By default, all image and video capture data are stored to instances of :py:class:`openflexure_microscope.camera.capture.CaptureObject`. This class mostly wraps up complexity associated with moving data between disk and memory. 

The class also includes some convenience features such as automatically cleaning up captures marked as temporary, handling metadata tags and file names, and generating image thumbnails. Often, the most recent capture wants to be stored in memory, for applications that involve immediately processing the capture data in some way. Rather than manually keep track of the location of the capture data, you can use the CaptureObject ``data`` attribute, which automatically returns capture data from the fastest available location. Additionally, the class handles storing capture metadata to Exif tags in supported formats. 
The class also includes some convenience features such as handling metadata tags and file names, and generating image thumbnails. Additionally, the class handles storing capture metadata to Exif tags in supported formats. 

Below are details of available methods and attributes.

Loading