Skip to content

Commit a797d7c

Browse files
committed
added docs
1 parent 09c01ee commit a797d7c

File tree

4 files changed

+114
-30
lines changed

4 files changed

+114
-30
lines changed

README.md

+22-29
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
1-
# DeepLabCut-Live! GUI<img src="https://images.squarespace-cdn.com/content/v1/57f6d51c9f74566f55ecf271/1596193544929-NHMVMXPVEYZ6R4I45DSR/ke17ZwdGBToddI8pDm48kOHwsIwndRGCkvek0XAcW4ZZw-zPPgdn4jUwVcJE1ZvWEtT5uBSRWt4vQZAgTJucoTqqXjS3CfNDSuuf31e0tVH0wqgmu6zkAOZ3crWCtkmLcPIuzHaxU8QRzZwtrVtHupu3E9Ef3XsXP1C_826c-iU/DLCLIVEGUI_LOGO.png?format=750w" width="350" title="DLC-live GUI" alt="DLC LIVE! GUI" align="right" vspace = "50">
1+
# DeepLabCut-Live! GUI
2+
<img src=https://imagizer.imageshack.com/img923/2419/QQKyMH.png align="right" width="250">
3+
<img src="https://images.squarespace-cdn.com/content/v1/57f6d51c9f74566f55ecf271/1596193544929-NHMVMXPVEYZ6R4I45DSR/ke17ZwdGBToddI8pDm48kOHwsIwndRGCkvek0XAcW4ZZw-zPPgdn4jUwVcJE1ZvWEtT5uBSRWt4vQZAgTJucoTqqXjS3CfNDSuuf31e0tVH0wqgmu6zkAOZ3crWCtkmLcPIuzHaxU8QRzZwtrVtHupu3E9Ef3XsXP1C_826c-iU/DLCLIVEGUI_LOGO.png?format=750w" width="350" title="DLC-live GUI" alt="DLC LIVE! GUI" align="right" vspace = "50">
4+
5+
26
GUI to run DeepLabCut-live video feed, record videos, and record external timestamps.
37

4-
## Install
8+
## [Installation Instructions](docs/install.md)
59

6-
Launch **console**:
7-
```bash
8-
conda create -n dlc_live
9-
conda activate dlc_live
10-
conda install python=3.7 tensorflow-GPU==1.13.1
11-
```
10+
## Getting Started
11+
12+
#### Open DeepLabCut-live-GUI
13+
14+
In a terminal, activate the conda or virtual environment where DeepLabCut-live-GUI is installed, then run:
1215

13-
**Install** DLC-Live! GUI **package**:
14-
```bash
15-
pip install deeplabcut-live-gui
1616
```
17-
**Run dlc live gui**:
18-
```bash
1917
dlclivegui
2018
```
2119

22-
## Getting Started
23-
24-
<img src= https://imagizer.imageshack.com/img923/2419/QQKyMH.png align="right">
25-
2620
#### Configurations
2721

28-
First, create a configuration file: select the drop down menu labeled `Config`, and click `Create New Config`. All settings, such as details about cameras, DLC networks, and DLC-live Processors, will be saved into configuration files so that you can close and reopen the GUI without losing all of these details. You can create multiple configuration files on the same system, so that different users can save different camera options, etc on the same computer. To load previous settings from a configuration file, please just select the file from the drop-down menu. Configuration files are stored at `$HOME/Documents/DeepLabCut-live-GUI/config`. These files do not need to be edited manually, they can be entirely created and edited automatically within the GUI.
2922

30-
#### Set Up Cameras <img src= https://imagizer.imageshack.com/img924/626/acJhWD.png align="right">
31-
32-
To setup a new camera, select `Add Camera` from the dropdown menu, and then click `Init Cam`. This will be bring up a new window where you need to select the type of camera (see [Camera Support](docs/Camera Support.md)), input a name for the camera, and click `Add Camera`. This will initialize a new `Camera` entry in the drop down menu. Now, select your camera from the dropdown menu and click`Edit Camera Settings` to setup your camera settings (i.e. set the serial number, exposure, cropping parameters, etc; the exact settings depend on the specific type of camera). Once you have set the camera settings, click `Init Cam` to start streaming. To stop streaming data, click `Close Camera`, and to remove a camera from the dropdown menu, click `Remove Camera`.
23+
First, create a configuration file: select the drop down menu labeled `Config`, and click `Create New Config`. All settings, such as details about cameras, DLC networks, and DLC-live Processors, will be saved into configuration files so that you can close and reopen the GUI without losing all of these details. You can create multiple configuration files on the same system, so that different users can save different camera options, etc on the same computer. To load previous settings from a configuration file, please just select the file from the drop-down menu. Configuration files are stored at `$HOME/Documents/DeepLabCut-live-GUI/config`. These files do not need to be edited manually, they can be entirely created and edited automatically within the GUI.
3324

25+
#### Set Up Cameras <img src= https://imagizer.imageshack.com/img924/626/acJhWD.png align="right">
3426

27+
To setup a new camera, select `Add Camera` from the dropdown menu, and then click `Init Cam`. This will be bring up a new window where you need to select the type of camera (see [Camera Support](docs/camera_support.md)), input a name for the camera, and click `Add Camera`. This will initialize a new `Camera` entry in the drop down menu. Now, select your camera from the dropdown menu and click`Edit Camera Settings` to setup your camera settings (i.e. set the serial number, exposure, cropping parameters, etc; the exact settings depend on the specific type of camera). Once you have set the camera settings, click `Init Cam` to start streaming. To stop streaming data, click `Close Camera`, and to remove a camera from the dropdown menu, click `Remove Camera`.
3528

3629
#### Processor (optional)
3730

@@ -43,7 +36,7 @@ To use your processor in the GUI, you must first add your custom `Processor` dir
4336

4437
<img src= https://imagizer.imageshack.com/img923/9730/MNzr1J.png align="right">
4538

46-
Select the `DeepLabCut` dropdown menu, and click `Add DLC`. This will bring up a new window to choose a name for the DeepLabCut configuration, choose the path to the exported DeepLabCut model, and set DeepLabCut-live settings, such as the cropping or resize parameters. Once configured, click `Update` to add this DeepLabCut configuration to the dropdown menu. You can edit the settings at any time by clicking `Edit DLC Settings`. Once configured, you can load the network and start performing inference by clicking `Start DLC`. If you would like to view the DeepLabCut pose estimation in real-time, select `Display DLC Keypoints`. You can edit the keypoint display settings (the color scheme, size of points, and the likelihood threshold for display) by selecting `Edit DLC Display Settings`.
39+
Select the `DeepLabCut` dropdown menu, and click `Add DLC`. This will bring up a new window to choose a name for the DeepLabCut configuration, choose the path to the exported DeepLabCut model, and set DeepLabCut-live settings, such as the cropping or resize parameters. Once configured, click `Update` to add this DeepLabCut configuration to the dropdown menu. You can edit the settings at any time by clicking `Edit DLC Settings`. Once configured, you can load the network and start performing inference by clicking `Start DLC`. If you would like to view the DeepLabCut pose estimation in real-time, select `Display DLC Keypoints`. You can edit the keypoint display settings (the color scheme, size of points, and the likelihood threshold for display) by selecting `Edit DLC Display Settings`.
4740

4841
If you want to stop performing inference at any time, just click `Stop DLC`, and if you want to remove a DeepLabCut configuration from the dropdown menu, click `Remove DLC`.
4942

@@ -54,11 +47,11 @@ Sessions are defined by the subject name, the date, and an attempt number. Withi
5447
#### Controlling Recording
5548

5649
If the `Ready` button is selected, you can now start a recording by clicking `On`. The `On` button will then turn green indicating a recording is active. To stop a recording, click `Off`. This will cause the `Ready` button to be selected again, as the GUI is prepared to restart the recording and to save the data to the same file. If you're session is complete, click `Save Video` to save all files: the video recording (as .avi file), a numpy file with timestamps for each recorded frame, the DeepLabCut poses as a pandas data frame (hdf5 file) that includes the time of each frame used for pose estimation and the time that each pose was obtained, and if applicable, files saved by the `Processor` in use. These files will be saved into a new directory at `{YOUR_SAVE_DIRECTORY}/{CAMERA NAME}_{SUBJECT}_{DATE}_{ATTEMPT}`
57-
- YOUR_SAVE_DIRECTORY : the directory chosen from the `Directory` dropdown menu.
58-
- CAMERA NAME : the name of selected camera (from the `Camera` dropdown menu).
59-
- SUBJECT : the subject chosen from the `Subject` drowdown menu.
60-
- DATE : the current date of the experiment.
61-
- ATTEMPT : the attempt number chosen from the `Attempt` dropdown.
62-
50+
51+
- YOUR_SAVE_DIRECTORY : the directory chosen from the `Directory` dropdown menu.
52+
- CAMERA NAME : the name of selected camera (from the `Camera` dropdown menu).
53+
- SUBJECT : the subject chosen from the `Subject` drowdown menu.
54+
- DATE : the current date of the experiment.
55+
- ATTEMPT : the attempt number chosen from the `Attempt` dropdown.
56+
6357
If you would not like to save the data from the session, please click `Delete Video`, and all data will be discarded. After you click `Save Video` or `Delete Video`, the `Off` button will be selected, indicating you can now set up a new session.
64-

dlclivegui/camera/tiscamera_linux.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def _convert_image_to_numpy(self):
170170
height = struct.get_value('height')
171171
width = struct.get_value('width')
172172
fmat = struct.get_value('format')
173-
dtype = np.uint8 if fmat == "GRAY16_LE" else np.uint8
173+
dtype = np.uint16 if fmat == "GRAY16_LE" else np.uint8
174174
ncolors = 1 if "GRAY" in fmat else 4
175175

176176
self.frame = np.ndarray(shape=(height, width, ncolors),

docs/camera_support.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## Camera Support
2+
3+
### Windows
4+
5+
- **The Imaging Source USB3 Cameras**: via code based on [Windows code samples](https://github.com/TheImagingSource/IC-Imaging-Control-Samples) provided by The Imaging Source. To use The Imaging Source USB3 cameras on Windows, you must first [install their drivers](https://www.theimagingsource.com/support/downloads-for-windows/).
6+
- **OpenCV compatible cameras**: OpenCV is installed with DeepLabCut-live-GUI, so webcams or other cameras compatible with OpenCV on Windows require no additional installation.
7+
8+
### Linux and NVIDIA Jetson Development Kits
9+
10+
- **OpenCV compatible cameras**: We provide support for many webcams and industrial cameras using OpenCV via Video4Linux drivers. This includes The Imaging Source USB3 cameras (and others, but untested). OpenCV is installed with DeepLabCut-live-GUI.
11+
- **Aravis Project compatible USB3Vision and GigE Cameras**: [The Aravis Project](https://github.com/AravisProject/aravis) supports a number of popular industrial cameras used in neuroscience, including The Imaging Source, Point Grey, and Basler cameras. To use Aravis Project drivers, please follow their [installation instructions](https://github.com/AravisProject/aravis#installing-aravis). The Aravis Project drivers are supported on the NVIDIA Jetson platform, but there are known bugs (e.g. [here](https://github.com/AravisProject/aravis/issues/324)).
12+
13+
### Contributing New Camera Types
14+
15+
Any camera that can be accessed through python (e.g. if the company offers a python package) can be integrated into the DeepLabCut-live-GUI. To contribute, please build off of our [base `Camera` class](../dlclivegui/camera/camera.py), and please use our [currently supported cameras](../dlclivegui/camera) as examples.
16+
17+
New camera classes must inherit our base camera class, and provide at least two arguments:
18+
19+
- id: an arbitrary name for a camera
20+
- resolution: the image size
21+
22+
Other common options include:
23+
24+
- exposure
25+
- gain
26+
- rotate
27+
- crop
28+
- fps
29+
30+
If the camera does not have it's own display module, you can use our Tkinter video display built into the DeepLabCut-live-GUI by passing `use_tk_display=True` to the base camera class, and control the size of the displayed image using the `display_resize` parameter (`display_resize=1` for full image, `display_resize=0.5` to display images at half the width and height of recorded images).
31+
32+
Here is an example of a camera that allows users to set the resolution, exposure, and crop, and uses the Tkinter display:
33+
34+
```python
35+
from dlclivegui import Camera
36+
37+
class MyNewCamera(Camera)
38+
39+
def __init__(self, id="", resolution=[640, 480], exposure=0, crop=None, display_resize=1):
40+
super().__init__(id,
41+
resolution=resolution,
42+
exposure=exposure,
43+
crop=crop,
44+
use_tk_display=True,
45+
display_resize=display_resize)
46+
47+
```
48+
49+
All arguments of your camera's `__init__` method will be available to edit in the GUI's `Edit Camera Settings` window. To ensure that you pass arguments of the correct data type, it is helpful to provide default values for each argument of the correct data type (e.g. if `myarg` is a string, please use `myarg=""` instead of `myarg=None`). If a certain argument has only a few possible values, and you want to limit the options user's can input into the `Edit Camera Settings` window, please implement a `@static_method` called `arg_restrictions`. This method should return a dictionary where the keys are the arguments for which you want to provide value restrictions, and the values are the possible values that a specific argument can take on. Below is an example that restrictions the values for `use_tk_display` to `True` or `False`, and restricts the possible values of `resolution` to `[640, 480]` or `[320, 240]`.
50+
51+
```python
52+
@static_method
53+
def arg_restrictions():
54+
return {'use_tk_display' : [True, False],
55+
'resolution' : [[640, 480], [320, 240]]}
56+
```
57+
58+
In addition to an `__init__` method that calls the `dlclivegui.Camera.__init__` method, you need to overwrite the `dlclivegui.Camera.set_capture_device`, `dlclive.Camera.close_capture_device`, and one of the following two methods: `dlclivegui.Camera.get_image` or `dlclivegui.Camera.get_image_on_time`.
59+
60+
Your camera class's `set_capture_device` method should open the camera feed and confirm that the appropriate settings (such as exposure, rotation, gain, etc.) have been properly set. The `close_capture_device` method should simply close the camera stream. For example, see the [OpenCV camera](../dlclivegui/camera/opencv.py) `set_capture_device` and `close_capture_device` method.
61+
62+
If you're camera has built in methods to ensure the correct frame rate (e.g. when grabbing images, it will block until the next image is ready), then overwrite the `get_image_on_time` method. If the camera does not block until the next image is ready, then please set the `get_image` method, and the base camera class's `get_image_on_time` method will ensure that images are only grabbed at the specified frame rate.
63+
64+
The `get_image` method has no input arguments, but must return an image as a numpy array. We also recommend converting images to 8-bit integers (data type `uint8`).
65+
66+
The `get_image_on_time` method has no input arguments, but must return an image as a numpy array (as in `get_image`) and the timestamp at which the image is returned (using python's `time.time()` function).

docs/install.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Installation Instructions
2+
3+
### Windows or Linux Desktop
4+
5+
We recommend that you install DeepLabCut-live in a conda environment. First, please install Anaconda:
6+
- [Windows](https://docs.anaconda.com/anaconda/install/windows/)
7+
- [Linux](https://docs.anaconda.com/anaconda/install/linux/)
8+
9+
Create a conda environment with python 3.7 and tensorflow:
10+
```
11+
conda create -n dlc-live python=3.7 tensorflow-gpu==1.13.1 # if using GPU
12+
conda create -n dlc-live python=3.7 tensorflow==1.13.1 # if not using GPU
13+
```
14+
15+
Activate the conda environment and install the DeepLabCut-live package:
16+
```
17+
conda activate dlc-live
18+
pip install deeplabcut-live-gui
19+
```
20+
21+
### NVIDIA Jetson Development Kit
22+
23+
First, please refer to our complete instructions for [installing DeepLabCut-Live! on a NVIDIA Jetson Development Kit](https://github.com/DeepLabCut/DeepLabCut-live/blob/master/docs/install_jetson.md).
24+
25+
Next, install the DeepLabCut-live-GUI: `pip install deeplabcut-live-gui`.

0 commit comments

Comments
 (0)