oursin.camera

Camera

Functions

on_camera_img

Handler for receiving data about incoming images

on_camera_img_meta

Handler for receiving metadata about incoming images

set_brain_rotation

Set the brain's rotation, independent of the camera.

set_light_camera

Change the camera that the main light is linked to (the light will rotate the camera)

set_light_rotation

Override the rotation of the main camera light

setup

Classes

Camera

on_camera_img_meta(data_str)[source]

Handler for receiving metadata about incoming images

Parameters

data_strstring

JSON with two fields {“name”:””, “totalBytes”:””}

on_camera_img(data_str)[source]

Handler for receiving data about incoming images

Parameters

data_strstring

JSON with two fields {“name”:””, “bytes”:””}

class Camera(main=False)[source]

Bases: object

delete()[source]

Deletes camera

Examples

>>>c1.delete()

set_target_coordinate(camera_target_coordinate)[source]

Set the camera target coordinate in CCF space in um relative to CCF (0,0,0), without moving the camera. Coordinates can be negative or larger than the CCF space (11400,13200,8000)

Parameters

camera_target_coordinatefloat list

list of coordinates in ap, ml, dv in um

Examples

>>>c1.set_target_coordinate([500,1500,1000])

set_rotation(rotation)[source]

Set the camera rotation (pitch, yaw, roll). The camera is locked to a target, so this rotation rotates around the target.

Rotations are applied in order: roll, yaw, pitch. This can cause gimbal lock.

Parameters

rotationfloat list OR string

list of euler angles to set the camera rotation in (pitch, yaw, roll) OR string: “axial”, “coronal”, “sagittal”, or “angled”

Examples

>>> c1.set_rotation([0,0,0])
>>> c1.set_rotation("angled")
set_zoom(zoom)[source]

Set the camera zoom.

Parameters

zoomfloat

camera zoom parameter

Examples

>>> c1.set_zoom(1.0)
set_pan(pan_x, pan_y)[source]

Set camera pan coordinates

Parameters

pan_xfloat

x coordinate

pan_yfloat

y coordinate

Examples

>>> c1.set_pan(3.0, 4.0)
set_mode(mode)[source]

Set camera perspective mode

Parameters

modestring

“perspective” or “orthographic” (default)

Examples

>>> c1.set_mode('perspective')
set_background_color(background_color)[source]

Set camera background color

Parameters

background_color : hex color string

Examples

>>> c1.set_background_color('#000000') # black background
set_controllable()[source]

Sets camera to controllable

Examples

>>> c1.set_controllable()
async screenshot(size=[1024, 768], filename='return')[source]

Capture a screenshot, must be awaited

Parameters

sizelist, optional

Size of the screenshot, by default [1024,768]

filename: string, optional

Filename to save to, relative to local path

Examples

>>> await urchin.camera.main.screenshot()
async capture_video(file_name, callback=None, start_rotation=None, end_rotation=None, frame_rate=30, duration=5, size=(1024, 768), test=False)[source]

Capture a video and save it to a file, must be awaited

Can be used in two modes, either by specifying a callback(frame#) or a start/end_rotation

Parameters

file_namestring

_description_

callbackfunction, optional

callback to execute prior to each frame, by default None

start_rotation : [yaw, pitch, roll], optional end_rotation : [yaw, pitch, roll], optional frame_rate : int, optional

frames per second, by default 30

durationint, optional

seconds, by default 5

sizetuple, optional

screenshot size, by default (1024,768)

Examples

>>> await urchin.camera.main.capture_video('output.mp4', callback=my_callback_function)
>>> await urchin.camera.main.capture_video('output.mp4', start_rotation=[22.5, 22.5, 225], end_rotation=[22.5, 22.5, 0])
set_light_rotation(angles)[source]

Override the rotation of the main camera light

Parameters

anglesvector3

Euler angles of light

set_light_camera(camera_name=None)[source]

Change the camera that the main light is linked to (the light will rotate the camera)

Parameters

camera_namestring, optional

Name of camera to attach light to, by default None

set_brain_rotation(yaw)[source]

Set the brain’s rotation, independent of the camera. This is useful when you want to animate a brain rotating for a video. You can set the camera angle you want, and then on each frame update the brain rotation, as needed.

Parameters

yawfloat

Yaw angle for the brain, independent of the camera

setup()[source]