Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit fafa297

Browse files
authored
Merge pull request #7 from google/staging
Project import generated by Copybara.
2 parents 283f995 + 497897e commit fafa297

14 files changed

+480
-8
lines changed

.github/workflows/scorecards.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ jobs:
3434
with:
3535
results_file: results.sarif
3636
results_format: sarif
37-
# Read-only PAT token. Necessary for the Branch-Protection check.
38-
# On creating/modifying the PAT token, see https://github.com/ossf/scorecard-action#authentication-with-pat.
39-
repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
4037

4138
# Publish the results for public repositories to enable scorecard badges. For more details, see
4239
# https://github.com/ossf/scorecard-action#publishing-results.

CHANGELOG

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
## [Unreleased]
44

55
### Added
6-
-
6+
7+
## [1.0.1]
8+
9+
### Added
10+
- Overlay graphs to display both base detection and tracked detections.
711

812
### Changed
913
- Replace absl::make_unique with std::make_unique (introduced in C++14).

docs/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ nav_order: 4
99
This document contains a summary of all changes to the Magritte open-source
1010
library.
1111

12+
## 1.0.1
13+
14+
* Add overlay graphs to display both base detection and tracked detections.
15+
* Replace absl::make_unique with std::make_unique (introduced in C++14).
16+
1217
## 1.0.0
1318

1419
* First release to GitHub.

docs/technical_guide/graphs.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,89 @@ files in the test_data directory.
345345
346346
**Code:** [source code](https://github.com/google/magritte/blob/master/magritte/graphs/face_sticker_redaction_offline_cpu.pbtxt)
347347
348+
#### FaceTrackingOverlayLiveGpu
349+
350+
A graph that detects and tracks faces to draw debug information.
351+
352+
It draws in red the raw detection output (detection box, keypoints, score),
353+
and in blue the tracked detection output (detection box, keypoints, score,
354+
when present).
355+
356+
This graph is specialized for GPU architectures. It also optimized for live
357+
streaming environments by throttling the input stream and by applying only
358+
full-range face detection.
359+
360+
**Input streams:**
361+
362+
* `input_video`: A GpuBuffer stream containing the image on which detection
363+
models are run.
364+
365+
**Output streams:**
366+
367+
* `output_video`: A GpuBuffer stream containing the image annotated with
368+
detections data.
369+
370+
**Build targets:**
371+
372+
* Graph `cc_library`:
373+
374+
```
375+
@magritte//magritte/graphs:face_tracking_overlay_live_gpu
376+
```
377+
* Text proto file:
378+
379+
```
380+
@magritte//magritte/graphs:face_tracking_overlay_live_gpu.pbtxt
381+
```
382+
* Binary graph:
383+
384+
```
385+
@magritte//magritte/graphs:face_tracking_overlay_live_gpu_graph
386+
```
387+
388+
**Code:** [source code](https://github.com/google/magritte/blob/master/magritte/graphs/face_tracking_overlay_live_gpu.pbtxt)
389+
390+
#### FaceTrackingOverlayOfflineCpu
391+
392+
A graph that detects and tracks faces to draw debug information.
393+
394+
It draws in red the raw detection output (detection box, keypoints, score),
395+
and in blue the tracked detection output (detection box, keypoints, score,
396+
when present).
397+
398+
This graph is specialized for CPU architectures and offline environments
399+
(no throttling is applied).
400+
401+
**Input streams:**
402+
403+
* `input_video`: An ImageFrame stream containing the image on which detection
404+
models are run.
405+
406+
**Output streams:**
407+
408+
* `output_video`: An ImageFrame stream containing the image annotated with
409+
detections data.
410+
411+
**Build targets:**
412+
413+
* Graph `cc_library`:
414+
415+
```
416+
@magritte//magritte/graphs:face_tracking_overlay_offline_cpu
417+
```
418+
* Text proto file:
419+
420+
```
421+
@magritte//magritte/graphs:face_tracking_overlay_offline_cpu.pbtxt
422+
```
423+
* Binary graph:
424+
425+
```
426+
@magritte//magritte/graphs:face_tracking_overlay_offline_cpu_graph
427+
```
428+
429+
**Code:** [source code](https://github.com/google/magritte/blob/master/magritte/graphs/face_tracking_overlay_offline_cpu.pbtxt)
430+
348431
## Subgraphs
349432
350433
### Detection
@@ -879,6 +962,78 @@ the ovals will be white.
879962
880963
**Code:** [source code](https://github.com/google/magritte/blob/master/magritte/graphs/redaction/detection_to_mask/face_detection_to_mask_gpu.pbtxt)
881964
965+
#### DetectionTrackingOverlaySubgraphCpu
966+
967+
Subgraph to draw debug information at the locations specified by two incoming
968+
detection streams. For each detection stream, it will draw all data available
969+
from detections, including the bounding box, keypoints and score.
970+
971+
**Input streams:**
972+
973+
* `IMAGE`: An ImageFrame containing the image to draw the overlays on.
974+
* `[0]`: A std::vector<mediapipe::Detection>, will be rendered in red.
975+
* `[1]`: A std::vector<mediapipe::Detection>, will be rendered in blue.
976+
977+
**Output streams:**
978+
979+
* `IMAGE`: The resulting image.
980+
981+
**Build targets:**
982+
983+
* Graph `cc_library`:
984+
985+
```
986+
@magritte//magritte/graphs/redaction:detection_tracking_overlay_cpu
987+
```
988+
* Text proto file:
989+
990+
```
991+
@magritte//magritte/graphs/redaction:detection_tracking_overlay_cpu.pbtxt
992+
```
993+
* Binary graph:
994+
995+
```
996+
@magritte//magritte/graphs/redaction:detection_tracking_overlay_cpu_graph
997+
```
998+
999+
**Code:** [source code](https://github.com/google/magritte/blob/master/magritte/graphs/redaction/detection_tracking_overlay_cpu.pbtxt)
1000+
1001+
#### DetectionTrackingOverlaySubgraphGpu
1002+
1003+
Subgraph to draw debug information at the locations specified by two incoming
1004+
detection streams. For each detection stream, it will draw all data available
1005+
from detections, including the bounding box, keypoints and score.
1006+
1007+
**Input streams:**
1008+
1009+
* `IMAGE_GPU`: A GpuBuffer containing the image to draw the overlays on.
1010+
* `[0]`: A std::vector<mediapipe::Detection>, will be rendered in red.
1011+
* `[1]`: A std::vector<mediapipe::Detection>, will be rendered in blue.
1012+
1013+
**Output streams:**
1014+
1015+
* `IMAGE_GPU`: The resulting image.
1016+
1017+
**Build targets:**
1018+
1019+
* Graph `cc_library`:
1020+
1021+
```
1022+
@magritte//magritte/graphs/redaction:detection_tracking_overlay_gpu
1023+
```
1024+
* Text proto file:
1025+
1026+
```
1027+
@magritte//magritte/graphs/redaction:detection_tracking_overlay_gpu.pbtxt
1028+
```
1029+
* Binary graph:
1030+
1031+
```
1032+
@magritte//magritte/graphs/redaction:detection_tracking_overlay_gpu_graph
1033+
```
1034+
1035+
**Code:** [source code](https://github.com/google/magritte/blob/master/magritte/graphs/redaction/detection_tracking_overlay_gpu.pbtxt)
1036+
8821037
#### FaceDetectionOverlaySubgraphCpu
8831038
8841039
Subgraph to draw debug information at the locations specified by incoming

magritte/calculators/BUILD

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ mediapipe_proto_library(
111111
cc_library(
112112
name = "pixelization_calculator_gpu",
113113
srcs = ["pixelization_calculator_gpu.cc"],
114-
visibility = ["//visibility:public"],
115114
deps = [
116115
":pixelization_calculator_cc_proto",
117116
"@mediapipe//mediapipe/framework:calculator_framework",
@@ -154,7 +153,6 @@ cc_library(
154153
name = "blend_calculator",
155154
srcs = ["blend_calculator.cc"],
156155
hdrs = ["blend_calculator.h"],
157-
visibility = ["//visibility:public"],
158156
deps = [
159157
"@mediapipe//mediapipe/framework:calculator_framework",
160158
"@mediapipe//mediapipe/framework/formats:image_frame",

magritte/calculators/rois_to_sprite_list_calculator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ using ::mediapipe::GlTexture;
4545
using ::mediapipe::GpuBuffer;
4646
#endif // !MEDIAPIPE_DISABLE_GPU
4747
using ::mediapipe::MakePacket;
48-
using ::mediapipe::NormalizedRect;
4948
using ::mediapipe::formats::MatView;
5049
using ::mediapipe::ImageFormat;
50+
using ::mediapipe::NormalizedRect;
5151
using NormalizedRects = std::vector<NormalizedRect>;
5252
using Size = std::pair<int, int>;
5353

magritte/calculators/rois_to_sprite_list_calculator_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ using ::mediapipe::CalculatorGraphConfig;
4444
using ::mediapipe::CalculatorRunner;
4545
using ::mediapipe::ImageFormat;
4646
using ::mediapipe::ImageFrame;
47-
using ::mediapipe::NormalizedRect;
4847
using ::mediapipe::Packet;
4948
using ::mediapipe::Timestamp;
5049
using ::mediapipe::formats::MatView;
50+
using ::mediapipe::NormalizedRect;
5151
using SizeFloat = std::pair<float, float>;
5252
using SizeInt = std::pair<int, int>;
5353

magritte/examples/desktop/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ _top_level_graph_targets = [
5050
"//magritte/graphs:face_blur_with_tracking_live_cpu",
5151
"//magritte/graphs:face_blur_with_tracking_offline_cpu",
5252
"//magritte/graphs:face_overlay_offline_cpu",
53+
"//magritte/graphs:face_tracking_overlay_offline_cpu",
5354
"//magritte/graphs:face_pixelization_offline_cpu",
5455
"//magritte/graphs:face_sticker_redaction_offline_cpu",
5556
] + select({

magritte/graphs/BUILD

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ magritte_graph(
4444
],
4545
)
4646

47+
magritte_graph(
48+
name = "face_tracking_overlay_offline_cpu",
49+
graph = "face_tracking_overlay_offline_cpu.pbtxt",
50+
register_as = "FaceTrackingOverlayOfflineCpu",
51+
deps = [
52+
"//magritte/graphs/detection:face_detection_short_and_full_range_cpu",
53+
"//magritte/graphs/redaction:detection_tracking_overlay_cpu",
54+
"//magritte/graphs/tracking:tracking_cpu",
55+
],
56+
)
57+
4758
magritte_graph(
4859
name = "face_blur_with_tracking_offline_cpu",
4960
graph = "face_blur_with_tracking_offline_cpu.pbtxt",
@@ -89,6 +100,18 @@ magritte_graph(
89100
],
90101
)
91102

103+
magritte_graph(
104+
name = "face_tracking_overlay_live_gpu",
105+
graph = "face_tracking_overlay_live_gpu.pbtxt",
106+
register_as = "FaceTrackingOverlayLiveGpu",
107+
deps = [
108+
"//magritte/graphs/detection:face_detection_full_range_gpu",
109+
"//magritte/graphs/redaction:detection_tracking_overlay_gpu",
110+
"//magritte/graphs/tracking:tracking_gpu",
111+
"@mediapipe//mediapipe/calculators/core:flow_limiter_calculator",
112+
],
113+
)
114+
92115
magritte_graph(
93116
name = "face_sticker_redaction_offline_cpu",
94117
graph = "face_sticker_redaction_offline_cpu.pbtxt",
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#
2+
# Copyright 2020-2022 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
package: "magritte"
17+
type: "FaceTrackingOverlayLiveGpu"
18+
19+
# A graph that detects and tracks faces to draw debug information.
20+
#
21+
# It draws in red the raw detection output (detection box, keypoints, score),
22+
# and in blue the tracked detection output (detection box, keypoints, score,
23+
# when present).
24+
#
25+
# This graph is specialized for GPU architectures. It also optimized for live
26+
# streaming environments by throttling the input stream and by applying only
27+
# full-range face detection.
28+
#
29+
# Inputs:
30+
# - input_video: A GpuBuffer stream containing the image on which detection
31+
# models are run.
32+
#
33+
# Outputs:
34+
# - output_video: A GpuBuffer stream containing the image annotated with
35+
# detections data.
36+
37+
input_stream: "input_video"
38+
output_stream: "output_video"
39+
40+
node {
41+
calculator: "FlowLimiterCalculator"
42+
input_stream: "input_video"
43+
input_stream: "FINISHED:output_video"
44+
input_stream_info: {
45+
tag_index: "FINISHED"
46+
back_edge: true
47+
}
48+
output_stream: "throttled_input_video"
49+
}
50+
51+
node {
52+
calculator: "FaceDetectionFullRangeGpu"
53+
input_stream: "IMAGE:throttled_input_video"
54+
output_stream: "DETECTIONS:detections"
55+
}
56+
57+
node {
58+
calculator: "TrackingSubgraphGpu"
59+
input_stream: "IMAGE:throttled_input_video"
60+
input_stream: "DETECTIONS:detections"
61+
output_stream: "DETECTIONS:tracked_detections"
62+
}
63+
64+
node {
65+
calculator: "DetectionTrackingOverlaySubgraphGpu"
66+
input_stream: "IMAGE_GPU:throttled_input_video"
67+
input_stream: "detections"
68+
input_stream: "tracked_detections"
69+
output_stream: "IMAGE_GPU:output_video"
70+
}
71+

0 commit comments

Comments
 (0)