简介
node-red-contrib-cameo 是一个在 Node-RED 上使用的相机节点,支持常见的网络摄像头、USB 摄像头等多种设备。其支持的功能包括视频流预览、录制、拍照等。此外,它还支持使用人工智能进行目标检测和识别。
安装
首先,你需要在你的计算机上安装 Node-RED 和 npm。然后,可以通过以下命令在 Node-RED 节点库中安装 node-red-contrib-cameo:
npm i node-red-contrib-cameo
使用
预览视频流
node-red-contrib-cameo 包含了一个名为 Cameo Camera 的节点,用于预览摄像头的视频流。使用此节点非常简单,只需要将其在 Node-RED 的流编辑器中拖动到画布上,并将其配置为正确的设备即可。例如,如果要使用 USB 摄像头,则可以选择在选项面板中选择 /dev/video0
。
节点还支持配置视频流的大小、帧率和编解码方式等参数。
[{"id":"fbddefa0.64a02","type":"cameo-camera","z":"d2e74b5a.eb5d5","name":"Camera Preview","device":"/dev/video0","width":640,"height":480,"fps":25,"codec":"mjpeg","rotate":0,"vflip":false,"hflip":false,"brightness":50,"Contrast":0,"sharpness":0,"saturation":0,"quality":50,"effect":"none","overlay_text":"","overlay_text_x":0,"overlay_text_y":0,"overlay_text_size":10,"overlay_text_color":"#ffffff","saveas":"","format":"","save":"false","x":260,"y":220,"wires":[]}]
预览节点将产生一个视频流输出,可以将其连接到其他处理节点,例如保存、视频流识别等。
视频录制
Cameo Camera 节点也支持将相机视频流录制为视频文件。使用此功能需要启用录制选项,并配置输出文件名和视频编解码器。在录制期间节点将输出当前录制时间的信息,您可以将其输出到本地调试节点,以便进行调试和错误排除。
[{"id":"fbddefa0.64a02","type":"cameo-camera","z":"d2e74b5a.eb5d5","name":"Camera Preview","device":"/dev/video0","width":640,"height":480,"fps":25,"codec":"mjpeg","rotate":0,"vflip":false,"hflip":false,"brightness":50,"Contrast":0,"sharpness":0,"saturation":0,"quality":50,"effect":"none","overlay_text":"","overlay_text_x":0,"overlay_text_y":0,"overlay_text_size":10,"overlay_text_color":"#ffffff","saveas":"/path/to/video-file.mp4","format":"mp4","save":"true","x":260,"y":220,"wires":[[]]}]
图片拍摄
Cameo Camera 节点还支持拍照并将其保存为图像文件。对于每个拍摄请求,节点将输出图像二进制数据和文件名。
[{"id":"fbddefa0.64a02","type":"cameo-camera","z":"d2e74b5a.eb5d5","name":"Camera Preview","device":"/dev/video0","width":640,"height":480,"fps":25,"codec":"mjpeg","rotate":0,"vflip":false,"hflip":false,"brightness":50,"Contrast":0,"sharpness":0,"saturation":0,"quality":50,"effect":"none","overlay_text":"","overlay_text_x":0,"overlay_text_y":0,"overlay_text_size":10,"overlay_text_color":"#ffffff","saveas":"/path/to/image-file.jpg","format":"jpg","save":"false","x":260,"y":220,"wires":[[]]}]
目标检测
Cameo Camera 节点支持使用 TensorFlow 进行对象检测。在使用前,您需要首先安装 TensorFlow,然后将模型文件放置在本地路径中,并在节点配置中指定模型路径。
例如,要对人脸进行检测,您可以选择一个名为 face_rcnn_resnet101_coco_2018_01_28
的预训练模型。在配置面板中,您需要指定模型路径(例如 /path/to/face_rcnn_resnet101_coco_2018_01_28
),并在节点输出中包含目标坐标和标签。必要时,您可以使用绘图节点将结果可视化。
[{"id":"fbddefa0.64a02","type":"cameo-camera","z":"d2e74b5a.eb5d5","name":"Camera Preview","device":"/dev/video0","width":640,"height":480,"fps":25,"codec":"mjpeg","rotate":0,"vflip":false,"hflip":false,"brightness":50,"Contrast":0,"sharpness":0,"saturation":0,"quality":50,"effect":"none","overlay_text":"","overlay_text_x":0,"overlay_text_y":0,"overlay_text_size":10,"overlay_text_color":"#ffffff","saveas":"","format":"","save":"false","model":"/path/to/face_rcnn_resnet101_coco_2018_01_28","threshold":0.5,"limit":100,"conflict_policy":"preempt","x":260,"y":220,"wires":[[]]}]
总结
Cameo Camera 是一个非常有用的 Node-RED 节点,它为我们提供了一个方便的方式来处理相机数据和图像处理。除了支持视频流预览和录制等基本功能之外,它还支持图像拍摄和深度学习目标检测。此外,我们可以通过调整节点配置来满足我们的特定需求。
来源:JavaScript中文网 ,转载请注明来源 https://www.javascriptcn.com/post/600554b681e8991b448d1ee2