使用 NodeJS 访问网络摄像头 [英] Accessing WebCam with NodeJS

查看:61
本文介绍了使用 NodeJS 访问网络摄像头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有尝试通过节点访问网络摄像头的经验?我似乎找不到任何先前的尝试.

Does anyone have any experience with trying to access a webcam through node? I can't seem to find any prior attempts at this.

稍微扩展一下 - 我有一个 nodeJS 服务器正在运行,我希望能够在 Node 运行的同一台机器上访问网络摄像头(实际上,我更多地使用 node 作为客户端实现).我想做的一些事情 - 从网络摄像头获取图像,或者,如果我可以将流传输到网络摄像头,然后通过管道传输到另一台服务器并传输到其他客户端,那就太棒了 ;)

To expand a bit - I have a nodeJS server running, and I want to be able to access the webcam on the same box Node is running (so really, I'm using node more as a client implementation). Some things I wanted to do - get an image from the webcam, or, it'd be awesome if I could get a stream to the webcam that I pipe to another server and stream to other clients ;)

有谁知道如何做到这一点?

Does anyone know how this can be done?

谢谢

推荐答案

我不认为 N​​ode.js 在处理网络摄像头方面有什么特别之处,无论您使用何种语言或服务器,概念通常都是相同的正在使用.所涉及的硬件以及与该硬件的接口应该定义您的解决方案.

I don't think there's anything specific to Node.js when it comes to working with webcams, the concepts are generally the same no matter what language or server you're using. The hardware involved and the interfaces to that hardware is what should define your solution.

最简单的情况是提供由网络摄像头附带的软件定期保存到磁盘的单个快照,或者您可以制作 系统调用 调用本地过程程序按需保存快照.然后,您可以使用 Node.js 提供一个页面,该页面会定期刷新最新快照.

The simplest case would be to serve individual snapshots that are periodically saved to disk by the webcam's included software, or you can make a system call that invokes a local process or program to save a snapshot on demand. You can then serve a page using Node.js that periodically refreshes the latest snapshot.

或者,您可以使用为操作系统量身定制的控制器直接连接网络摄像头硬件 (DirectShow, Windows 图像采集IKPictureTakerV4L2 等)并创建一个 实时视频流,使用 Node.js 作为传输机制.

Alternatively, you can interface directly with the webcam hardware using a controller tailored to the operating system (DirectShow, Windows Image Acquisition, IKPictureTaker, V4L2, etc.) and create a live video stream using Node.js as the transport mechanism.

如果您的网络摄像头有一个网络接口并且已经提供了一个流媒体服务器,那么您可能需要考虑使用反向代理解决方案,例如使用 nginx 或 Apache.这里有一个解决方案用于代理由 VLC 格式化的网络摄像头流.

If your webcam has a network interface and already offers a streaming server, you might want to look into a reverse proxy solution instead, using nginx or Apache for example. Here is a solution where nginx is being used to proxy a webcam stream formatted by VLC.

这是一个创造性的解决方案,它使用 Node.js 通过获取单个帧、编码图像数据并使用 websocket 将图像数据推送到客户端页面上的画布元素来捕获视频流作为中间服务器.

这篇关于使用 NodeJS 访问网络摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆