-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added script to render the video of detections as a point
- Loading branch information
Showing
18 changed files
with
436 additions
and
11 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This is a comment. | ||
# Each line is a file pattern followed by one or more owners. | ||
|
||
# These owners will be the default owners for everything in | ||
# the repo. Unless a later match takes precedence, | ||
# @global-owner1 and @global-owner2 will be requested for | ||
# review when someone opens a pull request. | ||
#* @global-owner1 @global-owner2 | ||
* @d61h6k4 | ||
|
||
# Order is important; the last matching pattern takes the most | ||
# precedence. When someone opens a pull request that only | ||
# modifies JS files, only @js-owner and not the global | ||
# owner(s) will be requested for a review. | ||
# *.js @js-owner | ||
|
||
# You can also use email addresses if you prefer. They'll be | ||
# used to look up users just like we do for commit author | ||
# emails. | ||
# *.go [email protected] | ||
|
||
# In this example, @doctocat owns any files in the build/logs | ||
# directory at the root of the repository and any of its | ||
# subdirectories. | ||
# /build/logs/ @doctocat | ||
|
||
# The `docs/*` pattern will match files like | ||
# `docs/getting-started.md` but not further nested files like | ||
# `docs/build-app/troubleshooting.md`. | ||
# docs/* [email protected] | ||
|
||
# In this example, @octocat owns any file in an apps directory | ||
# anywhere in your repository. | ||
# apps/ @octocat | ||
|
||
# In this example, @doctocat owns any file in the `/docs` | ||
# directory in the root of your repository. | ||
# /docs/ @doctocat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: C++ lint | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- 'master' | ||
|
||
jobs: | ||
build: | ||
name: C++ Linter by Clang-Format | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install clang-format | ||
run: | | ||
sudo apt install clang-format | ||
- name: Run linter | ||
run: | | ||
CLANG_FORMAT_ROOT=. TEST=1 bash tools/clang_format_all_the_things.sh | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
## Project tests GitHub Actions | ||
name: Lint | ||
|
||
# Start the job on all push | ||
on: | ||
push: | ||
branches-ignore: | ||
- 'master' | ||
|
||
# Set the Job | ||
jobs: | ||
build: | ||
# Name the Job | ||
name: Python linter | ||
# Set the agent to run on | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.8] | ||
|
||
# Load all steps | ||
steps: | ||
# Checkout the code base # | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
|
||
# Prepare python | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install wheel setuptools pylint | ||
- name: Run linter | ||
run: | | ||
# bash tools/pylint_code.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
## Project tests GitHub Actions | ||
name: Check types | ||
|
||
# Start the job on all push | ||
on: | ||
push: | ||
branches-ignore: | ||
- 'master' | ||
|
||
# Set the Job | ||
jobs: | ||
build: | ||
# Name the Job | ||
name: Python types :D | ||
# Set the agent to run on | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.8] | ||
|
||
# Load all steps | ||
steps: | ||
# Checkout the code base # | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
|
||
# Prepare python | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install wheel setuptools pytype | ||
- name: Run pytype | ||
run: | | ||
# bash tools/check_pytype.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
VIDEO_NAME = vfb_luebeck_012500_3min | ||
VIDEO_NAME = ma8796bf4f_012300_15min | ||
|
||
build: | ||
bazel build --define MEDIAPIPE_DISABLE_GPU=1 //runner:ap_demo | ||
|
||
debug: build | ||
GLOG_logtostderr=1 bazel-bin/runner/ap_demo \ | ||
--calculator_graph_config_file runner/ap_demo_debug_graph.pbtxt \ | ||
--input_side_packets=input_video_path=test_videos/$(VIDEO_NAME).mp4,output_detections_file_path=$(VIDEO_NAME)_detections.csv | ||
--input_side_packets=input_video_path=test_videos/$(VIDEO_NAME).mp4,output_detections_file_path=detection_csvs/$(VIDEO_NAME).csv | ||
|
||
render: build | ||
GLOG_logtostderr=1 bazel-bin/runner/ap_demo \ | ||
--calculator_graph_config_file runner/ap_demo_graph.pbtxt \ | ||
--input_side_packets=input_video_path=test_videos/$(VIDEO_NAME).mp4,output_video_path=processed_videos/$(VIDEO_NAME).mp4 | ||
--input_side_packets=input_video_path=test_videos/$(VIDEO_NAME).mp4,output_video_path=rendered_videos/$(VIDEO_NAME).mp4 | ||
|
||
|
||
render_schematic: | ||
bazel run //runner:schematic_visualizer -- --detections `pwd`/detection_csvs/$(VIDEO_NAME).csv | ||
|
||
|
||
all: debug render render_schematic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ _MEDIAPIPE_VERSION = "0.8.0" | |
|
||
http_archive( | ||
name = "mediapipe", | ||
#sha256 = "0b129a28864fd2cd2822948621645efb9d62b6d043d1c4da3cf2d01886bfd901", | ||
sha256 = "0b129a28864fd2cd2822948621645efb9d62b6d043d1c4da3cf2d01886bfd901", | ||
strip_prefix = "mediapipe-{}".format(_MEDIAPIPE_VERSION), | ||
url = "https://github.com/google/mediapipe/archive/{}.tar.gz".format(_MEDIAPIPE_VERSION), | ||
) | ||
|
@@ -104,6 +104,19 @@ git_repository( | |
remote = "[email protected]:d61h6k4/autoproduction.git", | ||
) | ||
|
||
http_archive( | ||
name = "rules_python", | ||
sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0", | ||
url = "https://github.com/bazelbuild/rules_python/releases/download/0.1.0/rules_python-0.1.0.tar.gz", | ||
) | ||
|
||
load("@rules_python//python:pip.bzl", "pip_install") | ||
|
||
pip_install( | ||
name = "ap_demo_deps", | ||
requirements = "//:requirements.txt", | ||
) | ||
|
||
_BAZEL_TOOLCHAINS_VERSION = "4.0.0" | ||
|
||
http_archive( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
tqdm | ||
numpy | ||
pandas | ||
matplotlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import argparse | ||
import pathlib | ||
import tqdm | ||
|
||
import pandas as pd | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import matplotlib.animation as animation | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument("--detections", | ||
required=True, | ||
help="Path to the CSV file with detections", | ||
type=pathlib.Path) | ||
return parser.parse_args() | ||
|
||
|
||
def label_to_color(arr): | ||
return np.array( | ||
list(map(lambda x: '#1f77b4' if x == 'person' else '#ff7f0e', arr))) | ||
|
||
|
||
def main(): | ||
args = parse_args() | ||
|
||
df = pd.read_csv(args.detections) | ||
|
||
df['y_center'] = 800. * (df['ymin'] + df['height'] / 2.) | ||
df['x_center'] = 3840. * (df['xmin'] + df['width'] / 2.) | ||
|
||
start = 0 | ||
end = df.iloc[df.shape[0] - 1].frame_num | ||
total = end - start | ||
|
||
fig, ax = plt.subplots(figsize=(12, 4)) | ||
pbar = tqdm.tqdm(total=total) | ||
|
||
def frame(w): | ||
pbar.update(1) | ||
ax.clear() | ||
|
||
ax.set_ylim(-900.0, 100.0) | ||
ax.set_xlim(0.0, 3840.0) | ||
|
||
return ax.scatter(df[df.frame_num == (start + w)].x_center.values, | ||
1 - df[df.frame_num == (start + w)].y_center.values, | ||
c=label_to_color( | ||
df[df.frame_num == (start + w)].label.values)) | ||
|
||
anim = animation.FuncAnimation(fig, | ||
frame, | ||
frames=total, | ||
interval=40, | ||
blit=False, | ||
repeat=False) | ||
|
||
anim.save(args.detections.with_suffix(".mp4")) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[style] | ||
based_on_style = google | ||
allow_split_before_dict_value = False | ||
spaces_around_default_or_named_assign = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/env bash | ||
|
||
set -ex; | ||
|
||
JOBS=$(nproc) || JOBS=4 | ||
python3 -m pip install pytype | ||
|
||
python3 -m pytype --python-version 3.8 --keep-going -j "$JOBS" --strict-import --config "setup.cfg" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
# change to root directory | ||
cd "$(dirname "$0")/.." | ||
|
||
# directories to run against | ||
DIRS="." | ||
|
||
# file matching patterns to check | ||
GLOB="*.h *.cc" | ||
|
||
# clang format command | ||
CLANG_FORMAT=${CLANG_FORMAT:-clang-format} | ||
|
||
files= | ||
for dir in $DIRS | ||
do | ||
for glob in $GLOB | ||
do | ||
files="$files `find $dir -name $glob`" | ||
done | ||
done | ||
|
||
if [ "$TEST" == "" ] | ||
then | ||
echo $files | xargs $CLANG_FORMAT -i | ||
else | ||
ok=yes | ||
for file in $files | ||
do | ||
tmp=`mktemp` | ||
$CLANG_FORMAT $file > $tmp | ||
diff -u $file $tmp || ok=no | ||
rm $tmp | ||
done | ||
if [ $ok == no ] | ||
then | ||
false | ||
fi | ||
fi |
Oops, something went wrong.