Skip to content

Commit f946d88

Browse files
Add hide your mess behind demo (background blurring JS demo) (#26)
* adding simple app to handle webcam * gitignore update for nodeJs purposes * detecting devices done * Updated view * tidying renderer and simplifying start/stop button * Further code cleaning * attempts to change webcam handler to node-webcam | webcam.capture not a function problem | mock runModel function * Added icon * New application UI * Updated UI * Hide menu bar * back to streaming from mediaDevices, but with new GUI (testing version - need to switch to node-webcam or other) * Removed unnecessary forge config * Added app info * Added more linux targets * streaming using single frames done * deleting node-webcam from package json * size of camera image corrected * path from runModel in renderer to runModel in ov jobs built | problem with passing the image (local resource) * changing the quality of webcam video * Added black webcam placeholder * choosing video source (webcams) * Small UI fixes * passing image to ov jobs * do not toggle sign on button if not clicking the button * Pass device to the function * Added cache for the OV models * raporting inference time: work in progress * raporting inference time: done * bug with black placeholder not showing up taken care of * processing time 0 when not processing | not declaring variable in handler * converting base64 to mat * work on image processing | subtraction of processing time from delay * convertion to mat from imageData, skipping base64, more efficient way * async taking time function * Added FPSs * processing time -> inference time * FIXED: Error occurred in handler for 'run-model' * Deleted debugging redundance * FIXED: RangeError: offset is out of bounds * small corrections * work on README * work on README * New name in README * Preprocessing mat function * Fixing error in padding * Conversion cv.Mat to ov.Tensor * preparation to interference * work on model inference - program stops after a few loops * semaphore to handle async functions * cleaning code * results of inference * preparation to postprocessing * normalize data in tensor (0-1) | work in progress on postprocessing * mask postprocessing * gausian blur function corrected | minor changes * 2 options mat resizing | work on blurring * mat resize: 5.1266000010073185 * mat and array resize time in comment * everything mock implemented | error occured & really not efficiant * logging | took inverseConditionMat to global | bitwise_and causes problems * TODO: optimization, blurred/org merging, displaying the final image * stop counting when display stopped * condition mat to be changed - too time consuming and not working properly * deleted kernel errors file * displaying the mat - work in progress * mask threshold * ImageData object transferred to renderer * EOD | nothing valuable, just saving my effort * ImageData declared in front, DISPLAYING IMAGE WORKS * Cleaning code | Faster mat to tensor conversion * mat resizing back to OpenCV * deleting kernel error + git ignore * not using helpers * Small code refactor * work on postprocessing: softmax analysis * Small renderer refactor * mask and blurring done * merging images works * all functionalities implemented * code cleaning * counting average time inference from 50 last inferences * taking blurring to seperate function * access to blurring from frontend * async inference + blur * blur -> resize ( time saving 150 -> 70) * deleting kernel errors file + typo in gitignore * contribution to demos README * adding photo to demos readme * updating README and changing the app name * changing the way of uploading image in demos README * check if it's compiled before reading model * check for mat size (enabling change for webcam with different quality) * fixing the oversight in previous commit * adding inference switch * First inference done before changing the switch * small visual changes * new photo in demos readme * hide your mess README * maybe stackblur canvas? * attempts to create a model for blurring * PostProcModel working * converting model to OpenVINO * creating model with flexible input * version without padding | back to OpenCV blur * OV blurring model creation fixed and testing functions deleted * blurring changed to model * changing the folder name * back to MVP * Preparing for publishing * readme update * readme mistake fixed * updated photos in hymb demo README * updated images in demos readme * small changes in UI * preparing code for publishing | code rewiev with Adrian * semaphore moved to ov jobs * new ideas | code rewiev with Adrian * Small code changes --------- Co-authored-by: Adrian Boguszewski <[email protected]>
1 parent a6c46e7 commit f946d88

File tree

17 files changed

+19775
-0
lines changed

17 files changed

+19775
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,7 @@ pipcache_openvino/
112112

113113
# PySpelling generated dictionary
114114
.ci/spellcheck/dictionary
115+
116+
# NodeJS
117+
demos/*/node_modules/**
118+
**/kernel.errors.txt

demos/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ The demo works as a virtual healthcare assistant, whose task is to greet the pat
4646
| Platforms | Client (CPU, GPU, NPU), Cloud (CPU, GPU) |
4747
| Owner | [@adrianboguszewski](https://github.com/adrianboguszewski) |
4848

49+
### 🔮 Hide Your Mess Behind
50+
51+
The demo blurs the background behind a person on a webcam. The app is built using NodeJS and Electron technologies. It can be run from the compiled exe file or using npm.
52+
53+
[![image](https://github.com/user-attachments/assets/e6925e6b-0d81-41da-b9b0-c4f21f173681)](hide_your_mess_behind_demo)
54+
55+
| [Hide Your Mess Behind](hide_your_mess_behind_demo) | |
56+
|--------------------------------------|------------------------------------------------------------------------------------------------------|
57+
| Related AI concepts | image segmentation |
58+
| Platforms | Client (CPU, GPU, NPU), Edge (CPU) |
59+
| Owner | [@Roszczyk](https://github.com/Roszczyk), [@adrianboguszewski](https://github.com/adrianboguszewski) |
60+
4961
### 💃 Strike a pose
5062

5163
The demo estimates poses of all people standing in front of the webcam.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
.DS_Store
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# TypeScript cache
43+
*.tsbuildinfo
44+
45+
# Optional npm cache directory
46+
.npm
47+
48+
# Optional eslint cache
49+
.eslintcache
50+
51+
# Optional REPL history
52+
.node_repl_history
53+
54+
# Output of 'npm pack'
55+
*.tgz
56+
57+
# Yarn Integrity file
58+
.yarn-integrity
59+
60+
# dotenv environment variables file
61+
.env
62+
.env.test
63+
64+
# parcel-bundler cache (https://parceljs.org/)
65+
.cache
66+
67+
# next.js build output
68+
.next
69+
70+
# nuxt.js build output
71+
.nuxt
72+
73+
# vuepress build output
74+
.vuepress/dist
75+
76+
# Serverless directories
77+
.serverless/
78+
79+
# FuseBox cache
80+
.fusebox/
81+
82+
# DynamoDB Local files
83+
.dynamodb/
84+
85+
# Webpack
86+
.webpack/
87+
88+
# Vite
89+
.vite/
90+
91+
# Electron-Forge
92+
out/
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Hide Your Mess Behind
2+
3+
## Description
4+
5+
This demo demonstrates how to use the OpenVINO toolkit in NodeJS to blur the background of video.
6+
7+
## Requirements
8+
9+
Ensure that you have Node.js (with npm) installed on your system. The app was developed and tested using *node v20.15.0* and *npm 10.8.2*.
10+
11+
## Getting started
12+
13+
Before running the app you have to initialize the electron project and install the required packages. Do it by running the following commands in the app folder:
14+
15+
```bash
16+
npm init -y
17+
npm install
18+
```
19+
20+
## Running the Demo
21+
22+
Once you've completed the initial setup, you can start the app anytime by running the following command in the app folder:
23+
24+
```bash
25+
npm start
26+
```
27+
28+
### Turn on the video
29+
30+
When you open the app, the following view will appear:
31+
32+
![image](https://github.com/user-attachments/assets/b9852e1e-3fa7-4375-afb9-8976cd9cf325)
33+
34+
Select the chosen video source from the control panel. Then click _Start_ button to start the streaming.
35+
36+
![image](https://github.com/user-attachments/assets/cd5a86e2-8865-4736-93e6-e2e0eb9b37f2)
37+
38+
Later you can turn off streaming by clicking _Stop_ button.
39+
40+
41+
### Turn on the inference
42+
43+
To turn on blurring you have to turn on inference using the _Inference_ switch. Below it, you can notice a panel, where you can choose the inference device (e.g. AUTO, GPU, CPU, NPU).
44+
45+
![image](https://github.com/user-attachments/assets/e6925e6b-0d81-41da-b9b0-c4f21f173681)
46+
47+
You can change the inference device or video source, and turn on and off inference, and streaming anytime.
14.4 KB
Binary file not shown.
24 KB
Loading
6.44 KB
Loading
Binary file not shown.

0 commit comments

Comments
 (0)