@@ -19,19 +19,7 @@ let prevDevice = null;
1919
2020const inputSize = { w : 256 , h : 256 } ;
2121let 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
3725async function detectDevices ( ) {
@@ -46,15 +34,37 @@ function average(array){
4634
4735
4836async 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
227237async 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