【问题标题】:Capture picture from webcam Ext JS从网络摄像头 Ext JS 捕获图片
【发布时间】:2020-02-26 04:43:12
【问题描述】:

我在这里看到了这个教程: https://github.com/mdn/samples-server/blob/master/s/webrtc-capturestill/capture.js

但是我在将它实现到我的代码中时遇到了麻烦,正在寻求一些帮助...

我基本上想要一个面板,您可以在其中按下“拍照”按钮。这将打开一个新的浮动面板,其中网络摄像头的实时流将自动启动,并且您有一个捕获图像的按钮。

    takePicture: function (photoPanel)
    {
        let me = this;

        let capture = Ext.create('Ext.panel.Panel', {
            title: 'Take Picture',
            height: 500,
            width: 750,
            draggable: true,
            closable: true,
            floating: true,
            layout: {
                type: 'vbox',
                pack: 'center',
                align: 'middle'
            },
            items: [
                {
                    xtype: 'container',
                    itemId: 'video',
                    height: 400,
                    width: 350
  // this is where I want the live webcam to stream
                },
                {
                    xtype: 'button',
                    text: 'Take Picture',
                    itemId: 'startbutton',
                    handler: function (btn)
                    {

                    }
    // button to capture the image
                }
            ]
        });
        photoPanel.add(capture).show();
    },

【问题讨论】:

  • 你试过什么?问题出在哪里 ?在takePicture 函数中,您需要启动getUserMedia 并将流回调设置为video 容器。在startbutton 按钮上,您只需从流中创建画布。

标签: javascript extjs webcam


【解决方案1】:

我制作了一个简单的fiddle,根据提供的脚本拍摄照片

【讨论】:

  • 感激不尽!只是一个简单的问题,在代码末尾它说 'photo.setAttribute('src', data); - “照片”说“未解决的变量”,这应该是什么?谢谢
  • 忘记删除了
  • 抱歉再问一个问题,但我注意到当我单击按钮实际拍照时 - 出于某种原因它显示的是低分辨率图像?
  • 我认为这取决于两个值的比率 - 相机分辨率和图像容器的大小。尝试调整容器大小
猜你喜欢
  • 2013-02-09
  • 1970-01-01
  • 2013-01-18
  • 1970-01-01
  • 2020-08-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多