I'm developing an PWA with Ionic 4 and Angular 7.
I need to access the webcam if it exists and then render in a canvas. In this process I use ImageCapture (https://developer.mozilla.org/en-US/docs/Web/API/ImageCapture).
let constrains =
{
audio:false,
video:
{
frameRate: { ideal: 60, min: 30 },
facingMode: { ideal: "user" },
width: { exact: 626 },
height: { exact: 720 },
}
}
navigator.mediaDevices.getUserMedia(constrains).then(mediaStream =>
{
this.Webcam.nativeElement.srcObject = mediaStream;
this.Webcam.nativeElement.play();
const track = mediaStream.getVideoTracks()[0];
let ic:ImageCapture = new ImageCapture(track);
return this.ImageCapture.getPhotoCapabilities();
});
I was getting an error because TypeScript didn't know anything about the ImageCapture, so I installed the typings adding them on my package.json:
npm install --save-dev @types/w3c-image-capture
When building the app with "ionic serve" or "ionic build --prod" I get this error:
ERROR in src/app/pages/photoframe/photoframe-take/photoframe-take.page.ts(26,22): error TS2304: Cannot find name 'ImageCapture'. src/app/pages/photoframe/photoframe-take/photoframe-take.page.ts(117,28): error TS2663: Cannot find name 'ImageCapture'. Did you mean the instance member 'this.ImageCapture'?
If I debug the aplication the ImageCapture has value, so it's only I build problem.
How can I remove this error from my build?