Skip to content

Commit

Permalink
lib: add an example to download an image (untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
josuah committed Nov 3, 2023
1 parent 160c5bb commit 4b48f90
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/example_get_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import asyncio
import io
import PIL.Image as Image
from brilliant import Monocle

remote_script = '''
import camera
camera.capture()
while data := camera.read(bluetooth.max_length()):
bluetooth.send(data)
'''

async def get_image():
async with Monocle() as m:
await m.send_command(remote_script)
from_monocle = await m.get_all_data()
return Image.open(io.BytesIO(from_monocle))

im = asyncio.run(get_image())
im.show()

0 comments on commit 4b48f90

Please sign in to comment.