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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
