File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -75,13 +75,27 @@ function snapshotBoundingBoxes(img) {
7575
7676 ctx . font = FONT ;
7777 ctx . fillStyle = color ;
78- const TEXT_OFFSET = - 10 ;
79- ctx . fillText ( p . class , p . bbox [ 0 ] , p . bbox [ 1 ] + TEXT_OFFSET ) ;
78+
79+ var textPos = bbTextPosition ( p . bbox [ 0 ] , p . bbox [ 1 ] , p . bbox [ 3 ] ) ;
80+ ctx . fillText ( p . class , textPos . x , textPos . y ) ;
8081 } ) ;
8182 } ) ;
8283 } ) ;
8384}
8485
86+ function bbTextPosition ( x , y , height ) {
87+ const TEXT_OFFSET_X = 3 ;
88+ const TEXT_OFFSET_Y = - 10 ;
89+ const TEXT_MIN_Y = 13 ;
90+ var shiftX = x + TEXT_OFFSET_X ;
91+ var shiftY = y + TEXT_OFFSET_Y ;
92+ if ( shiftY < TEXT_MIN_Y ) {
93+ return { x : shiftX , y : shiftY + height } ;
94+ } else {
95+ return { x : shiftX , y : shiftY } ;
96+ }
97+ }
98+
8599function swapToVideo ( ) {
86100 var constraints = { audio : false , video : { facingMode : { ideal : "environment" } } } ;
87101
You can’t perform that action at this time.
0 commit comments