Skip to content

Commit

Permalink
🎥 Add example for video frames (#136)
Browse files Browse the repository at this point in the history
* leave some of the notebook output

* Update README with steps for video frames
  • Loading branch information
leblancfg authored Aug 31, 2021
1 parent 6c9caad commit edfc418
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ Further examples and use cases are found in the [accompanying Jupyter Notebook](

If no output folder is added, asks for confirmation and destructively crops images in-place.

#### Detecting faces from video files
You can use autocrop to detect faces in frames extracted from a video. A great way to [perform the frame extraction step is with `ffmpeg`](https://ffmpeg.org/download.html):

```sh
mkdir frames faces

# Extract one frame per second
ffmpeg -i input.mp4 -filter:v fps=fps=1/60 frames/ffmpeg_%0d.bmp

# Crop faces as jpg
autocrop -i frames -o faces -e jpg
```


## Supported file types

Expand Down Expand Up @@ -119,7 +132,7 @@ pip install .
~~~

### conda
Development of a `conda-forge` package for the [Anaconda Python distribution](https://www.anaconda.com/download/) is also currently slated for development. Please leave feedback on [issue #7](https://github.com/leblancfg/autocrop/issues/7) if you are insterested in helping out.
Development of a `conda-forge` package for the [Anaconda Python distribution](https://www.anaconda.com/download/) is currently stalled due to the complexity of setting up the workflow with OpenCV. Please leave feedback on [issue #7](https://github.com/leblancfg/autocrop/issues/7) to see past attempts if you are insterested in helping out!

## Requirements
Best practice for your projects is of course to [use virtual environments](http://docs.python-guide.org/en/latest/dev/virtualenvs/). At the very least, you will need to [have pip installed](https://pip.pypa.io/en/stable/installing/).
Expand Down
35 changes: 8 additions & 27 deletions tests/visual_tests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2020-03-23T19:44:29.134965Z",
Expand Down Expand Up @@ -49,25 +49,15 @@
"metadata": {},
"output_type": "execute_result"
}
},
"outputs": [],
],
"source": [
"img_array = c.crop(loc)\n",
"PIL.Image.fromarray(img_array)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"PIL.Image.fromarray(c.crop(img_array))"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"ExecuteTime": {
"end_time": "2020-03-23T19:44:37.012712Z",
Expand Down Expand Up @@ -97,7 +87,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2020-03-23T19:44:32.387838Z",
Expand All @@ -122,7 +112,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"ExecuteTime": {
"end_time": "2020-03-23T19:44:32.604788Z",
Expand Down Expand Up @@ -160,7 +150,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {
"ExecuteTime": {
"end_time": "2020-03-23T19:44:32.734430Z",
Expand Down Expand Up @@ -198,7 +188,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {
"ExecuteTime": {
"end_time": "2020-03-23T19:44:35.895830Z",
Expand Down Expand Up @@ -342,15 +332,6 @@
"## `_crop_postions`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## `_crop_postions`"
]
},
{
"cell_type": "code",
"execution_count": 13,
Expand Down Expand Up @@ -458,7 +439,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.8.0"
}
},
"nbformat": 4,
Expand Down

0 comments on commit edfc418

Please sign in to comment.