Access Webcam in ReactJS. Camera access in React

preview_player
Показать описание
Access Webcam in ReactJS
Рекомендации по теме
Комментарии
Автор

hahaha bro is like "i taught enough, figure that shit out yourself". great tutorial thanks

sudhanshu
Автор

I get the same resolution as the preview in the browser, not the real image. Like if the preview is small the image will be small. Help?

cherubinth
Автор

You just have to store image in state and also use if statement

vishnuuplenchwar
Автор

It was an excellent tutorial. Never mind the slip at the end, it happens to all of us.

KikeVanegas
Автор

I tried the exact code and package. but the camera didnt open. it was allowed in the browser. how to fix it?

rafaelleafar
Автор

great tutorial. To get the img variable, you can use const [img, setImg] = useState(null); and set the value like this const showImage = () => {

}

crazydevSTL
Автор

you just use the usestate and image will be visible due to component refresh

SK_M_u_s_i_c
Автор

const[img, setImage] and <img src={img}/> displays the image

ABHIJITMSAWANT
Автор

This won't work for multiple image capture ...

kapiloliveti
Автор

The basic: when you want to render new data to the page, you must use and store it in state, with useState hook.

Thanks for the video tutorial

yoyopo
Автор

you forgot to store the image in a state

jubalm
Автор

this is what i wrote - working
import Webcam from 'react-webcam'
import { useRef, useState} from 'react';



const WebcomComponent=()=>{
const [imgSrc, setimgSrc] = useState(null);
const webRef = useRef(null);
const capture =()=>{

}

return(
<div>
<Webcam audio={false} ref={webRef} screenshotFormat="image/jpeg" />
<button onClick={capture}>Capture photo</button>
{imgSrc && (<img src={imgSrc} alt='take an emotion ' />
)}
</div>
)
};
export default WebcomComponent;

רקפתקונפורטי
join shbcf.ru