2 回答
TA贡献1816条经验 获得超6个赞
onButtonSubmit缺少}:
onButtonSubmit = () => {
this.setState({imageUrl: this.state.input});
app.models
.predict(
Clarifai.FACE_DETECT_MODEL,
this.state.input)
.then(response => this.calculateFaceLocation(response))
.catch (err => console.log(err));
}; // here it is (should be :))
TA贡献1895条经验 获得超3个赞
我已经清理、格式化并修复了您的代码中缺失的“}”。
import Clarifai from "clarifai";
import Navigation from "./components/Navigation/navigation";
import FaceRecognition from "./components/FaceRecognition/facerecognition";
import Logo from "./components/Logo/logo";
import ImageLinkForm from "./components/ImageLinkForm/imagelinkform";
import Rank from "./components/Rank/rank";
import "./App.css";
import "tachyons";
import Particles from "react-particles-js";
const app = new Clarifai.App({
apiKey: "fec62103a7704ea8b8ae7f951dc0b823",
});
const particlesOptions = {
particles: {
number: {
value: 70,
density: {
enable: true,
value_area: 800,
},
},
},
};
class App extends Component {
constructor() {
super();
this.state = {
input: "",
imageUrl: "",
box: {},
};
}
calculateFaceLocation = (data) => {
const clarifaiFace =
data.output[0].data.regions[0].region_info.bounding_box;
const image = document.getElementById("inputimage");
const width = Number(image.width);
const height = Number(image.height);
console.log(width, height);
};
onInputChange = (event) => {
this.setState({ input: event.target.value });
};
onButtonSubmit = () => {
this.setState({ imageUrl: this.state.input });
app.models
.predict(Clarifai.FACE_DETECT_MODEL, this.state.input)
.then((response) => this.calculateFaceLocation(response))
.catch((err) => console.log(err));
};
render() {
return (
<div className="App">
<Particles className="particles" params={particlesOptions} />,
<Navigation />,
<Logo />,
<Rank />,
<ImageLinkForm
onInputChange={this.onInputChange}
onButtonSubmit={this.onButtonSubmit}
/>
,
<FaceRecognition imageUrl={this.state.imageUrl} />
</div>
);
}
}
export default App;
添加回答
举报