auduno/clmtrackr

emotionClassifier is not a constructor

Technopathic opened this issue · 7 comments

I'm looking at the Emotion Detection demo and I'm trying to re-implement it with my ReactJS project. I'm running into some trouble trying to initialize the emotionClassifier.

What I've tried:

import React from 'react';
import clm from 'clmtrackr';
import * as emotion from '../../libs/emotion_classifier.js';

export default class Home extends React.PureComponent {
    componentWillMount() {
        this.ctrack = new clm.tracker({useWebGL : true});
        this.ctrack.init(pModel);

        this.ec = new emotion.emotionClassifier();
    }
}

Which gives me the error:

Uncaught TypeError: Emotion.emotionClassifier is not a constructor

I'm looking for some advice on how to make this work any help would be appreciated.

@Technopathic - did you manage to implement this into your React JS project? How did you do it?

@Technopathic @elsplatto Did you manage to resolve this problem? I got the same with using clmtrackr with typescript

I figured this out. First check that the files are imported in the right order, in my case:

import * as clm from "./../build/clmtrackr";
import * as pModel from "./../models/model_pca_20_svm";
import * as emotionClassifier from "./emotion_classifier";
import * as emotionModel from "./emotionModel";

Then be sure to remove all the <script> tags in the index.html.

Sorry for the late reply - well done... I just hard coded the emotionModel data as a JSON object. I'll check my code to see if things can be tidied up by using your approach.

Mmmm actually I still have the problem, I thought it was working but I just messed with the files. The problem is with emotion_classifier.js. I think it's maybe a problem with ES6, I found this topic: https://stackoverflow.com/questions/10107198/javascript-not-a-constructor-exception-while-creating-objects , I tried to change with some solutions proposed here but it's not working, I don't really get it.

@Technopathic @elsplatto @mathildebuenerd were any of you able to get it working? I am attempting to use the emotionModel and emotionClassifier in React, and I get the same error.

My bad, but functional implementation, was to insert the libraries in html's head, just like in the old ways, and call those objects directly from within the components in VUE.