session.camera.takePhoto captures a still on glasses that have a camera, like
Mentra Live. It resolves once the photo is on the phone, as one of your
miniapp’s own files. Nothing is uploaded: your miniapp decides where the photo
goes.
src/background/index.ts
CAMERA permission and glasses with a camera. Declare a
CAMERA permission in your manifest
so the call is allowed, and a CAMERA hardware requirement so the miniapp only
installs on glasses that can capture. Check session.capabilities.hasCamera
before calling so you don’t fire a request the glasses can’t satisfy.
Take a photo
takePhoto sends the request, waits while the glasses capture and send the
photo to the phone, then resolves with where your miniapp finds it. The photo works
without an internet connection.
size, "auto", is the largest photo that arrives in about 2 seconds on the link it
comes over, which the glasses decide when they send it: 1280×960 at JPEG quality 60 over Bluetooth,
the full sensor (4032×3024) over the glasses Wi-Fi link. A fixed size is low 640×480, medium
1280×960, high 2560×1920 and max 4032×3024, except that over Bluetooth high arrives at
1600×1200 and max at 1920×1440; a larger one takes longer over Bluetooth. Glasses from before auto take it as "medium".
All options are optional. The defaults are listed below.
The result is a
PhotoTaken:
Thumbnails
A full photo decodes to tens of megabytes on a screen, so a list or timeline of photos should show their thumbnails. The phone makes one for every photo as it arrives: a JPEG at most 512 px on its long side, upright, about 20 to 40 KB. It is one of your miniapp’s own files like the photo, under its ownkey in session.blob, cached like the photo.
A thumbnail exists once the full photo is on the phone. To show something sooner, ask the
glasses for a preview (
preview: true, below), which comes over Bluetooth before the full photo.
Take photos in stages
capture returns at once with the photo’s stages. Use it to take photos back to
back and fetch only the ones you keep: the full photo waits on the glasses until
you ask for it. With preview: true the glasses also send a small preview right
after the capture, which you can show before the full photo comes; without it
they send none, and the capture has no preview.
CAMERA_BUSY. preview.url
is a data:image/jpeg;base64, URL. The full photo stays on the glasses for 30
minutes at most; photo() asks for it the first time and returns the same photo
after that. For a preview only, await preview and release() without calling
photo(). takePhoto(options) is capture(options).photo() with no preview,
releasing the glasses’ copy once the photo is on the phone.
Camera sessions
A miniapp that takes many photos, like documenting a site, opens the camera for the whole stretch of work instead of callingcapture() on its own:
open() to close() the Mentra App holds the glasses Wi-Fi link, so full
photos come over it, and keeps the camera warm with the session’s settings, so
each photo is taken at once. Every photo goes through the session the same way,
one at a time: the next starts once the camera took the previous one. Only what
asks for a photo differs: capture(options) for a tap, with its options over
the session’s, or continuous(options), which takes photos on its own as fast
as the camera takes them. It waits by itself while the link is down, so photos
never pile up on the glasses behind Bluetooth. close() stops taking photos at
once and resolves once the photos the session handed out are released; closing
the miniapp closes it. A miniapp has one camera open at a time: open it again
only after close(). It requires CAMERA permission.
Keep the camera warm
Opening the camera takes about a second. A miniapp that takes photos on demand for a while, like a session that photographs on each button press, can keep it open:size, mode, exposureTimeNs, zsl and mfnr as your
photos: a photo with other settings reconfigures the camera. The phone keeps the
camera warm until you release it, however long. A miniapp holds one warm-up at a
time; a new warmUp() replaces the previous one.
Use the photo
The photo is a cachedsession.blob
entry: it doesn’t count toward your miniapp’s storage limit, and the phone
deletes it once newer files fill your miniapp’s cache.
- Send it somewhere. Read the bytes in your background script and upload
them yourself:
await session.blob.bytes(photo.key). - Show it. Pass
photo.urlto your screen and use it as an image source. The URL loads only in your miniapp’s own screen, in development as once installed. - Share it.
await session.blob.share(photo.key)opens the share sheet. - Keep it. Copy it under a key of your own:
await session.blob.copy(photo.key, "saved/" + photo.requestId).
Updating from uploaded photos
takePhoto used to upload the photo to Mentra’s cloud and return a photoUrl.
It now needs Mentra App 3.5.0 or later, so set "minHostVersion": "3.5.0" in
your manifest. On an older Mentra
App the call rejects and asks the user to update. Replace reads of photoUrl
with photo.url on screen, or the bytes from session.blob everywhere else.
The transferMethod option is gone: a photo for the phone always comes over
Bluetooth.
Photos during a stream
While the glasses stream video, their camera can’t also take a photo. When the stream passes through the phone (a Teams call in Mentra Call, or a managed stream started withingest: "whip"), takePhoto() returns the stream’s next
video frame instead. The stream doesn’t pause, and any miniapp can do this, not
only the one that started the stream.
The frame differs from a camera photo:
- It has the stream’s resolution and exposure (720p for a Teams call).
size,mode,compressand the exposure options don’t apply. - The glasses play no shutter sound and save nothing to their gallery.
warmUp()returns at once: the camera is already open.
direct stream, which the glasses send
straight to the internet) still rejects takePhoto() with CAMERA_BUSY.
Field of view
setFov applies a temporary FOV/ROI override owned by the calling miniapp and
resolves after the ASG client reports it was applied. It applies to all captures
(photos and video) while that miniapp is active. When the miniapp closes, the host
restores the previous live miniapp override or the persistent base setting. The
factory/missing base is the centered standard preset (102 degrees); existing
saved user values are preserved.
It resolves with a
CameraFovResult:
Errors
Every method returns a promise that rejects with{ code, message } on failure.
Wrap calls in try/catch and read code.
Breaking change: photo compression
Photo compression now accepts exactlynone, low, medium, and high, sent
unchanged across the Mentra Miniapp SDK, Bluetooth SDKs, and glasses.
The default is none everywhere. Glasses encode these as JPEG Q95, Q88, Q78,
and Q60 respectively; size controls dimensions separately. none still uses
lossy JPEG encoding. Unknown values are rejected.
Photo compression is handled by the phone and glasses.
The former heavy spelling is removed; callers must use high. Android’s native
default changes from medium to none. Existing miniapps may therefore produce
different JPEG quality or payload sizes. There are no compatibility aliases or wire translations.
