angular - 使用 ngx-webcam 捕获图像后暂停或冻结图像
问题描述
按下相机按钮后,我想冻结窗口中的网络摄像头视频(例如图片)。但我不确定是否可以使用ngx-webcam 选项
我查看了传入的不同选项,并尝试了几个不同的选项,例如:
[captureImageData]="真"
我尝试通过这样的打字稿访问和拍照
@ViewChild('webcam') webcamComp: 网络摄像头组件;this.webcamComp.takeSnapshot(); // 触发 imageCaptured()
但似乎没有任何效果。
这是我拍摄网络摄像头图像的一些代码
imageBase64: any;
croppedImage: any;
deviceId: string;
webcamImage: WebcamImage = null;
trigger: Subject<void> = new Subject<void>();
nextWebcam: Subject<boolean|string> = new Subject<boolean|string>();
imageCaptured(webcamImage: WebcamImage): void {
this.webcamImage = webcamImage;
this.imageBase64 = webcamImage.imageAsDataUrl;
// other code here
}
get triggerObservable(): Observable<void> {
return this.trigger.asObservable();
}
get nextWebcamObservable(): Observable<boolean|string> {
return this.nextWebcam.asObservable();
}
cameraWasSwitched(deviceId: string): void {
this.deviceId = deviceId;
}
triggerSnapshot(): void {
this.trigger.next();
}
showNextWebcam(directionOrDeviceId: boolean|string): void {
this.nextWebcam.next(directionOrDeviceId);
}
<webcam *ngIf="showWebcam"
(imageCapture)="imageCaptured($event)"
(initError)="handleInitError($event)"
[trigger]="triggerObservable"
[allowCameraSwitch]="true"
[switchCamera]="nextWebcamObservable"
[width]="webcamWidth"
[height]="webcamHeight"
[captureImageData]="true"
(cameraSwitched)="cameraWasSwitched($event)">
</webcam>
我可以从现场演示中看到您可以将图像放在 img 源中,但我想使用图像代替网络摄像头(冻结图像)。我不想在页面的其他区域显示它。
解决方案
推荐阅读
- c# - 如何自动检测arduino用来传递数据的COM端口?C#
- javascript - 如何使用 VANILLA JS 按住右键单击来执行 eventListener
- php - 尝试在插件中使用 foreach 访问购物车项目,但在管理员 wordpress 中的编辑和设置页面上出现严重错误
- r - 用线性趋势替换数据框缺失值
- r - 将数据从 SQL Server 数据库快速导入 RSStudio
- html - 隐藏一个 div,但仅当它在另一个特定的 div 类中时
- html - 如何在彼此下方垂直对齐按钮
- google-chrome - 为什么某些网站在 Google Chrome DevTools 中没有显示 replay xhr
- firebase - 尝试在生产中进行条带付款时收到错误“错误:请求失败,状态码为 408”
- machine-learning - 深度自动编码器-解码器结构中的 Keras NoneTypeError / 形状错误