Tensorflow.js是Google开发的开源库,用于在浏览器或节点环境中运行机器学习模型和深度学习神经网络。
tf.data.webcam() 函数用于创建从网络摄像头视频流生成张量的迭代器。
注意:当设备包含网络摄像头时,它仅适用于浏览器环境。
用法:
tf.data.webcam(webcamVideoElement?, webcamConfig?)
参数:
- webcamVideoElement:它用于从网络摄像头播放视频。
- webcamConfig:它是一个对象,包含使用网络摄像头从视频流中操作和读取数据的配置。
返回值:它返回一个 Promise。
范例1:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Webcam promise return
let camera = await tf.data.webcam(document.createElement('video'));
// Image camera capture promise return.
let image = await camera.capture();
// Printing the result.
image.print();
// Stopping the camera.
camera.stop();输出:
Tensor
[[[168, 176, 185],
[164, 171, 180],
[161, 169, 178],
...,
[43 , 91 , 74 ],
[37 , 90 , 70 ],
[41 , 94 , 74 ]],
[[165, 172, 181],
[166, 174, 182],
[164, 171, 180],
...,
[45 , 93 , 77 ],
[38 , 92 , 71 ],
[41 , 94 , 74 ]],
[[152, 174, 178],
[156, 178, 182],
[158, 178, 182],
...,
[60 , 89 , 79 ],
[56 , 90 , 74 ],
[55 , 89 , 73 ]],
...
[[150, 174, 98 ],
[147, 171, 95 ],
[136, 168, 87 ],
...,
[13 , 27 , 2 ],
[21 , 29 , 8 ],
[21 , 29 , 8 ]],
[[134, 170, 92 ],
[138, 173, 96 ],
[130, 169, 84 ],
...,
[16 , 33 , 0 ],
[22 , 33 , 7 ],
[21 , 32 , 6 ]],
[[132, 167, 90 ],
[130, 165, 88 ],
[128, 167, 82 ],
...,
[19 , 36 , 3 ],
[24 , 35 , 9 ],
[22 , 33 , 7 ]]]相关用法
- PHP imagecreatetruecolor()用法及代码示例
- p5.js year()用法及代码示例
- d3.js d3.utcTuesdays()用法及代码示例
- PHP ImagickDraw getTextAlignment()用法及代码示例
- PHP Ds\Sequence last()用法及代码示例
- PHP Imagick floodFillPaintImage()用法及代码示例
- PHP array_udiff_uassoc()用法及代码示例
- PHP geoip_continent_code_by_name()用法及代码示例
- d3.js d3.map.set()用法及代码示例
- PHP GmagickPixel setcolor()用法及代码示例
- PHP opendir()用法及代码示例
- PHP cal_to_jd()用法及代码示例
- d3.js d3.bisectLeft()用法及代码示例
- PHP stream_get_transports()用法及代码示例
注:本文由纯净天空筛选整理自singh_teekam大神的英文原创作品 Tensorflow.js tf.data.webcam() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
