File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -101,17 +101,17 @@ class ImageClassifier {
101
101
await tf . nextFrame ( ) ;
102
102
103
103
// Classify the image using the selected model
104
- if ( this . video ) {
105
- if ( this . video . readyState >= 2 ) {
104
+ /* eslint arrow-body-style: 0 */
105
+ if ( this . videoElt && ! this . addedListener ) {
106
+ /* eslint func-names: 0 */
107
+ this . video . addEventListener ( 'onloadstart' , function ( ) {
106
108
return this . model . classify ( imgToPredict , numberOfClasses ) . then ( ( predictions ) => {
107
109
if ( callback ) {
108
110
callback ( predictions ) ;
109
111
}
110
112
} ) ;
111
- }
112
- if ( callback ) {
113
- callback ( [ ] ) ;
114
- }
113
+ } ) ;
114
+ this . addedListener = true ;
115
115
}
116
116
return this . model . classify ( imgToPredict , numberOfClasses ) . then ( ( predictions ) => {
117
117
if ( callback ) {
You can’t perform that action at this time.
0 commit comments