69 |
70 | |
71 | |
72 |
73 | What is the Python Video Annotator?
74 | ------------------------------------
75 |
76 | |
77 | | The **PythonVideoAnnotator** is a graphical application written in python, to analyze videos and create notes for events in the video. It was developed with the aim of helping neuroscience and ethology researchers identify animals’ behaviors based on the information extracted from the video.
78 | |
79 | | Paths, contours and outputs of external devices, like accelerometers, sound recorders, pokes, pressure devices and other sensors can be combined to find classes of events to identify behaviors.
80 | |
81 |
82 |
83 | |
84 |
85 | .. image:: _static/index/project.png
86 | :align: left
87 |
88 | |
89 | |
90 | | Organize your data and work on multiple videos at the same time with the project tree.
91 | |
92 | | Import the output of your scripts, third party applications or external devices, into your project and follow its changes over the time.
93 | |
94 | | On each video you may have associated objects that you can track and compare their properties.
95 | |
96 | |
97 | | Navigate in the video, annotate and modify events with the timeline bar.
98 | |
99 | | Plot the data on the timeline to compare values over the time.
100 | |
101 |
102 | .. image:: _static/index/timeline_small.png
103 |
104 |
105 | |
106 |
107 | .. image:: _static/index/project-directories-tree.png
108 | :align: left
109 |
110 | |
111 | | Access and modify the data easily with the open formats.
112 | |
113 | | The project data is organized in an intuitive structure, and files are saved with open formats like json and csv to garantee the portability of the data.
114 | |
115 | | Modify the project structure by moving the folders around with your filesystem manager.
116 | |
117 | |
118 | | The python video annotator is plugins based which allow to toggle the activation of the ones that are already included or add new ones developed by you.
119 | |
120 | | Validate automatically tracking mistakes and correct them using the tracking modules or the manual correction.
121 | |
122 |
123 | .. image:: _static/index/background-calculator.gif
124 |
125 | .. image:: _static/index/player.png
126 | :class: paddingleft18
127 |
128 | |
129 | | Visualize the tracking information directly on the video player, smooth paths, calculate the videos' backgrounds and much more ...
130 | |
131 |
132 |
133 | Funding
134 | -------------------
135 |
136 | .. image:: _static/index/funding.png
137 |
138 | Thank you!!
139 |
140 | |
141 |
142 | Developers
143 | -------------------
144 |
145 | ================================= ============================================================================================================================================
146 | Ricardo Ribeiro from the `Champalimaud Scientific Software Platform `_
147 | ricardo.ribeiro@research.fchampalimaud.org
148 | Carlos Mão de Ferro from the `Champalimaud Scientific Software Platform `_
149 | carlos.maodeferro@research.fchampalimaud.org
150 | Hugo Cachitas from the `Innate Behavior Lab `_
151 | hugo.cachitas@research.fchampalimaud.org
152 |
153 | Manuel Manso from the `Champalimaud Scientific Software Platform `_
154 | manel.manso@research.fchampalimaud.org
155 | ================================= ============================================================================================================================================
156 |
157 | |
158 | |
--------------------------------------------------------------------------------
/docs/source/modules/calc-background.rst:
--------------------------------------------------------------------------------
1 | .. _backgroundfinder-label:
2 |
3 | Calculate the video background
4 | ===============================
5 |
6 | This module calculates the background image of the video.
7 |
8 | ------------------------
9 | How to use
10 | ------------------------
11 |
12 | | 1. Open the **"Modules"** tab and choose the **"Calculate the video background"** module.
13 | |
14 | | 2. On the left **check** the corresponding checkboxes to select the **video(s)** you want to calculate the background for.
15 | |
16 | | 3. On the right use the sliders to change the parameters of the background calculation:
17 | |
18 | | - **Gaussian blur matrix size** -> changes the size of the blur matrix
19 | | - **Gaussian blur sigma X** -> changes the sigma X of the blur matrix
20 | | - **Jump n frames** -> only does the algorithm described below every n frames
21 | | - **Compare with frame in front** -> compares the current frame with the specified frame
22 | | - **Threshold** -> uses the pixels over the threshold for the image
23 | |
24 | | :ref:`See the workflow of the algorithm ` to better understand what the parameters mean.
25 |
26 | .. note:: **Lower values** for "Jump n frames", "Compare with frame in front" and "Threshold" will result in **more accurate** results
27 |
28 | | 4. Press the **"Apply"** button to calculate the background image.
29 | |
30 |
31 | ------------------------
32 | Result
33 | ------------------------
34 |
35 | The calculated background image will be added to the video as a new image called **"background-0"**.
36 |
37 | |
38 |
39 | .. _algorithmworkflow-label:
40 |
41 | ------------------------
42 | Algorithm
43 | ------------------------
44 |
45 | The algorithm used to calculate the background is described in the next workflow:
46 |
47 | .. image:: /_static/modules/background-module-workflow.png
48 |
49 | |
50 |
51 | ------------------------
52 | Example
53 | ------------------------
54 |
55 | .. image:: /_static/modules/calc-background.gif
--------------------------------------------------------------------------------
/docs/source/modules/distances.rst:
--------------------------------------------------------------------------------
1 |
2 | Distances
3 | ==================================
4 |
5 | This module calculates the distances between two objects, using their paths or contours.
6 |
7 | ------------------------
8 | How to use
9 | ------------------------
10 |
11 | | 1. Open the **"Modules"** tab and choose the **"Distances"** module.
12 | |
13 | | 2. **Check** the corresponding checkboxes to select the **video**, the **two objects** and the **paths/contours of the two objects** between which the distance will be calculated.
14 | |
15 | | 3. Use the **blue slider or the left and right textboxes** to **set a start and an end frame** for the calculation. The distance will only be calculated for the interval you choose.
16 |
17 | .. note ::
18 |
19 | To change the start and end frame you also have to click on the name of the video, **not just the checkbox**
20 |
21 | | 4. Press the **"Apply"** button and you're done.
22 | |
23 |
24 | ------------------------
25 | Result
26 | ------------------------
27 |
28 | The calculated distance will appear under one of the two objects as a new value called: **"distance-between(...)".**
29 |
30 | |
31 |
32 | ------------------------
33 | Example
34 | ------------------------
35 |
36 | .. image:: /_static/modules/distances.gif
--------------------------------------------------------------------------------
/docs/source/modules/estimate-contour-orientation.rst:
--------------------------------------------------------------------------------
1 | Estimate the countour's orientation
2 | ===================================
3 |
4 | This module estimates the countour's orientation.
5 |
6 | ------------------------
7 | How to use
8 | ------------------------
9 |
10 | | 1. Open the **"Modules"** tab and choose the **"Estimate the contours orientation"** module.
11 | |
12 | | 2. On the top part select the video, then the object and finally the object's **contour** that you want to estimate the orientation for.
13 | |
14 | | 3. Use the **blue slider or the left and right textboxes** to **set a start and an end frame** for the estimation of the orientation. The orientation will then only be estimated for the interval you choose.
15 |
16 | .. note ::
17 |
18 | To change the start and end frame you also have to click on the name of the video, **not just the checkbox**
19 |
20 | | 4. Use the **"Minimum steps"** slider to set the minimum steps for the estimation
21 | |
22 | | 5. Use the **"Minimum distance"** slider to set the minimum distance for the estimation
23 | |
24 | | 6. If you want to see all the intermediate values of the estimation, check the **"Create all the intermediate values"** checkbox
25 | |
26 | | 7. Click the **"Apply"** button.
27 | |
28 |
29 | ------------------------
30 | Result
31 | ------------------------
32 |
33 | The contour's value **"angle"** will be automatically updated after running the module. This angle is displayed in the video as the blue line showing the contour's orientation.
34 |
35 | |
36 |
37 | ------------------------
38 | Example
39 | ------------------------
40 |
41 | .. image:: /_static/modules/est-contours-orientation.gif
--------------------------------------------------------------------------------
/docs/source/modules/export-data.rst:
--------------------------------------------------------------------------------
1 |
2 | Export data
3 | ===============================
4 |
5 | This module allow the user to export data to custom csv files.
6 |
7 | ------------------------
8 | How to use
9 | ------------------------
10 |
11 | | 1. Open the **"Modules"** tab and choose the **"Export Data"** module.
12 | |
13 | | 2. For every value you want to export, navigate through the project tree, select that value and click the **"Add"** button on the top left. In the resulting csv file, a column will be generated for each value you add. To remove a value, simply select it on the right side and click the **"Remove"** button on the top.
14 | |
15 | | 3. If the **"Split files by events"** checkbox is selected, then the values will only be exported for the frames during those events.
16 | | If no events are selected, the values during the whole video will be exported. If one or more events are selected, only the values during those events will be exported.
17 | | The output file will also be split in multiple files, where each file will correspond to one of the selected events.
18 | |
19 | | 4. Choose the directory you want to save the csv file in by clicking the **"Open"** button on the bottom right side and then write the name you want the file to have in the **"Output file name"** textbox.
20 | |
21 | | 5. Click the **"Apply"** button to export the data to the output file.
22 |
23 | .. note:: The first column of the csv file will always be the index of the frame the other columns correspond to
24 |
25 | |
26 |
27 | ------------------------
28 | Result
29 | ------------------------
30 |
31 | The module will create a csv file in the chosen directory.
32 |
33 | |
34 |
35 | ------------------------
36 | Example
37 | ------------------------
38 |
39 | .. image:: /_static/modules/export-data.gif
40 |
41 |
--------------------------------------------------------------------------------
/docs/source/modules/export-videos.rst:
--------------------------------------------------------------------------------
1 | Export videos
2 | =======================================
3 |
4 | This module allows the user to generate new videos with the annotations and the object's paths or contours directly drawn on the video.
5 |
6 | ------------------------
7 | How to use
8 | ------------------------
9 |
10 |
11 | | 1. Open the **"Modules"** tab and choose the **"Export Videos"** module.
12 |
13 | .. note:: You can preview the generated video by clicking the video you selected and then clicking on the *'Play'* button under the video player
14 |
15 | | 2. For each tab, choose the settings accordingly to what you want to include in the generated video:
16 | |
17 |
18 | Path
19 | --------------------------------------
20 |
21 | In this tab, the user should select the video over which the annotations and/or the paths will be drawn.
22 |
23 | By checking the **"Draw paths"** checkbox, all the selected paths and contours will be drawn in the generated video.
24 |
25 | Using the blue slider or the left and right textboxes, the user can also select a start and an end time for the video.
26 | The video will then only be generated for the interval between the start and end time.
27 |
28 | .. note ::
29 |
30 | To change the start and end frame you also have to click on the name of the video, **not just the checkbox**
31 |
32 | Circle
33 | --------------------------------------
34 |
35 | To use this tab, you must have selected a dataset(path or contour) in the PATH tab.
36 |
37 | If a contour was selected in the previous tab, a circle will be drawn in the position of the object for the corresponding frame using the contour's area.
38 |
39 | In case you select the checkbox **"Use a fixed size"**, which is mandatory if the selected dataset is a path, a circle with a fixed size will be drawn every frame over the object's position. Use the slider to change the size of the circle.
40 |
41 | Circle color
42 | --------------------------------------
43 |
44 | If any dataset is selected, the drawn circle will use the color of this dataset for each frame.
45 | If instead the checkbox **"Use a fixed color"** is selected, the drawn circle will use the chosen color.
46 | To change the color, simply change the numbers, beware it is in the BGR format (0-255).
47 |
48 | Background
49 | --------------------------------------
50 |
51 | If any image is selected, the video will be generated with the image in the background instead of the frames of the video.
52 |
53 | Draw events
54 | --------------------------------------
55 |
56 | Select the events to be drawn in the exported video.
57 | If the **"Draw titles"** checkbox is select, the titles of the events will be also drawn.
58 |
59 | Split files by events
60 | --------------------------------------
61 |
62 | | In this tab, the user can select to only generate the video during certain moments.
63 | | If no events are selected, the whole video will be generated. If one or more events are selected, the video will only be generated during those events.
64 | | The generated video will also be split in multiple videos, where each video will correspond to one of the selected events.
65 |
66 | |
67 | | 3. Choose the directory you want to save the video in by clicking the **"Open"** button on the bottom right side and then write the name you want the video to have in the **"Output file name"** textbox.
68 | |
69 | | 4. Click the **"Export Video(s)"** button to generate the video.
70 | |
71 |
72 | ------------------------
73 | Result
74 | ------------------------
75 |
76 | The module will generate a video or videos in the chosen directory.
77 |
78 | |
79 |
80 | ------------------------
81 | Example
82 | ------------------------
83 |
84 | .. image:: /_static/modules/export-videos.gif
--------------------------------------------------------------------------------
/docs/source/modules/extract-images.rst:
--------------------------------------------------------------------------------
1 | Extract the contour's images
2 | ===========================================
3 |
4 |
5 | This module generates images by extracting them from a contour.
6 |
7 | ------------------------
8 | How to use
9 | ------------------------
10 |
11 | | 1. Open the **"Modules"** tab and choose the **"Extract the contour's images"** module.
12 | |
13 | | 2. For each tab, choose the settings accordingly to how you want your images to be extracted:
14 | |
15 |
16 |
17 | Extract from contours
18 | --------------------------------------
19 |
20 | In this tab, **check** the corresponding checkboxes to select the **video**, the **object** and the object's **contour** you want to extract the images from.
21 |
22 | Use the **blue slider or the left and right textboxes** to **set a start and an end frame**. The images will only be extracted for the frames in that interval.
23 |
24 | .. note ::
25 |
26 | To change the start and end frame you also have to click on the name of the video, **not just the checkbox**
27 |
28 | Mask
29 | --------------------------------------
30 |
31 | In this tab you can apply diferent masks to the image:
32 |
33 | - to apply a simple mask check **"Apply a mask to the image"**
34 | - to apply a dilated mask check **"Dilate the mask and apply it to the image"** and use the **"Dilate size"** slider to choose the dilation of the mask
35 | - to apply a circular mask check **"Apply a circular mask to the image"** and use the **"Circular radius"** slider to choose the radius of the mask
36 | - to apply the minimum ellipse of the contours as a mask to the image, check **"Apply the min. ellipse as a mask to the image"**
37 | - to apply the minimum rectangle of the contours as a mask to the image, check **"Apply the min. rect as a mask to the image"**
38 |
39 |
40 | Margin, image size and stretch image
41 | --------------------------------------
42 |
43 | In this tab you change the image size, strech the image and change its margins.
44 |
45 | To change the image margins, use the **"Margin size"** slider.
46 |
47 | To set the size of an image, use the **"Image size"** slider to set its size and then check **"Stretch image"** to stretch it. If you change the size of an image, you can also cut its height and/or width. To do this check **"Cut image"** and then use the blue sliders or the left and right textboxes to select the portion of the image that you want.
48 |
49 | .. note ::
50 |
51 | The first slider changes the width and the second one changes the height of the image
52 |
53 |
54 | Rotate images
55 | --------------------------------------
56 |
57 | In this tab you can rotate the extracted images in different ways:
58 |
59 | - if you want the contour in the extracted images to always be facing up, check **"Turn the contour always up"**
60 | - if you want the contour in the extracted images to always be facing down, check **"Turn the contour always down"**
61 | - to rotate all the images using a fixed angle, check **"Use a fixed orientation"** and use the **"Rotate the images using a fixed angle"** slider to set the angle
62 | - to rotate the images using the orientation of another contour, check **"Use the orientation of other contour"** and then choose the other contour by first selecting the correspoding **video**, then the **object** and finally the **contour**
63 |
64 | .. note ::
65 |
66 | You can only use one of these options at the same time
67 |
68 |
69 | Center images
70 | --------------------------------------
71 |
72 | In this tab you can center the images.
73 |
74 | If you want to center the images using another dataset, check **"Use a dataset to center the image"** and then select the dataset by first selecting the correspoding **video**, then the **object** and finally the dataset(path/contour).
75 |
76 | Export images per events
77 | --------------------------------------
78 |
79 | | In this tab you can organize the exported images by events:
80 | | - By checking an event, all the frames during that event will be exported to a folder with the event name.
81 | | - All the frames in which no event occurs or no event is selected will be exported to a folder named **"untagged"**.
82 |
83 | .. note :: Click the **"Reload events"** button if you don't see any events in the **"Events"** tab
84 |
85 | |
86 | | 3. Choose the directory you want to save the generated images in by clicking the **"Open"** button on the bottom right side. A folder with the name of the video will be created in that directory.
87 |
88 | .. note:: If you don't choose a directory, then a folder named **"contour-images"** will be created in your current directory.
89 |
90 | | 4. Click the **"Apply"** button to generate the images.
91 | |
92 |
93 | ------------------------
94 | Result
95 | ------------------------
96 |
97 | The result is a folder in the directory you chose with the name of your video. This folder contains all the images generated by the module. Navigate the folder to find the images, as they will be inside subfolders.
98 |
99 | |
100 |
101 | ------------------------
102 | Example
103 | ------------------------
104 |
105 | .. image:: /_static/modules/extract-images.gif
--------------------------------------------------------------------------------
/docs/source/modules/label-deeplabcut.rst:
--------------------------------------------------------------------------------
1 | .. _label-deeplabcut-label:
2 |
3 | Label DeepLabCut
4 | =================
5 |
6 | This module allows you to label a video according to a DeepLabCut config file. Read more about DeeplabCut here: DeepLabCut_.
7 |
8 | .. _DeepLabCut: https://github.com/AlexEMG/DeepLabCut
9 |
10 |
11 | ------------------------
12 | How to use
13 | ------------------------
14 |
15 | | 1. :ref:`Setup the project. `
16 | |
17 | | 2. :ref:`Import the videos to label from a YAML file. `
18 | |
19 | | 3. :ref:`Label the videos. `
20 | |
21 | | 4. :ref:`Export the labeled videos to a CSV file. `
22 | |
23 |
24 | .. _setup-label:
25 |
26 | ----------------------------
27 | Setup the project
28 | ----------------------------
29 |
30 | **1.** Create a directory for your project. You can name it whatever you want.
31 |
32 | **2.** Create a yaml config file for the project. Put it in the project directory.
33 |
34 | The config file should contain the path to all the videos you want to label, the path to your project directory, the parts you want
35 | to label and the number of frames you want to label. This is an example of how it should be structured: :download:`config file <../_static/modules/config.yaml>`.
36 |
37 | You can download the file and change it to suit your project.
38 |
39 | **3.** Create a directory named **"videos"** inside the project directory.
40 |
41 | **4.** Put all the videos you want to label inside the **"videos"** directory.
42 |
43 | **5.** Create a directory named **"labeled-data"** inside the project directory.
44 |
45 | The parent directory should now look like this:
46 |
47 | .. image:: /_static/modules/deeplabcut-project-directory.png
48 |
49 | **6.** This step is done. Now move to the next step of :ref:`importing the videos. `
50 |
51 | |
52 |
53 | .. _import-YAML-label:
54 |
55 | ---------------------------
56 | Importing from a YAML file
57 | ---------------------------
58 |
59 |
60 | **1.** Open the **"Modules"** tab and choose the **"Label DeepLabCut"** module.
61 |
62 | **2.** Choose the yaml to import from. To do this, click the **"Open"** button to the right of **"YAML to import from"** and then browse your folders until you find the file.
63 |
64 | **3.** Click the **"Import"** button. Now the deeplabcut module will run and extract as many frames from the video as defined in the config file. This might take a while. You can track the progress in the command line. Once it's finished, a message will pop up informing you that the import is finished.
65 |
66 | **4.** This step is done. Now move to the next step of :ref:`labeling the videos. `
67 |
68 | |
69 |
70 | .. _labeling-videos-label:
71 |
72 | ------------------------
73 | Labeling the videos
74 | ------------------------
75 |
76 | Now you should have one or more videos created. Each video should have an object for each of the parts you want to label, and each part should have a path. Your timeline should also have a row for each one of the videos you're labeling.
77 |
78 | Each frame you want to label is represented in the timeline as an event. It should look like a small vertical purple bar.
79 |
80 | **1.** **Select the row** of the video you're about to label in the timeline. In most cases this should be the first row of the timeline. It should become highlighted in blue. Right now, your project should look like this:
81 |
82 | .. image:: /_static/modules/deeplabcut-project.png
83 |
84 | **2.** Now you have to go through each frame, and for each object, select its path, then click the **"Mark Point"** button and then select its location with the **Left Mouse Button**.
85 |
86 | You can do all of this using only the mouse, but to help you be more productive, there are a couple of very useful shortcuts:
87 |
88 | - **U** - Selects the path of the next object and also clicks the **"Mark point"** button.
89 | - **I** - Moves to the next event and also clicks the **"Mark point"** button.
90 | - **O** - If a path is selected, clicks the **"Mark point"** button.
91 |
92 | - **E** - Moves to the next event. If no event is selected, moves to the first event.
93 | - **Q** - Moves to the previous event. If no event is selected, moves to the last event.
94 |
95 | To quickly label, you should either:
96 |
97 | - Label an object in all frames using the **I** shortcut
98 | - Label all object in a frame using the **U** shortcut and then move to the next frame with the **E** shortcut
99 |
100 | .. note:: You can select the color of each object's path, thereby changing the color of its "Mark point" marker on the right side. Simply click on **"Choose a color"** and then select the color you want.
101 |
102 | **3.** To see if you maybe missed labeling one of the frames, you can do this:
103 |
104 | 1. Open the **"Modules"** tab and choose the **"Label DeepLabCut"** module.
105 | 2. Click the **"Check unlabeled frames"** button.
106 | 3. A text file will be created in your current directory. This text file tells you for each video and each part, what frames you still haven't labeled. If a part has no frames specified, then you have labeled that object in every frame.
107 |
108 | **4.** Once you don't have any frames left to label, you can move to the next step of :ref:`exporting to a csv file. `
109 |
110 | |
111 |
112 | .. _exporting-csv-label:
113 |
114 | ------------------------
115 | Exporting to a CSV file
116 | ------------------------
117 |
118 | **1.** Open the **"Modules"** tab and choose the **"Label DeepLabCut"** module.
119 |
120 | **2.** Choose the directory you want the file to be written to. To do this, click the **"Open"** button to the right of **"Output directory"** and then browse your folders to select the one you want.
121 |
122 | **3.** Choose the name you want for csv file. You simply have to write the name in the textbox to the right of **"Output file name"**. The **".csv"** extension will be automatically added to the end.
123 |
124 | **4.** Click the **"Export"** button. The resulting csv file will now be in the directory you chose before.
125 |
126 | **5.** You're done with the labeling of the videos. Now you can use deeplabcut to analyse the resulting csv file.
127 |
128 | |
129 |
130 | ------------------------
131 | Result
132 | ------------------------
133 |
134 | The result will be a csv file for each labeled video. The csv file will look like this:
135 |
136 | .. image:: /_static/modules/deeplabcut-csv-result.png
137 |
138 |
139 |
140 |
141 |
142 | *******************
143 | Install DeepLabCut
144 | *******************
145 |
146 | **for windows and mac:**
147 |
148 | Run the following commands:
149 |
150 | .. code-block:: bash
151 |
152 | pip install deeplabcut
153 | pip install -U wxPython
154 | pip install --ignore-installed tensorflow==1.10
155 |
156 | **for linux:**
157 |
158 | | Go to this link: https://extras.wxpython.org/wxPython4/extras/linux/gtk3/.
159 | | There you will have to choose your linux distribution and the wheel for Python 3.6.
160 | | Then run the commands under, but replace the middle command with whatever fits your linux distribution.
161 | |
162 | | For example, if you have ubuntu 18.04, you will have to run the following commands:
163 |
164 | .. code-block:: bash
165 |
166 | pip install deeplabcut
167 | pip install https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04/wxPython-4.0.4-cp36-cp36m-linux_x86_64.whl
168 | pip install --ignore-installed tensorflow==1.10
--------------------------------------------------------------------------------
/docs/source/modules/motion.rst:
--------------------------------------------------------------------------------
1 |
2 | Motion
3 | ===============================
4 |
5 | | This module calculates the motion of an object, which means,the number of pixels that change from frame to frame for a path or contours.
6 |
7 | ------------------------
8 | How to use
9 | ------------------------
10 |
11 |
12 | | 1. Open the **"Modules"** tab and choose the **"Motion"** module.
13 | |
14 | | 2. On the top part select the video, the object and finally the object's **path or contour** to determine the object you will calculate the motion for.
15 |
16 | .. note:: You can preview the motion calculation by clicking on the name of thevideo you selected and then clicking on the *'Play'* button under the video player
17 |
18 | | 3. Use the blue slider or the left and right textboxes to **select a start and an end frame** for the calculation. The motion will then only be calculated for the specified interval.
19 |
20 | .. note ::
21 |
22 | To change the start and end frame you also have to click on the name of the video, **not just the checkbox**
23 |
24 | | 4. Use the **"Compare with"** selection box to choose how the motion is calculated:
25 | | - **First frame** -> compares the current frame with the first frame
26 | | - **Previous frame** -> compares the current frame with the previous frame (current frame - 1)
27 | | - **Background image** -> compares the current frame with a background image
28 | |
29 | | To create a Background image you can either :ref:`capture a frame ` or use the :ref:`"Calculate the video background" ` module.
30 | |
31 | | 6. Use the **"Threshold"** slider to set the treshold for the motion
32 | |
33 | | 7. Use the **"Radius"** slider to select the radius the motion calculation
34 | |
35 | | 8. Check the **"Show diffs boxes"** if you want the preview to show the pixels that changed in the current frame
36 | |
37 | | 9. Press the **"Apply"** button to calculate the motion.
38 | |
39 |
40 | ------------------------
41 | Result
42 | ------------------------
43 |
44 | | The calculated motion will be added to the contours or path dataset as a new value called **"motion"**.
45 | |
46 |
47 | ------------------------
48 | Example
49 | ------------------------
50 |
51 | .. image:: /_static/modules/motion.gif
--------------------------------------------------------------------------------
/docs/source/modules/path-map.rst:
--------------------------------------------------------------------------------
1 | Path map
2 | ===============================
3 |
4 | This module maps the path of an object.
5 |
6 | ------------------------
7 | How to use
8 | ------------------------
9 |
10 | | 1. Open the **"Modules"** tab and choose the **"Path map"** module.
11 | |
12 | | 2. **Check** the corresponding checkboxes to select the **video**, the **object** and the **path/contour** for which you want to calculate a pathmap.
13 | |
14 | | 3. Use the **blue slider or the left and right textboxes** to **set a start and an end frame** for the calculation. The pathmap will only be calculated for the interval you choose.
15 |
16 | .. note ::
17 |
18 | To change the start and end frame you also have to click on the name of the video, **not just the checkbox**
19 |
20 | | 4. Use the **"Radius"** slider to set the radius size for the object. A bigger radius has a bigger impact in the pathmap. Try different sizes for the radius until you're happy with the resulting pathmap.
21 | |
22 | | 5. Press the **"Apply"** button and you're done.
23 | |
24 |
25 | ------------------------
26 | Result
27 | ------------------------
28 |
29 | | The calculated pathmap will be added to the video as a new image called **"pathmap-1"**.
30 | |
31 |
32 | ------------------------
33 | Example
34 | ------------------------
35 |
36 | .. image:: /_static/modules/pathmap.gif
--------------------------------------------------------------------------------
/docs/source/modules/regionsfilter.rst:
--------------------------------------------------------------------------------
1 | .. regionsfilter-label:
2 |
3 | Filter by regions
4 | ===============================
5 |
6 | This module calculates the distance between an object and a geometry's closest border.
7 |
8 | ------------------------
9 | How to use
10 | ------------------------
11 |
12 |
13 | | 1. Create a geometry, :ref:`here's how `.
14 | |
15 | | 2. Open the **"Modules"** tab and choose the **"Filter by regions"** module.
16 | |
17 | | 3. On the top part select the video, then the object and finally the object's **path or contour** to determine the object used in the distance calculation. On the bottom part select the geometry you want to calculate the distance to.
18 | |
19 | | 4. Use the **blue slider or the left and right textboxes** to **set a start and an end frame** for the calculation. The distance will only be calculated for the interval you choose.
20 |
21 | .. note ::
22 |
23 | To change the start and end frame you also have to click on the name of the video, **not just the checkbox**
24 |
25 | | 5. Click the **"Apply"** button.
26 | |
27 |
28 | ------------------------
29 | Result
30 | ------------------------
31 |
32 | | After running the module, a value with the name **"regions-filter"** will appear under the object to which the path or contour belongs to.
33 | | If we plot this value into the timeline we can see the variation of the object's distance to the border of the selected geometry.
34 |
35 | | For the value of the calculated distance we have that:
36 | |
37 | | - When the distance is **lower than 0** it means the object is **outside the geometry**.
38 | |
39 | | - When the distance is **0** it means the position of the object is **over the geometry border**.
40 | |
41 | | - When the distance is **higher than 0** it means the object is **inside the geometry**.
42 | |
43 |
44 | ------------------------
45 | Example
46 | ------------------------
47 |
48 | .. image:: /_static/modules/filter-by-regions.gif
49 |
--------------------------------------------------------------------------------
/docs/source/modules/smooth.rst:
--------------------------------------------------------------------------------
1 | .. smoothpaths-label:
2 |
3 | Smooth
4 | ===============================
5 |
6 | This module smoothens the data of a value or path using the Savitzky–Golay filter.
7 |
8 | ------------------------
9 | How to use
10 | ------------------------
11 |
12 | | 1. Open the **"Modules"** tab and choose the **"Smooth"** module.
13 | |
14 | | 2. If you want to smoothen the data of a value, first you have to create a value. See how you can create a value :ref:`here `.
15 | |
16 | | 3. **Check** the corresponding checkboxes to select the **video**, the **object** and the **path or value** for which you want to smoothen the data.
17 | |
18 | | 4. Use the **blue slider or the left and right textboxes** to **set a start and an end frame** for the calculation. The data will only be smoothed for the interval you choose.
19 |
20 | .. note ::
21 |
22 | To change the start and end frame you also have to click on the name of the video, **not just the checkbox**
23 |
24 | | 5. Use the **"Window size"** slider to set the Windows size parameter for the Savitzky–Golay filter.
25 | |
26 | | 6. Use the **"Order"** slider to set the Order parameter for the Savitzky–Golay filter.
27 | |
28 | | 7. Use the **"Derivative"** slider to set the Derivative parameter for the Savitzky–Golay filter.
29 | |
30 | | 8. Use the **"Rate"** slider to set the Rate parameter for the Savitzky–Golay filter.
31 |
32 | .. note ::
33 |
34 | To obtain good results, the Window size parameter should be significantly bigger than the Order. You can read more about the Savitky-Golay filter `here `_.
35 |
36 | | 9. Press the **"Apply"** button and you're done.
37 | |
38 |
39 | ------------------------
40 | Result
41 | ------------------------
42 |
43 | | The value or the path used in the module will have its data automatically smoothed after running the module. To see the results you can :ref:`display the value/path on the timeline `.
44 | |
45 |
46 | ------------------------
47 | Example
48 | ------------------------
49 |
50 | .. image:: /_static/modules/smooth.gif
51 |
--------------------------------------------------------------------------------
/docs/source/user-docs/howto/index.rst:
--------------------------------------------------------------------------------
1 | .. _howto-label:
2 |
3 | ************
4 | How to
5 | ************
6 |
7 | |
8 |
9 | ---------------
10 | Project
11 | ---------------
12 |
13 | By default the application opens with an empty project so you can start adding videos immediately.
14 |
15 |
16 |
17 |
18 | Open a project
19 | ===============
20 |
21 | To open a existing project select the option **"Open"** in the **"File"** menu of the main window.
22 | A new window will appear asking for the project folder. You should select the folder and press open.
23 |
24 | .. seealso:: Find information about the project folders structure in the :ref:`Project tree ` section.
25 |
26 | Save a project
27 | ===============
28 |
29 | It is possible to save a project by using the options **"Save"** or **"Save as"** in the **"File"** menu of the main window.
30 |
31 | Save
32 | -------------
33 |
34 | Update the current project files with the last changes.
35 |
36 | .. note:: If you are saving the project for the first time, this option will behave like the **"Save as"** option.
37 |
38 | Save as
39 | -------------
40 |
41 | Save or export the current project into a folder.
42 |
43 | .. note:: The user should choose an empty directory to avoid mixing the project files with pre existing files and directories.
44 |
45 |
46 | Add a video
47 | ===============
48 |
49 | .. image:: /_static/howto/add-video.png
50 |
51 | **Result:**
52 |
53 | .. image:: /_static/howto/add-video-result.png
54 |
55 |
56 |
57 | |
58 | |
59 | |
60 | |
61 |
62 |
63 | ---------------
64 | Video
65 | ---------------
66 |
67 | You can right click a video to be able to add objects, geomtries, notes and images to it. You can also capture the current frame or remove the video.
68 |
69 | |
70 |
71 | .. _addgeometry-label:
72 |
73 | Add & edit a geometry
74 | ==============================
75 |
76 | A geometry is used to define a region or a static object in the video. The geometries created will be displayed on top of the video. To edit a geometry, simply click on the **"Edit"** button on the right side of the window.
77 |
78 |
79 | .. image:: /_static/howto/add-geometry.png
80 |
81 | .. image:: /_static/howto/add-geometry-edit.png
82 |
83 | Drawing geometries
84 | ------------------------
85 |
86 | To draw a geometry, you should first select the type of geometry you would like to draw (Square or Cicle). Then, simply drag the mouse over the video to draw the polygon. You can zoom in and out using the mouse wheel.
87 |
88 | The **polygon points can be moved**, by dragging and dropping the selected point, or **deleted** by pressing the delete key on the keyboard. Once you're done, press **"Apply"** to confirm your changes.
89 |
90 |
91 | .. image:: /_static/howto/add-geometry-edit-poly.png
92 |
93 | **Example:** Drawing a circle
94 |
95 | .. image:: /_static/howto/add-geometry-edit-draw-circle.gif
96 |
97 |
98 | |
99 |
100 | .. _captureframe-label:
101 |
102 | Capture a frame
103 | ===============
104 |
105 | The next step can be used to capture the current frame into an image.
106 |
107 | .. image:: /_static/howto/add-capture.png
108 |
109 | **Result:**
110 |
111 | .. image:: /_static/howto/add-capture-result.png
112 |
113 | |
114 |
115 | .. _add_objects-label:
116 |
117 | Add an object
118 | ===============
119 |
120 | An object is something in the video whose properties change over time.
121 |
122 | .. image:: /_static/howto/add-object.png
123 |
124 | .. _add_dataset-label:
125 |
126 | Add a dataset
127 | ------------------------
128 |
129 | A dataset is an object's property that changes over time. There are 3 types of properties that you can add: **Paths**, **Countours** or **Values**.
130 |
131 | .. seealso:: Find more information about the datasets in the :ref:`Objects’ datasets ` section.
132 |
133 | To add a dataset right click over the object and select one of the available options.
134 |
135 | .. image:: /_static/howto/add-datasets.png
136 |
137 | Path
138 | -----------
139 |
140 | A path dataset stores information about an object's path.
141 |
142 | Contours
143 | -----------
144 |
145 | A contours dataset stores information about the object' contour over time, but it also has information about the object's path.
146 |
147 | Value
148 | -----------
149 |
150 | This property stores any arbitrary number that can change over time. It can be used to store external data like for example hardware triggers.
151 |
152 |
153 | * **Import data from a CSV file**
154 |
155 | |
156 |
157 | Right click over the value object in the project tree, and select the option **import**.
158 |
159 | .. image:: /_static/howto/import-value-from-csvfile-step1.png
160 |
161 | |
162 |
163 | Choose the file, remove the file header (if it exists) using the starting row field and select the separator character.
164 | You will see a preview of the parsing of the file to import.
165 |
166 | Then select the column corresponding to the number of the frame and to the value you would like to import. If the field **Frame** has the value -1 then it will be considered that the row number N corresponds to the N frame.
167 |
168 | |
169 |
170 | .. image:: /_static/howto/import-value-from-csvfile-step2.png
171 |
172 | |
173 | |
174 |
175 |
176 | * **Display the value in the timeline**
177 |
178 | |
179 |
180 | Right click **"value"** and select the option **view on the timeline**.
181 |
182 | .. image:: /_static/howto/send-value-to-timeline.png
183 |
184 | |
185 |
186 | **Result:**
187 |
188 | .. image:: /_static/howto/send-value-to-timeline-result.png
--------------------------------------------------------------------------------
/docs/source/user-docs/install_and_run/index.rst:
--------------------------------------------------------------------------------
1 | .. _installing-label:
2 |
3 | ****************
4 | Install and Run
5 | ****************
6 |
7 | |
8 |
9 | Quickest installation
10 | ______________________
11 |
12 |
13 | Installing
14 | -----------
15 |
16 |
17 | 1. Install Python 3.6 from [python.org](https://www.python.org/) or use the Anaconda [Anaconda](https://www.anaconda.com/) Python version.
18 |
19 | 2. Install pypi from [pypi.org](https://pypi.org/)
20 |
21 | 3. Install PythonVideoAnnotator from Pypi:
22 |
23 | .. code-block:: bash
24 |
25 | pip install python-video-annotator
26 |
27 |
28 | Running
29 | -----------
30 |
31 | 1. Execute pythonvideoannotator:
32 |
33 | .. code-block:: bash
34 |
35 | start-video-annotator
36 |
37 | |
38 |
39 | For developers
40 | ______________
41 |
42 |
43 | Installing
44 | -----------
45 |
46 | Download the source code and install it:
47 |
48 | **for ubuntu, mac and windows:**
49 |
50 | .. code-block:: bash
51 |
52 | git clone --recursive https://github.com/UmSenhorQualquer/pythonVideoAnnotator.git
53 | cd pythonVideoAnnotator
54 | python utils/install.py
55 |
56 | |
57 |
58 |
59 | Running
60 | -----------
61 |
62 | Run this command:
63 |
64 | .. code-block:: bash
65 |
66 | start-video-annotator
67 |
68 | Or these commands:
69 |
70 |
71 | .. code-block:: bash
72 |
73 | source activate videoannotator
74 | python -m pythonvideoannotator
75 |
--------------------------------------------------------------------------------
/docs/source/user-docs/shortcuts/index.rst:
--------------------------------------------------------------------------------
1 | .. _shortcuts-label:
2 |
3 | ***************
4 | Shortcuts keys
5 | ***************
6 |
7 | This is a list of useful shortcuts for the application.
8 | The list shows the button used for the shortcut along with an explanation of what the shortcut does.
9 |
10 |
11 | TIMELINE
12 | ________
13 |
14 | ========================================================================== =================================
15 | EVENT SHORT KEYS
16 | ========================================================================== =================================
17 | Move the end of the selected event to the left. Alt+Shift+Num+Left
18 | Move the end of the selected event to the right. Alt+Shift+Num+Right
19 | Move the begin of the selected event to the left. Ctrl+Alt+Num+Left
20 | Move the begin of the selected event to the right. Ctrl+Alt+Num+Right
21 | Move the selected event to the left. Alt+Num+Left
22 | Move the selected event to the right. Alt+Num+Right
23 | Move the selected event to the track above. Alt+Num+Up
24 | Move the selected event to the track bellow. Alt+Num+Down
25 | Delete the selected event. Alt+Del
26 | Open or close a new event. Alt+C
27 | Lock or unlock the selected event. Alt+L
28 | Select the first event. Alt+Q
29 | Select the last event. Alt+D
30 | Select the next event. Alt+D
31 | Select the previous event. Alt+A
32 | ========================================================================== =================================
33 |
34 |
35 | PLAYER
36 | ________
37 |
38 | ========================================================================== =================================
39 | EVENT SHORT KEYS
40 | ========================================================================== =================================
41 | Play or pause the video. Ctrl+P
42 | Jumps 1 frame backward. Ctrl+I
43 | Jumps 1 frame forward. Ctrl+O
44 | Jumps 20 seconds backward. Ctrl+K
45 | Jumps 20 seconds forward. Ctrl+L
46 | Set player speed to 1x. Ctrl+1
47 | Set player speed to 2x. Ctrl+2
48 | Set player speed to 3x. Ctrl+3
49 | Set player speed to 4x. Ctrl+4
50 | Set player speed to 5x. Ctrl+5
51 | Set player speed to 6x. Ctrl+6
52 | Set player speed to 7x. Ctrl+7
53 | Set player speed to 8x. Ctrl+8
54 | Set player speed to 9x. Ctrl+9
55 | ========================================================================== =================================
56 |
57 |
--------------------------------------------------------------------------------
/docs/source/user-docs/timeline/index.rst:
--------------------------------------------------------------------------------
1 | |
2 |
3 | Timeline
4 | ===============
5 |
6 | |
7 |
8 | .. image:: /_static/timeline/timeline.png
9 | :align: center
10 |
11 | The timeline events
12 | __________________________________________
13 |
14 | |
15 |
16 | - Create a new event:
17 | - double-click on the track and time you wish to add a new event.
18 | - Rename the event label:
19 | - double-click over the event.
20 | - Resize the event:
21 | - drag the left and right side of the box until you reach the desired size.
22 | - Change the event color:
23 | - right click over the event and choose the option "pick a color".
24 | - Lock the edition of an event:
25 | - right click over the event and choose the option "lock".
26 | - Remove an event:
27 | - right click over the event and choose the option "remove".
28 |
29 | |
30 |
31 | **Example:** Creating, editing and deleting a note
32 |
33 | .. image:: /_static/timeline/add-and-edit-note.gif
34 |
35 | |
36 |
37 | Add and edit the properties of a row
38 | __________________________________________
39 |
40 | |
41 | | With the mouse over a row, click on the right mouse button and choose the option **"Row properties"**. A new window will appear.
42 | | On this window you can set the label for the row and the color that the new events will have.
43 | |
44 |
45 | **Example:** Adding and editing rows
46 |
47 | .. image:: /_static/timeline/add-and-edit-rows.gif
48 |
49 | |
50 |
51 | .. _show_dataset_timeline-label:
52 |
53 | Show a dataset property on the timeline
54 | __________________________________________
55 |
56 | |
57 | | On the project's tree select the dataset property you want to graph on the timeline, press the right button of the mouse and select the option **"View on the timeline"**. The graph of the property will then be shown on the timeline.
58 |
59 | .. image:: /_static/timeline/send-2-timeline.png
60 |
61 | **Result**:
62 |
63 | .. image:: /_static/timeline/graph-on-timeline.png
64 |
65 | |
66 |
67 | Import & export events
68 | __________________________________________
69 |
70 | Use the buttons on the bottom right side to export events to a csv file or import graphs, events or bonsai events files.
71 |
72 | |
73 |
74 | Edit the graph's properties
75 | __________________________________________
76 |
77 | |
78 | | Press the right mouse button and select the **"Graphs"** option to access the graphs' properties windows.
79 | | On this windows it's possible to edit the graphs' names and their displays.
80 | |
81 | | Also, you can use this window to visualize the value of a graph at a certain point in time. Just select the graph and as you pass the mouse over the timeline, the value of the graph at a certain frame will be displayed on the window.
82 | |
83 |
84 | .. image:: /_static/timeline/graphs-properties.png
85 |
86 | |
87 |
88 | Convert graphs to events
89 | __________________________________________
90 |
91 | |
92 | | Right click the timeline and select the option **"Convert graphs to events"**.
93 | |
94 | | A new window will be shown. On the left-side list, double click on the graph you would like to use for the equation, and write the rest of it.
95 | |
96 | | Use the fields **Event name** to define the name of the new events, use the **row number** field to define the row where the events should be created, and the **Minimum number of frames** to define the necessary number of consecutive frames where the equation is verified to create the events.
97 | |
98 |
99 | Equation example:
100 |
101 | .. code-block:: python
102 |
103 | [Deeplearning result]>0.5 and [value(6)]<10
104 |
105 | .. note:: Use spaces only between logic operators: **and** or **or**.
106 |
107 | |
108 |
109 | **1.** Right click the timeline and choose the option **"Convert graphs to events"**
110 |
111 | .. image:: /_static/timeline/convert-graphs-2-events.png
112 |
113 | **2.** Write the equation
114 |
115 |
116 | **3.** Choose the name for the events, the minimum number of frames and the row they will be displayed in
117 |
118 | .. image:: /_static/timeline/convert-graphs-2-events-window.png
--------------------------------------------------------------------------------
/docs/source/user-docs/update/index.rst:
--------------------------------------------------------------------------------
1 | .. _update-label:
2 |
3 | ****************
4 | Update
5 | ****************
6 |
7 | If there is a newer version of Pythonvideoannotator available, a window like this one will appear when you run the application:
8 |
9 | .. image:: /_static/howto/update.png
10 |
11 | Simply click the **"Yes"** button and wait for the update to complete.
--------------------------------------------------------------------------------
/docs/youtube.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/video-annotator/pythonvideoannotator/dacba887d289ab254f8cc3a56eaff9465704b010/docs/youtube.png
--------------------------------------------------------------------------------
/libraries/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/video-annotator/pythonvideoannotator/dacba887d289ab254f8cc3a56eaff9465704b010/libraries/__init__.py
--------------------------------------------------------------------------------
/plugins/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/video-annotator/pythonvideoannotator/dacba887d289ab254f8cc3a56eaff9465704b010/plugins/__init__.py
--------------------------------------------------------------------------------
/readthedocs.yml:
--------------------------------------------------------------------------------
1 | # http://docs.readthedocs.io/en/latest/yaml-config.html
2 |
3 | python:
4 | version: 3
5 |
6 | # Build PDF & ePub
7 | formats:
8 | - epub
9 | - pdf
10 |
11 | requirements_file: requirements-rtd.txt
--------------------------------------------------------------------------------
/requirements-rtd.txt:
--------------------------------------------------------------------------------
1 | # 3rd party dependencies
2 | numpy
3 |
4 | # rtd dependencies
5 | sphinx==1.5.6
6 | sphinx_rtd_theme>=0.2.4
7 | recommonmark
8 |
9 | # swp dependencies
10 | https://bitbucket.org/fchampalimaud/logging-bootstrap/get/master.zip
--------------------------------------------------------------------------------
/utils/deeplab.yml:
--------------------------------------------------------------------------------
1 | name: videoannotator
2 | channels:
3 | - anaconda
4 | - conda-forge
5 | - defaults
6 | dependencies:
7 | - atk=2.25.90=hb9387b2_1
8 | - blas=1.0=mkl
9 | - bzip2=1.0.6=h6d464ef_2
10 | - ca-certificates=2019.3.9=hecc5488_0
11 | - certifi=2019.3.9=py36_0
12 | - ffmpeg=3.4=h7264315_0
13 | - fontconfig=2.12.4=h88586e7_1
14 | - freetype=2.8=hab7d2ae_1
15 | - gettext=0.19.8.1=hc5be6a0_1002
16 | - glib=2.55.0=h464dc38_2
17 | - gobject-introspection=1.55.0=py36h3a3fb3b_0
18 | - graphite2=1.3.10=hc526e54_0
19 | - gst-plugins-base=1.8.0=0
20 | - gstreamer=1.8.0=1
21 | - hdf5=1.10.2=hba1933b_1
22 | - icu=58.2=h9c2bf20_1
23 | - jasper=1.900.1=4
24 | - jpeg=9b=h024ee3a_2
25 | - libedit=3.1=heed3624_0
26 | - libffi=3.2.1=hd88cf55_4
27 | - libgcc-ng=8.2.0=hdf63c60_1
28 | - libgfortran=3.0.0=1
29 | - libgfortran-ng=7.2.0=h9f7466a_2
30 | - libglu=9.0.0=hf484d3e_1000
31 | - libiconv=1.15=h516909a_1005
32 | - libopus=1.2.1=hb9ed12e_0
33 | - libpng=1.6.32=hbd3595f_4
34 | - libprotobuf=3.6.0=hdbcaa40_0
35 | - libstdcxx-ng=8.2.0=hdf63c60_1
36 | - libtiff=4.0.9=h28f6b97_0
37 | - libvpx=1.6.1=h888fd40_0
38 | - libxcb=1.12=hcd93eb1_4
39 | - libxml2=2.9.4=h2e8b1d7_6
40 | - llvm=3.3=0
41 | - mesa=10.5.4=0
42 | - ncurses=6.0=h9df7e31_2
43 | - openssl=1.0.2r=h14c3975_0
44 | - pcre=8.41=hc27e229_1
45 | - pip=19.0.3=py36_0
46 | - pixman=0.34.0=hceecf20_3
47 | - python=3.6.4=hc3d631a_1
48 | - readline=7.0=ha6073c6_4
49 | - sqlite=3.20.1=hb898158_2
50 | - system=5.8=2
51 | - tk=8.6.7=hc745277_3
52 | - wxpython=4.0.1=py36_0
53 | - xz=5.2.3=h55aa19d_2
54 | - zlib=1.2.11=ha838bed_2
55 | - pip:
56 | - absl-py==0.7.1
57 | - anyqt==0.0.10
58 | - astor==0.7.1
59 | - chardet==3.0.4
60 | - click==7.0
61 | - cloudpickle==0.8.1
62 | - confapp==1.0.1
63 | - cycler==0.10.0
64 | - dask==1.1.4
65 | - decorator==4.4.0
66 | - deeplabcut==2.0.5.1
67 | - easydict==1.9
68 | - gast==0.2.2
69 | - grpcio==1.19.0
70 | - h5py==2.9.0
71 | - icc-rt==2019.0
72 | - idna==2.8
73 | - imageio==2.3.0
74 | - intel-numpy==1.14.3
75 | - intel-openmp==2019.0
76 | - ipython==6.0.0
77 | - ipython-genutils==0.2.0
78 | - jedi==0.13.3
79 | - keras-applications==1.0.7
80 | - keras-preprocessing==1.0.9
81 | - kiwisolver==1.0.1
82 | - markdown==3.1
83 | - matplotlib==3.0.3
84 | - mkl==2019.0
85 | - mkl-fft==1.0.6
86 | - mkl-random==1.0.1
87 | - mock==2.0.0
88 | - moviepy==0.2.3.5
89 | - networkx==2.2
90 | - numexpr==2.6.9
91 | - numpy==1.14.6
92 | - opencv-python==3.4.1.15
93 | - pandas==0.21.0
94 | - parso==0.3.4
95 | - patsy==0.5.1
96 | - pbr==5.1.3
97 | - pexpect==4.6.0
98 | - pickleshare==0.7.5
99 | - pillow==5.4.1
100 | - prompt-toolkit==1.0.15
101 | - protobuf==3.7.1
102 | - ptyprocess==0.6.0
103 | - public==2019.3.22
104 | - pygments==2.3.1
105 | - pyopengl==3.1.0
106 | - pyparsing==2.3.1
107 | - pypi-xmlrpc==2019.3.22
108 | - pypubsub==4.0.3
109 | - pyqt5==5.12.1
110 | - pyqt5-sip==4.19.15
111 | - python-dateutil==2.7.3
112 | - pytz==2018.9
113 | - pywavelets==1.0.2
114 | - pyyaml==5.1
115 | - qscintilla==2.11.1
116 | - requests==2.21.0
117 | - ruamel-yaml==0.15.0
118 | - scikit-image==0.14.2
119 | - scikit-learn==0.19.2
120 | - scipy==1.1.0
121 | - send2trash==1.5.0
122 | - setuptools==39.1.0
123 | - simplegeneric==0.8.1
124 | - simplejson==3.16.0
125 | - six==1.12.0
126 | - sklearn==0.0
127 | - statsmodels==0.9.0
128 | - tables==3.5.1
129 | - tensorboard==1.10.0
130 | - tensorflow==1.13.1
131 | - tensorflow-estimator==1.13.0
132 | - termcolor==1.1.0
133 | - toolz==0.9.0
134 | - tqdm==4.31.1
135 | - traitlets==4.3.2
136 | - urllib3==1.24.1
137 | - visvis==1.11.2
138 | - wcwidth==0.1.7
139 | - werkzeug==0.15.1
140 | - wheel==0.33.1
141 | prefix: /home/manuel/anaconda3/envs/deeplab
142 |
143 |
--------------------------------------------------------------------------------
/utils/deploy-pypi.py:
--------------------------------------------------------------------------------
1 | import os, shutil
2 | import xmlrpc.client
3 | from subprocess import Popen, PIPE
4 | from setuptools import find_packages
5 | from natsort import natsorted
6 |
7 | ###### CONFIGURATIONS #############################
8 | HEADER = '\033[95m'
9 | OKBLUE = '\033[94m'
10 | OKGREEN = '\033[92m'
11 | WARNING = '\033[93m'
12 | FAIL = '\033[91m'
13 | ENDC = '\033[0m'
14 | BOLD = '\033[1m'
15 | UNDERLINE = '\033[4m'
16 |
17 | DEBUG = False
18 | DEPLOY = True
19 |
20 | if DEBUG:
21 | PYPI_URL = 'https://test.pypi.org'
22 | else:
23 | PYPI_URL = 'https://pypi.org'
24 |
25 | # Dictionary with the correspondence of the libraries and folders.
26 | PACKAGES = { 'pyforms-gui': 'pyforms_gui' }
27 | PACKAGES_TO_IGNORE = [
28 | 'confapp'
29 | ]
30 |
31 | PACKAGES_TO_IGNORE_FOR_REQUIREMENTS = [
32 | 'confapp',
33 | 'python-video-annotator-module-idtrackerai'
34 | ]
35 |
36 |
37 | # sub packages directories to look for updates
38 | DIRECTORIES_TO_SEARCH_FORM = [
39 | os.path.join('libraries'),
40 | os.path.join('base'),
41 | os.path.join('plugins'),
42 | ]
43 |
44 | MAIN_NAME = 'pythonvideoannotator' # main package name
45 | MAIN_PATH = os.path.join('base', MAIN_NAME) # main package path
46 | MAIN_REPO = 'python-video-annotator' # name of the main package on pypi
47 |
48 | APP_DIRECTORY = os.getcwd() # current directory
49 |
50 | ####################################################
51 |
52 | pypi = xmlrpc.client.ServerProxy(PYPI_URL)
53 |
54 | # make sure all the packages required to deploy to pypi are installed
55 | Popen(['pip','install','--upgrade','setuptools','wheel','twine']).communicate()
56 |
57 |
58 | def version_compare(a, b):
59 | """
60 | Compare versions
61 | :param a: Version a
62 | :param b: Version b
63 | :return: Returns 0 if equal, returns 1 if a>b, returns -1 if b>a
64 | """
65 | if a == b: return 0
66 | versions = natsorted([a, b])
67 | if a==versions[-1]: return -1
68 | if b==versions[-1]: return 1
69 | raise Exception('Error when comparing versions')
70 |
71 |
72 |
73 | def update_package_version(package_name, setup_path, new_version):
74 | """
75 | Update the version of the package
76 |
77 | :param str package_name: Package name.
78 | :param str setup_path: Path of the setup.py file.
79 | :param str new_version: The new version to update.
80 | :return:
81 | """
82 | if package_name in PACKAGES:
83 | package = PACKAGES[package_name]
84 | else:
85 | packages = find_packages(where=setup_path)
86 | package = packages[0]
87 |
88 | package_path = os.path.join(setup_path, package)
89 | init_path = os.path.join(package_path, '__init__.py')
90 |
91 | with open(init_path) as infile: text = infile.read()
92 | try:
93 | begin = text.index('__version__')
94 | end = text.index('\n', begin)
95 | text = text.replace( text[begin:end], f'__version__ = "{new_version}"')
96 | except ValueError:
97 | text = text + f'\n__version__ = "{new_version}"'
98 |
99 | with open(init_path, 'w') as outfile: outfile.write(text)
100 |
101 |
102 |
103 | def check_version_and_upload(dir_path):
104 | """
105 | Check the package version and decide if should be updated or not.
106 | :param str dir_path: Path of the package.
107 | """
108 | os.chdir(dir_path)
109 |
110 | try:
111 | shutil.rmtree(os.path.join(dir_path, 'build'))
112 | except OSError:
113 | pass
114 | except Exception as e:
115 | print(e)
116 | try:
117 | shutil.rmtree(os.path.join(dir_path, 'dist'))
118 | except OSError:
119 | pass
120 | except Exception as e:
121 | print(e)
122 |
123 | local_version = Popen(["python", 'setup.py', '--version'], stdout=PIPE).stdout.read()
124 | local_version = local_version.strip().decode().strip()
125 |
126 | package_name = Popen(["python", 'setup.py', '--name'], stdout=PIPE).stdout.read()
127 | package_name = package_name.strip().decode().replace(' ', '-')
128 | package_name = package_name.replace('---', '-').lower()
129 |
130 | if package_name in PACKAGES_TO_IGNORE:
131 | os.chdir(APP_DIRECTORY)
132 | return False, package_name, local_version
133 |
134 | tmp = pypi.package_releases(package_name)
135 | remote_version = tmp[0] if tmp else 'None'
136 |
137 | tagged_version = Popen(["git", "describe", "--tags"], stdout=PIPE).stdout.read()
138 | tagged_version = tagged_version.strip().decode().split('-')
139 | tagged_version = tagged_version[0]
140 |
141 | print(f"{OKGREEN}{package_name:<65} {local_version:<25} {tagged_version:<25} {remote_version:<25}{ENDC}")
142 |
143 | #git_tag = Popen(["git", 'tag'], stdout=PIPE).stdout.read()
144 | #if git_tag == f'v{new_version}':
145 | # return
146 |
147 | updated = False
148 |
149 | if remote_version=='None' or version_compare(tagged_version, remote_version) < 0:
150 | print(OKBLUE+f'\tUPLOADING TO PYPI\t\t[{package_name}]', ENDC)
151 |
152 | update_package_version(package_name, dir_path, tagged_version)
153 |
154 | if os.path.isdir('./dist'): shutil.rmtree('./dist')
155 |
156 | Popen(['python', 'setup.py', 'sdist', 'bdist_wheel'], stdout=PIPE).communicate()
157 |
158 | ######################################################################################
159 | # DEPLOY TO PYPI #####################################################################
160 | ######################################################################################
161 | if DEPLOY:
162 | if not DEBUG:
163 | Popen(['twine', 'upload', os.path.join('dist','*')]).communicate()
164 | else:
165 | Popen(['twine', 'upload', '--repository', 'pypitest', os.path.join('dist', '*'), '--verbose']).communicate()
166 | ######################################################################################
167 |
168 | """
169 | remote_version = pypi.package_releases(package_name)
170 | if version_compare(new_version, remote_version[0])==0:
171 | Popen(['git', 'add', '--all']).communicate()
172 | Popen(['git', 'commit', '-m', '"upload to pypi"']).communicate()
173 | Popen(['git', 'tag', '-a', f'v{new_version}', '-m', 'generated with deploy-pypi.py script']).communicate()
174 | """
175 | updated = True
176 |
177 | os.chdir(APP_DIRECTORY)
178 |
179 | remote_version = pypi.package_releases(package_name)
180 | remote_version_str = remote_version[0] if remote_version else 'None'
181 |
182 | return updated, package_name, tagged_version
183 |
184 |
185 | # List of requirements
186 | requirements = []
187 |
188 | for search_dir in DIRECTORIES_TO_SEARCH_FORM:
189 | print(
190 | BOLD+HEADER+"\n{:<65} {:<25} {:<25} {:<25}".format('PACKAGE', 'LOCAL', 'TAGGED VERSION', 'REMOTE')+ENDC
191 | )
192 |
193 | for dir_name in os.listdir(search_dir):
194 |
195 | dir_path = os.path.abspath(os.path.join(search_dir, dir_name))
196 |
197 | # is not a directory or is the main repository
198 | if not os.path.isdir(dir_path) or MAIN_NAME==dir_name: continue
199 |
200 | setup_filepath = os.path.join(dir_path, 'setup.py')
201 | if not os.path.isfile(setup_filepath): continue
202 |
203 | updated, package_name, version = check_version_and_upload(dir_path)
204 |
205 | if package_name != MAIN_REPO and package_name not in PACKAGES_TO_IGNORE_FOR_REQUIREMENTS:
206 | requirements.append("{module}=={version}".format(module=package_name, version=version))
207 |
208 |
209 | #### UPDATE REQUIREMENTS IN THE MAIN SETUP.PY ##################
210 | with open( os.path.join(MAIN_PATH, 'setup.py') ) as infile: text = infile.read()
211 | begin = text.index('# REQUIREMENTS BEGIN')
212 | end = text.index('# REQUIREMENTS END', begin)+len('# REQUIREMENTS END')
213 | new_text = """# REQUIREMENTS BEGIN
214 | REQUIREMENTS = [
215 | "{}"
216 | ]
217 | # REQUIREMENTS END""".format('",\n\t"'.join(requirements))
218 | text = text.replace(text[begin:end], new_text)
219 | with open( os.path.join(MAIN_PATH, 'setup.py'), 'w' ) as outfile: outfile.write(text)
220 | #### END UPDATE REQUIREMENTS ###################################
221 |
222 | #### UPDATE THE MAIN PACKAGE ##################
223 | updated, package_name, version = check_version_and_upload(os.path.abspath(MAIN_PATH))
--------------------------------------------------------------------------------
/utils/environment-macosx.yml:
--------------------------------------------------------------------------------
1 | name: videoannotator
2 |
3 | channels:
4 | - anaconda
5 | - menpo
6 | - defaults
7 | dependencies:
8 | - cycler=0.10.0=py35hb89929e_0
9 | - freetype=2.8=h143eb01_0
10 | - libpng=1.6.32=hce72d48_2
11 | - matplotlib=2.1.0=py35hc2166d4_0
12 | - pyparsing=2.2.0=py35h31fab04_0
13 | - python-dateutil=2.6.1=py35h10515e0_1
14 | - pytz=2017.2=py35h9789cde_1
15 | - scipy=0.19.1=py35hf362045_3
16 | - six=1.11.0=py35h39a4c60_1
17 | - tornado=4.5.2=py35h4099233_0
18 | - ca-certificates=2017.08.26=ha1e5d58_0
19 | - certifi=2017.7.27.1=py35h0fdde5e_0
20 | - hdf5=1.8.18=h1edb405_0
21 | - intel-openmp=2018.0.0=h68bdfb3_7
22 | - libcxx=4.0.1=h579ed51_0
23 | - libcxxabi=4.0.1=hebd6815_0
24 | - libedit=3.1=hb4e282d_0
25 | - libgfortran=3.0.1=h93005f0_2
26 | - mkl=2018.0.0=h5ef208c_6
27 | - ncurses=6.0=ha932d30_1
28 | - numpy=1.13.3=py35hfd7066c_0
29 | - openssl=1.0.2l=h57f3a61_2
30 | - pip=9.0.1=py35he52dd69_3
31 | - python=3.5.0=1
32 | - readline=6.2=2
33 | - setuptools=36.5.0=py35h52cde6a_0
34 | - sqlite=3.20.1=h900c3b0_1
35 | - tk=8.5.18=0
36 | - wheel=0.29.0=py35ha7aa5c4_1
37 | - xz=5.0.5=1
38 | - zlib=1.2.11=h60db283_1
39 | - opencv3=3.1.0=py35_0
40 | - tbb=4.3_20141023=0
41 | - pip:
42 | - https://bitbucket.org/fchampalimaud/geometry-designer/get/master.zip
43 | - https://bitbucket.org/fchampalimaud/logging-bootstrap/get/master.zip
44 | - https://bitbucket.org/fchampalimaud/mcv-api/get/master.zip
45 | - https://bitbucket.org/fchampalimaud/mcv-gui/get/master.zip
46 | - pyopengl==3.1.0
47 | - pyopengl-accelerate==3.1.0
48 | - pyqt5==5.9
49 | - send2trash==1.4.1
50 | - simplejson==3.11.1
--------------------------------------------------------------------------------
/utils/environment-ubuntu17.yml:
--------------------------------------------------------------------------------
1 | name: videoannotator
2 | channels:
3 | - conda-forge
4 | - anaconda
5 | - defaults
6 | dependencies:
7 | - graphite2=1.3.10=hc526e54_0
8 | - harfbuzz=1.5.0=h2545bd6_0
9 | - libgfortran-ng=7.2.0=h9f7466a_2
10 | - jasper=1.900.1=4
11 | - blas=1.0=mkl
12 | - bzip2=1.0.6=h6d464ef_2
13 | - ca-certificates=2017.08.26=h1d4fec5_0
14 | - cairo=1.14.10=hdf128ce_6
15 | - certifi=2017.11.5=py35h9749603_0
16 | - ffmpeg=3.4=h7264315_0
17 | - fontconfig=2.12.4=h88586e7_1
18 | - freetype=2.8=hab7d2ae_1
19 | - glib=2.53.6=h5d9569c_2
20 | - hdf5=1.10.2=hba1933b_1
21 | - icu=58.2=h9c2bf20_1
22 | - intel-openmp=2018.0.0=hc7b2577_8
23 | - jpeg=9b=h024ee3a_2
24 | - libedit=3.1=heed3624_0
25 | - libffi=3.2.1=hd88cf55_4
26 | - libgcc-ng=8.2.0=hdf63c60_1
27 | - libgfortran=3.0.0=1
28 | - libopus=1.2.1=hb9ed12e_0
29 | - libpng=1.6.32=hbd3595f_4
30 | - libprotobuf=3.6.0=hdbcaa40_0
31 | - libstdcxx-ng=8.2.0=hdf63c60_1
32 | - libtiff=4.0.9=h28f6b97_0
33 | - libvpx=1.6.1=h888fd40_0
34 | - libxcb=1.12=hcd93eb1_4
35 | - libxml2=2.9.4=h2e8b1d7_6
36 | - mkl=2018.0.3=1
37 | - mkl_fft=1.0.4=py35h4414c95_1
38 | - mkl_random=1.0.1=py35h4414c95_1
39 | - ncurses=6.0=h9df7e31_2
40 | - numpy=1.15.1=py35h1d66e8a_0
41 | - numpy-base=1.15.1=py35h81de0dd_0
42 | - opencv=3.4.1=py35h6fd60c2_1
43 | - openssl=1.0.2n=hb7f436b_0
44 | - pcre=8.41=hc27e229_1
45 | - pip=9.0.1=py35h7e7da9d_4
46 | - pixman=0.34.0=hceecf20_3
47 | - python=3.5.4=h417fded_24
48 | - readline=7.0=ha6073c6_4
49 | - scikit-learn=0.19.1=py35hbf1f462_0
50 | - scipy=1.1.0=py35hfa4b5c9_1
51 | - setuptools=38.4.0=py35_0
52 | - sqlite=3.20.1=hb898158_2
53 | - tk=8.6.7=hc745277_3
54 | - wheel=0.30.0=py35hd3883cf_1
55 | - xz=5.2.3=h55aa19d_2
56 | - zlib=1.2.11=ha838bed_2
57 | - pip:
58 | - alabaster==0.7.10
59 | - anyqt==0.0.8
60 | - argh==0.26.2
61 | - babel==2.5.3
62 | - chardet==3.0.4
63 | - cycler==0.10.0
64 | - docutils==0.14
65 | - idna==2.6
66 | - imagesize==0.7.1
67 | - jinja2==2.10
68 | - livereload==2.5.1
69 | - markupsafe==1.0
70 | - matplotlib==2.1.2
71 | - mkl-fft==1.0.4
72 | - mkl-random==1.0.1
73 | - opencv-python==3.4.2.17
74 | - pathtools==0.1.2
75 | - port-for==0.3.1
76 | - pygments==2.2.0
77 | - pyopengl==3.1.0
78 | - pyopengl-accelerate==3.1.0
79 | - pyparsing==2.2.0
80 | - pyqt5==5.10
81 | - python-dateutil==2.6.1
82 | - pytz==2018.3
83 | - pyyaml==3.12
84 | - qscintilla==2.10.2
85 | - requests==2.18.4
86 | - send2trash==1.4.2
87 | - simplejson==3.13.2
88 | - sip==4.19.7
89 | - six==1.11.0
90 | - snowballstemmer==1.2.1
91 | - sphinx==1.6.6
92 | - sphinx-autobuild==0.7.1
93 | - sphinx-rtd-theme==0.2.4
94 | - sphinxcontrib-websupport==1.0.1
95 | - tornado==4.5.3
96 | - urllib3==1.22
97 | - visvis==1.10.0
98 | - watchdog==0.8.3
99 | prefix: /home/ricardo/miniconda3/envs/videoannotator-environment
100 |
101 |
--------------------------------------------------------------------------------
/utils/environment-windows.yml:
--------------------------------------------------------------------------------
1 | name: videoannotator
2 | channels:
3 | - inso
4 | - conda-forge
5 | - defaults
6 | dependencies:
7 | - certifi=2018.1.18=py35_0
8 | - pip=9.0.1=py35_1
9 | - pyopengl=3.1.1a1=py35_0
10 | - python=3.5.5=0
11 | - setuptools=38.5.2=py35_0
12 | - vs2015_runtime=14.0.25420=0
13 | - wheel=0.30.0=py35_2
14 | - wincertstore=0.2=py35_0
15 | - git=2.16.1=0
16 | - pyqt5=5.6=py35_0
17 | - sip=4.18=py35_0
18 | - pip:
19 | - anyqt==0.0.8
20 | - cycler==0.10.0
21 | - kiwisolver==1.0.1
22 | - matplotlib==2.2.0
23 | - numpy==1.14.1
24 | - opencv-python==3.4.0.12
25 | - pyparsing==2.2.0
26 | - python-dateutil==2.6.1
27 | - pytz==2018.3
28 | - qscintilla==2.10.3
29 | - scikit-learn==0.19.1
30 | - scipy==1.0.0
31 | - send2trash==1.5.0
32 | - simplejson==3.13.2
33 | - six==1.11.0
34 | - sklearn==0.0
35 | - visvis==1.10.0
36 |
--------------------------------------------------------------------------------
/utils/install.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | # -*- coding: utf-8 -*-
3 |
4 | import os
5 | from subprocess import call
6 |
7 | SUBMODULES_FOLDERS = [
8 | os.path.join('libraries', 'geometry-designer'),
9 | os.path.join('libraries', 'mcv-api'),
10 | os.path.join('libraries', 'mcv-gui'),
11 | os.path.join('libraries', 'mcv-gui-editor'),
12 | os.path.join('libraries', 'pyforms-gui'),
13 | os.path.join('plugins', 'pythonvideoannotator-module-backgroundfinder'),
14 | os.path.join('plugins', 'pythonvideoannotator-module-contoursimages'),
15 | os.path.join('plugins', 'pythonvideoannotator-module-createpaths'),
16 | os.path.join('plugins', 'pythonvideoannotator-module-distances'),
17 | os.path.join('plugins', 'pythonvideoannotator-module-eventsstats'),
18 | os.path.join('plugins', 'pythonvideoannotator-module-findorientation'),
19 | os.path.join('plugins', 'pythonvideoannotator-module-importexport'),
20 | os.path.join('plugins', 'pythonvideoannotator-module-motioncounter'),
21 | os.path.join('plugins', 'pythonvideoannotator-module-patheditor'),
22 | os.path.join('plugins', 'pythonvideoannotator-module-regionsfilter'),
23 | os.path.join('plugins', 'pythonvideoannotator-module-smoothpaths'),
24 | os.path.join('plugins', 'pythonvideoannotator-module-timeline'),
25 | os.path.join('plugins', 'pythonvideoannotator-module-tracking'),
26 | os.path.join('plugins', 'pythonvideoannotator-module-virtualobjectgenerator'),
27 | os.path.join('plugins', 'pythonvideoannotator-module-pathmap'),
28 | os.path.join('plugins', 'pythonvideoannotator-module-deeplab'),
29 | os.path.join('base', 'pythonvideoannotator'),
30 | os.path.join('base', 'pythonvideoannotator-models'),
31 | os.path.join('base', 'pythonvideoannotator-models-gui'),
32 | ]
33 |
34 |
35 |
36 | def install():
37 | for submodule in SUBMODULES_FOLDERS:
38 | call(['pip', 'install', '-e', os.path.join(submodule,'.')])
39 |
40 | if __name__=='__main__':
41 | install()
--------------------------------------------------------------------------------