I'm trying to call Clarifai's color API to receive the different colors in an image. However, I'm having some difficulty calling the API, as I'm always getting empty objects back.
This is the code used to call the API:
private app;
obj: RootObject ;
constructor(private _http: HttpClient) {
this.app = new Clarifai.App({
ApiKey: "CENSOR BAR"
});
};
public getColorValues(imageUrl: string): RootObject {
this.app.models.predict('eeed0b6733a644cea07cf4c60f87ebb7', imageUrl).then(
function (response) {
this.obj = response;
},
function (error) {
this.obj = "There was an error";
}
);
let i: number;
while (this.obj == null) {
i += 1;
}
console.log("Waited " + i + " cycles for response.")
console.log("Object: " + this.obj);
return this.obj;
}