Skip to content

Commit

Permalink
fixed namespace shortening and finalised documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cansik committed Dec 28, 2023
1 parent d0a74bf commit f0b327f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
10 changes: 5 additions & 5 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ To make sharing graphic textures as easy as possible, the library provides some
The `syphon.utils.raw` module contains methods to create and manipulate textures with a raw `bytes` array.

#### Create MTLTexture
To create an [MTLTexture](https://developer.apple.com/documentation/metal/mtltexture) the method `syphon.utils.raw.create_mtl_texture` can be used. It is possible to create your own default device or use a server's `device` property to get the current device.
To create an [MTLTexture](https://developer.apple.com/documentation/metal/mtltexture) the method `syphon.utils.raw.create_mtl_texture` can be used. It is possible to create your own default device or use a server's `syphon.server.SyphonMetalServer.device` property to get the current device.

```python
import Metal
Expand All @@ -178,7 +178,7 @@ texture = create_mtl_texture(mtl_device, 512, 512)
```

#### Manipulate MTLTexture
To write `bytes` to an [MTLTexture](https://developer.apple.com/documentation/metal/mtltexture) the method `syphon.utils.raw.copy_bytes_to_mtl_texture` can be used.
To write `bytes` to an [MTLTexture](https://developer.apple.com/documentation/metal/mtltexture) the method `syphon.utils.raw.copy_bytes_to_mtl_texture()` can be used.

```python
from syphon.utils.raw import copy_bytes_to_mtl_texture
Expand All @@ -189,7 +189,7 @@ texture = ... # MLTTexture object
copy_bytes_to_mtl_texture(data, texture)
```

To read `bytes` from an [MTLTexture](https://developer.apple.com/documentation/metal/mtltexture) the method `syphon.utils.raw.copy_mtl_texture_to_bytes` can be used.
To read `bytes` from an [MTLTexture](https://developer.apple.com/documentation/metal/mtltexture) the method `syphon.utils.raw.copy_mtl_texture_to_bytes()` can be used.

```python
from syphon.utils.raw import copy_mtl_texture_to_bytes
Expand All @@ -204,7 +204,7 @@ If you are working with [Numpy](https://numpy.org/) arrays, the `syphon.utils.nu

It is important to note that the `numpy` package is not installed by default, it must be installed using `pip install numpy`.

To write a numpy image to a MTLTexture, the `syphon.utils.numpy.copy_image_to_mtl_texture` method can be used.
To write a numpy image to a MTLTexture, the `syphon.utils.numpy.copy_image_to_mtl_texture()` method can be used.

```python
import numpy as np
Expand All @@ -219,7 +219,7 @@ texture_data = np.zeros((512, 512, 4), dtype=np.uint8)
copy_image_to_mtl_texture(texture_data, texture)
```

To read a numpy image from a MTLTexture, the `syphon.utils.numpy.copy_mtl_texture_to_image` method can be used.
To read a numpy image from a MTLTexture, the `syphon.utils.numpy.copy_mtl_texture_to_image()` method can be used.

```python
import numpy as np
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
[![Build](https://github.com/cansik/syphon-python/actions/workflows/build.yml/badge.svg)](https://github.com/cansik/syphon-python/actions/workflows/build.yml)
[![PyPI](https://img.shields.io/pypi/v/syphon-python)](https://pypi.org/project/syphon-python/)

⚠️ This library is still *under development*.
⚠️ This library is still *in development*.

Python wrapper for the GPU texture sharing framework Syphon. This library has been created to support the Metal backend
as well as the deprecated OpenGL backend. It requires **macOS 11 or higher**.
Python wrapper for the Syphon GPU texture sharing framework. This library was created to support both the Metal backend
and the deprecated OpenGL backend. It requires **macOS 11 or above**.

The implementation is based on [PyObjC](https://github.com/ronaldoussoren/pyobjc) to wrap
the [Syphon-Framework](https://github.com/Syphon/Syphon-Framework) directly from within Python. This approach removes
the need of a native wrapper and allows Python developers to extend the library if needed.
The implementation is based on [PyObjC](https://github.com/ronaldoussoren/pyobjc) to wrap the
Syphon framework](https://github.com/Syphon/Syphon-Framework) directly from Python. This approach eliminates
native wrapper and allows Python developers to extend the library as needed.

## State of Development

Expand All @@ -23,19 +23,19 @@ the need of a native wrapper and allows Python developers to extend the library
- [ ] Syphon Client On Frame Callback

## Usage
To install `syphon-python` it is recommended to use a pre-built binary from PyPi:
To install `syphon-python` it is recommended to use a prebuilt binary from PyPi:

```bash
pip install syphon-python
```

For examples using `numpy`, please also install numpy:
To run all the examples, please also install [Numpy](https://numpy.org/) and [OpenCV](https://opencv.org/):

```bash
pip install numpy
pip install numpy opencv-python
```

The following code snippet is a basic example which shows how to share `numpy` images as a `MTLTexture` with a `SyphonMetalServer`. There are more examples under [examples](/examples).
The following code snippet is a basic example showing how to share `numpy` images as `MTLTexture` with a `SyphonMetalServer`. There are more examples in [examples](/examples).

```python
import time
Expand Down Expand Up @@ -65,7 +65,7 @@ server.stop()
```

## Development
To develop the library or install it manually, use the following commands to setup the local repository.
To develop or manually install the library, use the following commands to set up the local repository.

### Installation

Expand All @@ -84,7 +84,7 @@ pip install opencv-python

### Build

Build the Syphon-Framework on your machine:
Build the Syphon framework on your machine:

```bash
python setup.py build
Expand Down
6 changes: 1 addition & 5 deletions scripts/generate_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ def linkify_repl(m: re.Match):
if plain_text.endswith("()"):
plain_text = f"{doc.name}()"
else:
# replaced doc.fullname with doc.name if is class (uppercase letter) to only display identifier
if doc.fullname.split(".")[-1][0].isupper():
plain_text = doc.name
else:
plain_text = doc.fullname
plain_text = doc.name
return f'<a href="{relative_link(context["module"].modulename, module)}{qualname}">{plain_text}</a>'
else:
return text
Expand Down

0 comments on commit f0b327f

Please sign in to comment.