Skip to content

Commit dc40414

Browse files
MediaPipe Teamjqtang
MediaPipe Team
authored and
jqtang
committed
Project import generated by Copybara.
PiperOrigin-RevId: 256060078
1 parent 37c93d5 commit dc40414

File tree

8 files changed

+144
-4
lines changed

8 files changed

+144
-4
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![MediaPipe](mediapipe/docs/images/mediapipe_small.png?raw=true "MediaPipe logo")
22
=======================================================================
33

4-
[MediaPipe](http://mediapipe.dev) is a framework for building multimodal (eg. video, audio, any time series data) applied ML pipelines. With MediaPipe, a perception pipeline can be built as a graph of modular components, including, for instance, inference models (e.g., TensorFlow, TFLite) and media processing functions. http://mediapipe.dev
4+
[MediaPipe](http://mediapipe.dev) is a framework for building multimodal (eg. video, audio, any time series data) applied ML pipelines. With MediaPipe, a perception pipeline can be built as a graph of modular components, including, for instance, inference models (e.g., TensorFlow, TFLite) and media processing functions.
55

66
![Real-time Face Detection](mediapipe/docs/images/realtime_face_detection.gif)
77

Diff for: mediapipe/docs/gpu.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ calculator derived from base class GlSimpleCalculator. The GPU calculator
3636
`LuminanceCalculator` is shown as an example. The method
3737
`LuminanceCalculator::GlRender` is called from `GlSimpleCalculator::Process`.
3838

39-
```
39+
```c++
4040
// Converts RGB images into luminance images, still stored in RGB format.
4141
// See GlSimpleCalculator for inputs, outputs and input side packets.
4242
class LuminanceCalculator : public GlSimpleCalculator {

Diff for: mediapipe/docs/how_to_questions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ You can see an example in:
2323

2424
### How to visualize perception results
2525

26-
The [`AnnotationOverlayCalculator`] allows perception results, such as boudning
26+
The [`AnnotationOverlayCalculator`] allows perception results, such as bounding
2727
boxes, arrows, and ovals, to be superimposed on the video frames aligned with
2828
the recognized objects. The results can be displayed in a diagnostic window when
2929
running on a workstation, or in a texture frame when running on device. You can
@@ -85,7 +85,7 @@ The first approach has the advantage of leveraging [`CalculatorGraphConfig`]
8585
processing tools such as "subgraphs". The second approach has the advantage of
8686
allowing active calculators and packets to remain in-flight while settings
8787
change. Mediapipe contributors are currently investigating alternative approaches
88-
to achieve both of these adantages.
88+
to achieve both of these advantages.
8989

9090
### How to process realtime input streams
9191

Diff for: mediapipe/docs/install.md

+120
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Choose your operating system:
66
- [Installing on Debian and Ubuntu](#installing-on-debian-and-ubuntu)
77
- [Installing on CentOS](#installing-on-centos)
88
- [Installing on macOS](#installing-on-macos)
9+
- [Installing on Windows Subsystem for Linux (WSL)](#installing-on-windows-subsystem-for-linux-wsl)
910
- [Installing using Docker](#installing-using-docker)
1011
- [Setting up Android SDK and NDK](#setting-up-android-sdk-and-ndk)
1112

@@ -299,6 +300,125 @@ Required libraries
299300
# Hello World!
300301
```
301302
303+
### Installing on Windows Subsystem for Linux (WSL)
304+
305+
1. Follow
306+
[the instruction](https://docs.microsoft.com/en-us/windows/wsl/install-win10)
307+
to install Windows Sysystem for Linux (Ubuntu)
308+
309+
2. Install Windows ADB and start the ADB server in Windows
310+
311+
Note: Window’s and WSL’s adb versions must be the same version, e.g., if WSL
312+
has ADB 1.0.39, you need to download the corresponding Windows ADB from
313+
[here](https://dl.google.com/android/repository/platform-tools_r26.0.1-windows.zip).
314+
315+
3. Launch WSL
316+
317+
Note: All the following steps will be executed in WSL. The Windows directory
318+
of the Linux Subsystem can be found in
319+
C:\Users\YourUsername\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_SomeID\LocalState\rootfs\home
320+
321+
4. Install the needed packages
322+
323+
```bash
324+
username@DESKTOP-TMVLBJ1:~$ sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential git python zip adb openjdk-8-jdk
325+
```
326+
327+
5. Install Bazel
328+
329+
```bash
330+
username@DESKTOP-TMVLBJ1:~$ curl -sLO --retry 5 --retry-max-time 10 \
331+
https://storage.googleapis.com/bazel/0.27.0/release/bazel-0.27.0-installer-linux-x86_64.sh && \
332+
sudo mkdir -p /usr/local/bazel/0.27.0 && \
333+
chmod 755 bazel-0.27.0-installer-linux-x86_64.sh && \
334+
sudo ./bazel-0.27.0-installer-linux-x86_64.sh --prefix=/usr/local/bazel/0.27.0 && \
335+
source /usr/local/bazel/0.27.0/lib/bazel/bin/bazel-complete.bash
336+
337+
username@DESKTOP-TMVLBJ1:~$ /usr/local/bazel/0.27.0/lib/bazel/bin/bazel version && \
338+
alias bazel='/usr/local/bazel/0.27.0/lib/bazel/bin/bazel'
339+
```
340+
341+
6. Checkout mediapipe repository
342+
343+
```bash
344+
username@DESKTOP-TMVLBJ1:~$ git clone https://github.com/google/mediapipe.git
345+
346+
username@DESKTOP-TMVLBJ1:~$ cd mediapipe
347+
```
348+
349+
7. Install OpenCV
350+
351+
Option 1. Use package manager tool to install the pre-compiled OpenCV
352+
libraries.
353+
354+
```bash
355+
username@DESKTOP-TMVLBJ1:~/mediapipe$ sudo apt-get install libopencv-core-dev libopencv-highgui-dev \
356+
libopencv-imgproc-dev libopencv-video-dev
357+
```
358+
359+
Option 2. Run [`setup_opencv.sh`] to automatically build OpenCV from source
360+
and modify MediaPipe's OpenCV config.
361+
362+
Option 3. Follow OpenCV's
363+
[documentation](https://docs.opencv.org/3.4.6/d7/d9f/tutorial_linux_install.html)
364+
to manually build OpenCV from source code.
365+
366+
Note: You may need to modify [`WORKSAPCE`] and [`opencv_linux.BUILD`] to
367+
point MediaPipe to your own OpenCV libraries, e.g., if OpenCV 4 is installed
368+
in "/usr/local/", you need to update the "linux_opencv" new_local_repository
369+
rule in [`WORKSAPCE`] and "opencv" cc_library rule in [`opencv_linux.BUILD`]
370+
like the following:
371+
372+
```bash
373+
new_local_repository(
374+
name = "linux_opencv",
375+
build_file = "@//third_party:opencv_linux.BUILD",
376+
path = "/usr/local",
377+
)
378+
379+
cc_library(
380+
name = "opencv",
381+
srcs = glob(
382+
[
383+
"lib/libopencv_core.so*",
384+
"lib/libopencv_highgui.so*",
385+
"lib/libopencv_imgcodecs.so*",
386+
"lib/libopencv_imgproc.so*",
387+
"lib/libopencv_video.so*",
388+
"lib/libopencv_videoio.so*",
389+
390+
],
391+
),
392+
hdrs = glob(["include/opencv4/**/*.h*"]),
393+
includes = ["include/opencv4/"],
394+
linkstatic = 1,
395+
visibility = ["//visibility:public"],
396+
)
397+
398+
```
399+
400+
8. Run the hello world desktop example
401+
402+
```bash
403+
username@DESKTOP-TMVLBJ1:~/mediapipe$ export GLOG_logtostderr=1
404+
405+
# Need bazel flag 'MEDIAPIPE_DISABLE_GPU=1' as desktop GPU is currently not supported
406+
username@DESKTOP-TMVLBJ1:~/mediapipe$ bazel run --define 'MEDIAPIPE_DISABLE_GPU=1' \
407+
mediapipe/examples/desktop/hello_world:hello_world
408+
409+
# Should print:
410+
# Hello World!
411+
# Hello World!
412+
# Hello World!
413+
# Hello World!
414+
# Hello World!
415+
# Hello World!
416+
# Hello World!
417+
# Hello World!
418+
# Hello World!
419+
# Hello World!
420+
```
421+
302422
### Installing using Docker
303423
304424
This will use a Docker image that will isolate mediapipe's installation from the rest of the system.

Diff for: mediapipe/framework/calculator_runner.cc

+4
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ mediapipe::Counter* CalculatorRunner::GetCounter(const std::string& name) {
216216
return graph_->GetCounterFactory()->GetCounter(name);
217217
}
218218

219+
std::map<std::string, int64> CalculatorRunner::GetCountersValues() {
220+
return graph_->GetCounterFactory()->GetCounterSet()->GetCountersValues();
221+
}
222+
219223
::mediapipe::Status CalculatorRunner::BuildGraph() {
220224
if (graph_ != nullptr) {
221225
// The graph was already built.

Diff for: mediapipe/framework/calculator_runner.h

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ class CalculatorRunner {
127127
// Returns a graph counter.
128128
mediapipe::Counter* GetCounter(const std::string& name);
129129

130+
// Returns all graph counters values.
131+
std::map<std::string, int64> GetCountersValues();
132+
130133
private:
131134
static const char kSourcePrefix[];
132135
static const char kSinkPrefix[];

Diff for: mediapipe/framework/counter_factory.cc

+10
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ Counter* CounterSet::Get(const std::string& name) LOCKS_EXCLUDED(mu_) {
7373
return counters_[name].get();
7474
}
7575

76+
std::map<std::string, int64> CounterSet::GetCountersValues()
77+
LOCKS_EXCLUDED(mu_) {
78+
absl::ReaderMutexLock lock(&mu_);
79+
std::map<std::string, int64> result;
80+
for (const auto& it : counters_) {
81+
result[it.first] = it.second->Get();
82+
}
83+
return result;
84+
}
85+
7686
Counter* BasicCounterFactory::GetCounter(const std::string& name) {
7787
return counter_set_.Emplace<BasicCounter>(name, name);
7888
}

Diff for: mediapipe/framework/counter_factory.h

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class CounterSet {
6565
// exist.
6666
Counter* Get(const std::string& name);
6767

68+
// Retrieves all counters names and current values from the internal map.
69+
std::map<std::string, int64> GetCountersValues() LOCKS_EXCLUDED(mu_);
70+
6871
private:
6972
absl::Mutex mu_;
7073
std::map<std::string, std::unique_ptr<Counter>> counters_ GUARDED_BY(mu_);

0 commit comments

Comments
 (0)