Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import "./LiveFace.scss";
  3. import Grid from '@material-ui/core/Grid';
  4. import faceimage from "./../../../images/face.png";
  5. import { Button } from '@material-ui/core';
  6. import { updateFace } from "./../actions";
  7. import { connect } from "react-redux";
  8. import LinearProgress from '@material-ui/core/LinearProgress';
  9.  
  10.  
  11. export class LiveFace extends Component {
  12.  
  13. constructor() {
  14. super();
  15.  
  16. this.state = {
  17. loading: false,
  18. progress: 0,
  19. }
  20. }
  21.  
  22.  
  23. continue = async (e) => {
  24.  
  25. }
  26.  
  27. componentDidMount = () => {
  28.  
  29. const constraints = { video: { facingMode: 'user' } };
  30.  
  31. if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
  32. navigator.mediaDevices.getUserMedia(constraints)
  33. .then(this.handleSuccess.bind(this)).catch(this.handleError.bind(this));
  34. }
  35.  
  36. }
  37.  
  38. handleSuccess = (stream) => {
  39.  
  40. console.log(this.refs);
  41. this.track = stream.getTracks()[0];
  42. this.refs.video.srcObject = stream;
  43. this.started = true;
  44.  
  45. }
  46.  
  47. handleError = (error) => {
  48. console.error('Error: ', error);
  49. }
  50.  
  51. render() {
  52. const { handleChange } = this.props;
  53. return (
  54. <div id="live">
  55. <div className="videoContainer">
  56. <video ref="video" autoPlay playsInline muted></video>
  57. </div>
  58. <br />
  59. <div className="live-footer">
  60.  
  61. <Button className="live-button" type="submit" variant="contained" onClick={this.start} color="primary">
  62. Start Live Face Capture
  63. </Button>
  64. <br />
  65. <LinearProgress variant="determinate" className="progress-bar" value={this.state.progress} />
  66.  
  67. </div>
  68.  
  69. <canvas ref="canvas" className="screenshotCanvas"></canvas>
  70.  
  71. </div>
  72. )
  73. }
  74. }
  75.  
  76. const mapStateToProps = state => ({
  77. });
  78.  
  79. export default connect(mapStateToProps, {updateFace})(LiveFace);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement