This repository was archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 182
Enable IC background blur feature #564
Open
zhibo1-wang
wants to merge
30
commits into
open-webrtc-toolkit:main
Choose a base branch
from
zhibo1-wang:dev-owt-ic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
dea547b
Enable IC background blur feature
zhibo1-wang 6b305e9
Fixups
zhibo1-wang 07e161c
Update thirdpartylicense.txt
zhibo1-wang 091f187
Fixups
zhibo1-wang ec24bbf
Fixups
zhibo1-wang 09530e6
Fixups
zhibo1-wang 96ab951
Fixups
zhibo1-wang 572b0f4
Fixups
zhibo1-wang 65ee09d
Fixups
zhibo1-wang 8e12bed
Fixups
zhibo1-wang 51311bc
Fixups
zhibo1-wang 09d1d4d
Fixups
zhibo1-wang 59891e2
Fixups
zhibo1-wang 9c7a7ce
Fixups
zhibo1-wang 6ef5289
Fix FreeLibrary deadlocks
zhibo1-wang f9c7381
Fixups
zhibo1-wang a474a59
Naming fixups and etc.
zhibo1-wang 13d8027
Fixups
zhibo1-wang 4db6116
Update README.md
zhibo1-wang 2f91956
Fixups (bugs)
zhibo1-wang e8c02e5
Update docs
zhibo1-wang 7980fcf
Fix debug build
zhibo1-wang 705860c
Fixups
zhibo1-wang ab80773
Update windows.jenkinsfile
zhibo1-wang 6287a53
Fixups
zhibo1-wang f23c70c
Fixup
zhibo1-wang 3e5dd15
Update windows.jenkinsfile
zhibo1-wang 16de4f9
Update windows.jenkinsfile
zhibo1-wang d00bb7e
Update windows.jenkinsfile
zhibo1-wang 32a61d7
Update windows.jenkinsfile
zhibo1-wang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,10 @@ | ||
# Copyright (C) <2021> Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
declare_args() { | ||
owt_msdk_lib_root = "" | ||
owt_msdk_header_root = "" | ||
owt_build_ic = false | ||
owt_msvcrt = false | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,31 @@ | ||
# IC Developer Guide | ||
|
||
This guide is to introduce how to add a post processor into IC plugin. | ||
|
||
The IC plugin is to support Intelligent Collaboration features in the OWT, which | ||
are background blur, face detection, face framing, eye contact correction and | ||
etc. video frame post processing algorithms using deep learning neural networks. | ||
In this plugin, OpenVINO inference engine is used to do the neural network | ||
inference. | ||
|
||
The IC plugin is compiled to an individual shared library, whose entry is defined | ||
in `talk/owt/sdk/ic/icmanager.h`. The ICManager will be initialized as a global | ||
singleton instance and will be used to create the post processor instances. | ||
|
||
To introduce a new post processor, you need to create a class in the | ||
`talk/owt/sdk/ic` directory, inheriting the `owt::ic::VideoFramePostProcessor` | ||
interface and implement its virtual methods. The post processor's main logic | ||
should be in the `Process` function, which returns the processed frame buffer. | ||
You may use inference engine C++ API for neural network inferencing, but be sure | ||
to catch and handle all exceptions. Exceptions are not expected in the main OWT. | ||
|
||
To make it possible for creating your post processor by `CreatePostProcessor` | ||
method., change the code in `talk/owt/sdk/ic/icmanager.cc`. You may get the | ||
inference engine core instance from the `ICManager`. You also need to add new | ||
enumeration item of `owt::ic::ICPostProcessor` in | ||
`talk/owt/sdk/include/cpp/owt/ic/icmanagerinterface.h`. | ||
|
||
Finally, update the `ic-user-guide.md` to introduce the parameters' usage to the | ||
user. Also edit the `.gn` files to make the new codes compiled. | ||
|
||
See the background blur's code for more detail. |
This file contains hidden or 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,77 @@ | ||
# IC User Guide | ||
|
||
The IC plugin is to support Intelligent Collaboration features in the OWT, which | ||
are background blur, face detection, face framing, eye contact correction and | ||
etc. video frame post processing algorithms using deep learning neural networks. | ||
|
||
To use the IC plugin, first initialize the global plugin instance in plugin | ||
manager. | ||
```cpp | ||
owt::ic::ICManagerInterface* ic_plugin = owt::base::PluginManager::ICPlugin(); | ||
``` | ||
If the `owt::ic::ICManagerInterface* ic_plugin` is not `nullptr`, the ic plugin | ||
is succesfully initialized. Otherwise, check whether `owt_ic.dll` is in | ||
your path. The pointer is managed by `PluginManager` so you do not delete it. | ||
|
||
You may get a `std::shared_ptr<owt::base::VideoFramePostProcessor>` by | ||
using `ic_plugin->CreatePostProcessor(owt::ic::ICPostProcessor)`. Then configure | ||
the post-processor, and finally add it into the | ||
`LocalCameraStreamParameters.PostProcessors()`, which is used for creating | ||
`LocalStream`. | ||
|
||
The post-processors will be applied to the produced frame in the order you add | ||
them. | ||
|
||
```cpp | ||
std::shared_ptr<owt::base::VideoFramePostProcessor> post_processor = | ||
ic_plugin->CreatePostProcessor(owt::ic::ICPostProcessor::BACKGROUND_BLUR); | ||
// do some preparation, see below | ||
owt::base::LocalCameraStreamParameters param(true, true); | ||
param.PostProcessors().push_back(post_processor); | ||
``` | ||
|
||
See below sections for each post processor's usage. | ||
|
||
## Background Blur | ||
The background blur post processor uses a selfie segmentation neural network | ||
model to detect the area of human in frames. The background part will be applied | ||
with a Gaussian filter to make it blurred. You can customize its blur radius to | ||
change the blurring degree. | ||
Use `ic_plugin->CreatePostProcessor(owt::ic::ICPostProcessor::BACKGROUND_BLUR)` | ||
to get a background blur post processor instance. | ||
|
||
### Model | ||
This post-processor use a neural network model, which can be found at | ||
[owt-selfie-segmentation-144x256.xml](https://github.com/open-webrtc-toolkit/owt-model-zoo/raw/main/selfie-segmentation/144x256/owt-selfie-segmentation-144x256.xml) | ||
and | ||
[owt-selfie-segmentation-144x256.bin](https://github.com/open-webrtc-toolkit/owt-model-zoo/raw/main/selfie-segmentation/144x256/owt-selfie-segmentation-144x256.bin). | ||
Download and save them to your project, then call `ReadModel` and `LoadModel` to | ||
prepare the model. When reading model, you only need to specify the path to | ||
`.xml` file, and the `.bin` file should be in the same directory, which will be | ||
automatically loaded by the framework. | ||
|
||
Note that the loading process will taken place in the function, so this may be | ||
time-consuming depends on the model's size. Make sure you call this in a proper | ||
time. | ||
|
||
The function will return false if there is any error, and the error | ||
message will be printed to the log output. | ||
|
||
```cpp | ||
background_blur->ReadModel("/path/to/model.xml"); | ||
background_blur->LoadModel("CPU"); | ||
``` | ||
|
||
### Parameters | ||
**blur_radius**: A positive integer representing the blur radius used in | ||
Gaussian blur processing to the background. The larger the blur radius is, the | ||
more blurred will the frame be, and vise versa. Zero or negative blur_radius | ||
will lead to the Gaussian blur taking no effect. Default: 55. | ||
|
||
### Sample | ||
```cpp | ||
background_blur->SetParameter("blur_radius", 55); | ||
``` | ||
|
||
There is a sample program about using background blur, which can be found at | ||
`talk/owt/sdk/sample/win/sample_background_blur`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.