Skip to content

Commit 6f7b7c9

Browse files
authored
[HYMB] Fixing paths handling for exe version (#107)
* fixed paths declaring to make it work in exe * deleted console log
1 parent 1758973 commit 6f7b7c9

File tree

2 files changed

+37
-23
lines changed

2 files changed

+37
-23
lines changed

demos/hide_your_mess_behind_demo/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hide-your-mess-behind",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"main": "src/main.js",
55
"scripts": {
66
"start": "electron .",
@@ -33,7 +33,8 @@
3333
"assets/**/*"
3434
],
3535
"asarUnpack": [
36-
"models/**"
36+
"models/**",
37+
"assets/openvino-logo.png"
3738
]
3839
},
3940
"devDependencies": {

demos/hide_your_mess_behind_demo/src/ov-jobs.js

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,7 @@ let prevDevice = null;
1919

2020
const inputSize = { w: 256, h: 256 };
2121
let outputMask = null;
22-
23-
const ovLogo = sharp('assets/openvino-logo.png')
24-
.flop()
25-
.composite([{
26-
input: Buffer.from([255, 255, 255, 100]), // 50% transparent white
27-
raw: {
28-
width: 1,
29-
height: 1,
30-
channels: 4
31-
},
32-
tile: true,
33-
blend: 'dest-in'
34-
}])
22+
let ovLogo = null;
3523

3624

3725
async function detectDevices() {
@@ -46,15 +34,37 @@ function average(array){
4634

4735

4836
async function getModelPath() {
49-
const archivePath = path.join(__dirname, '../../app.asar.unpacked/models/selfie_multiclass_256x256.xml');
50-
const devPath = path.join(__dirname, '../models/selfie_multiclass_256x256.xml');
51-
52-
try {
53-
await fs.access(archivePath, fs.constants.F_OK);
54-
return archivePath;
55-
} catch(e) {
56-
return devPath;
37+
if (fs.existsSync(path.join(__dirname, '../../app.asar'))){
38+
//if running compiled program
39+
return path.join(__dirname, "../../app.asar.unpacked/models/selfie_multiclass_256x256.xml");
40+
} else {
41+
//if running npm start
42+
return path.join(__dirname, "../models/selfie_multiclass_256x256.xml");
43+
}
44+
}
45+
46+
47+
function getOvLogo(){
48+
let imgPath = null;
49+
if (fs.existsSync(path.join(__dirname, '../../app.asar'))){
50+
//if running compiled program
51+
imgPath = path.join(__dirname, "../../app.asar.unpacked/assets/openvino-logo.png");
52+
} else {
53+
//if running npm start
54+
imgPath = path.join(__dirname, "../assets/openvino-logo.png");
5755
}
56+
return sharp(imgPath)
57+
.flop()
58+
.composite([{
59+
input: Buffer.from([255, 255, 255, 100]), // 50% transparent white
60+
raw: {
61+
width: 1,
62+
height: 1,
63+
channels: 4
64+
},
65+
tile: true,
66+
blend: 'dest-in'
67+
}])
5868
}
5969

6070

@@ -225,6 +235,9 @@ async function blurImage(image, width, height) {
225235

226236

227237
async function addWatermark(image, width, height) {
238+
if (ovLogo == null){
239+
ovLogo = getOvLogo();
240+
}
228241
const watermarkWidth = Math.floor(width * 0.3);
229242
const watermark = await ovLogo
230243
.resize({ width: watermarkWidth })

0 commit comments

Comments
 (0)