<a id="exp-camera-interface"></a>

# Camera interface

<!-- @artefact camera interface -->

The camera interface
enables access to the host system’s cameras
and other video capture devices inside the workshop.

By using the interface,
the SDK publisher allows the workshop to access the host’s cameras,
which can be useful in various SDK-specific tasks
such as testing hardware or embedded devices.

<a id="exp-camera-plug"></a>

## Camera interface plug

An essential element here is the camera interface plug,
which is declared in the SDK definition.

Its structure includes just the name of the plug and the interface;
both must be set to `camera`.

Defining the plug in an SDK
allows the workshops using this SDK to connect to the host’s cameras,
which can be useful in various SDK-specific tasks
such as testing hardware or embedded devices.

<a id="exp-camera-slot"></a>

## Camera interface slot

To let SDKs in a workshop access the host’s cameras,
**Workshop** provides a camera interface slot
that multiple camera interface plugs can access.

When the SDK is installed at runtime during launch and refresh operations,
**Workshop** checks that the plug targeting the slot
passes [validation](https://ubuntu.com/workshop/docs//explanation/interfaces/concepts.md#exp-interfaces-validation);
if it does,
it can be connected.

## Connection

The interface isn’t connected automatically at launch and refresh
for security reasons.
The **workshop connect** and **workshop disconnect** commands
can be invoked manually after the workshop has started:

<!-- @artefact workshop connect -->
<!-- @artefact workshop disconnect -->
```console
$ workshop connect ws/camera-sdk:camera
$ workshop disconnect ws/camera-sdk:camera
```

Establishing a connection means
that all existing `video4linux` and `media` devices
will be made available inside the workshop.
While the connection is active,
adding new devices on the host will also make them available inside the workshop,
whereas unplugged devices will also be removed from the workshop.

To check if the interface is connected:

<!-- @artefact workshop connections -->
```console
$ workshop connections --all

  INTERFACE  PLUG              SLOT              NOTES
  ...
  camera     ws/camera:camera  ws/system:camera  manual
```

This means the host’s cameras are available inside the workshop:

<!-- @artefact workshop shell -->
```console
$ workshop shell ws
workshop@ws-8584e571$ ls /dev/video*

  /dev/video0  /dev/video1

workshop@ws-8584e571$ ls /dev/media*

  /dev/media0
```

## See also

Explanation:

- [Interface concepts](https://ubuntu.com/workshop/docs//explanation/interfaces/concepts.md#exp-interface-concepts)
- [Plugs and slots](https://ubuntu.com/workshop/docs//explanation/interfaces/concepts.md#exp-plugs-slots)
- [SDK definition](https://ubuntu.com/workshop/docs//explanation/sdks/concepts.md#exp-sdk-definition)
- [Workshop definition](https://ubuntu.com/workshop/docs//explanation/workshops/concepts.md#exp-workshop-definition)

Reference:

- [workshop connect](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-connect)
- [workshop connections](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-connections)
- [workshop disconnect](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-disconnect)
- [workshop launch](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-launch)
- [workshop refresh](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-refresh)
- [workshop shell](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-shell)
