html snapshot控件,javascript - HTML - How to take snapshot from video stream? - Stack Overflow

I am trying to add a button to a webpage that takes a snapshot of a video stream, shows it on the same webpage, and also saves it to a local directory.

The video is streaming from a server and is shown using an img tag. I can see the video but the capture button doesn't do anything:

Capture

Camera Footage

Captured Image

// The button to capture the image

var btnCapture = document.getElementById( "btn-capture" );

// The stream & capture

var stream = document.getElementById( "stream" );

var capture = document.getElementById( "capture" );

var photo = document.getElementById("photo");

// Attach listeners

btnCapture.addEventListener( "click", captureSnapshot );

// Capture Snapshot

function captureSnapshot() {

var ctx = capture.getContext( "2d" );

ctx.drawImage( stream, 0, 0);

photo.src = capture.toDataURL('image/png');

}

<br> HTML Snapshot ActiveX控件 可以把当前整体网页存取为JPG 、BMP 、PNG 、TIFF 和GIF 图象文件。HTML文件可以通过Snapshot ActiveX 容易地转换成图像, 也可以控制JPEG 的压缩质量或改变TIFF 图像压缩方法。<br><br> HTML Snapshot ActiveX控件 可以容易为成千上万网页建立thumbshot 服务器,数据库由用户充分控制。<br><br> HTML Snapshot ActiveX控件 特别适合使用于服务器,并且可以容易地集成支持ActiveX的语言,譬如:Visual C++,Visual Basic, Delphi, C++ Builder和.Net 语言如 C#,VB.Net,Java,以及脚本语言如 Perl,Php,Python,ASP.Net。<br><br> HTML Snapshot ActiveX控件的特点: 直接保存指定URL网页中的bmp 、jpeg 、tiff 、gif 或png 格式图象; 把图象直接改变TML串; 从大图象创造子图象; 得到链接、标题、cookie或页的HTML来源; 得到HTML文件DOM接口; 使用灰度和黑白图象; 在图象中减少颜色数量但保留很好的质量; 支持压缩的图象如jpg 、tiff 、gif 或png,不创建临时文件; 支持JPEG压缩水平和TIFF 压缩方法的选择; 转换VML为bmp 、jpg 、tiff 、gif 或png格式文件; 提供以下环境下的大量实例:Visual C++,Visual Basic,Delphi,C++ Builder和.Net 语言如 C#,VB.Net,Java,以及脚本语言如 Perl,Php,Python,ASP.Net等。 HTML Snapshot ActiveX控件各组件功能: SnapUrl(String strUrl, String strPicFile)主函数将HTML转换成图象; SnapHtmlString(String strHtml, String strPicFile):strUrl: HTML串 strPicFile: 保存本地图像文件; GetThumbnailImage(String strInputFile, String strOutputFile, Long cx, Long cy, Long bRemainRatio):strInputFile: 输入图像文件strOutputFile: 保存子图像文件;cx, cy: 指图图象的维度。bRemainRatio: 如果bRemainRation 是0, 子图象的维数大小将是cx, cy;然后是原始的图象的长宽比; ReduceColor(String strInputFile, String strOutputFile, Long nColors):在输入图象时减少颜色的数目; MakeGrayImage(String strInputFile, String strOutputFile, Long bGrayOrBW):将图象颜色转换成灰色或黑白色; SetCode(String strCode):设置注册码(试用版); SetTimeOut(Long nTimeOut):超时值为SnapUrl毫秒,缺省超时值是30000; SetDelayTime(Long nDelayTime):nDelayTime: 等待一定时间值(毫秒)后HTML文件被下载。 有时,网页包含ActiveX需要初始化。这个方法可以使用控制时间获取动态嵌入的对象内容。缺省nDelayTime 价值是1000 年; EnableActiveX(BOOL bEnable):bEnable: 确定ActiveX是否能在html页中使用; EnableJava(BOOL bEnable):bEnable: 确定Java是否能在html页中使用; EnableScript(BOOL bEnable) :bEnable: 确定Script是否能在html页中使用; SetSnapDimension(long cx, long cy):设置浏览器窗口的宽度和高度。浏览器视窗大小将影响HTML文件大小; SetPostData(String postData):使用这个功能为一些urls提供保护; SetJPEGQuality (long n): 设置JPEG 压缩的质量。n值在0 和100 之间; SetDither(long n):当转换成1bpp 图象时设置励振方法; SetTIFFEncoder(long n):设置TIFF 图象压缩方法。0: LZW;1: CCITT3; 2: CCITT4;3: RLE; 5: 无; SetThreshold(long n):转换图象为黑白图片时,设置阈值(0-255); StringArray GetLinks():在网页上设置退回链接; StringArray GetFrames():在网页上设置退回一些urls框架; String GetTitle():退回网页的标题; String GetSource():退回网页的HTML来源; String GetText()::退回网页的文本; LONG GetImageWidth():退回图象的宽度; LONG GetImageHeight():退回图象的高度; String GetCookie():得到当前的URLCookie; SetCookie(String strURL, String strName, String strData):设置Cookie为URL; GetCookie2(String strURL):得到Cookie为URL; IDispatch GetHtmlDocument():得到HTML文件的IDispatch 接口; ReSnap:在引用SnapUrl以后重获取图像。这个作用将刷新图象,得到到新图象; SetZoom(Double zoomRatio):设置超文字标记语言页的快照徒升比率; GetImageBytes(String imageType):得到被压缩的图象字节。文件格式譬如* jpg, * gif 等; GetThumbImageBytes(String imageType, LONG cx, LONG cy, LONG bRemainRatio):得到被压缩的指图图象字节数。 HTML Snapshot ActiveX控件的系统需求: windows平台,Internet Explorer 5.0以上,互联网连接, 真彩色显示模式
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值