電子發(fā)燒友App

硬聲App

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示
創(chuàng)作
電子發(fā)燒友網(wǎng)>電子資料下載>電子資料>在Agora Video SDK之上運行AI姿勢檢測

在Agora Video SDK之上運行AI姿勢檢測

2023-06-30 | zip | 0.00 MB | 次下載 | 免費

資料介紹

在 Agora 的 Video SDK 之上運行 AI

?

先決條件:

  • 節(jié)點
  • 火力基地功能
  • Agora Web SDK 3.1.0 或以上
  • Firebase 托管

第一步:注冊 Agora 賬號

Agora 每月提供 10,000 分鐘的免費 sdk 使用時間,可以完美地用于測試應(yīng)用程序。要注冊一個帳戶,請訪問https://sso.agora.io/v2/signup ,您可以從那里開始。

pYYBAGOAIOSAIl8uAAERFqXyFjM229.png
注冊 Agora
?

創(chuàng)建帳戶后,只需創(chuàng)建一個 API 密鑰。

pYYBAGOAIOaAI8BYAAAqhFUVT3E431.png
Agora 儀表板生成臨時令牌
?

。。

。

。

id="output" >
id="image" />

。

imagectx.clearRect(0, 0, $('#output').width(), $('#output').height());

    imagectx.save();
    imagectx.scale(-1, 1);
    imagectx.translate(-$('#output').width(), 0);
    imagectx.drawImage(video, 0, 0, $('#output').width(), $('#output').height());
    imagectx.restore();

第 4 步:在畫布上運行 tfjs

現(xiàn)在我們有了一個可以運行 AI 推理的元素,我們終于可以使用 TFJS。在撰寫本文時,我們正在通過 TF 2.0 進(jìn)行

></script>
script>

我們現(xiàn)在可以在輸出畫布上運行推理

async function poseDetectionFrame() {    
if(!JSON.parse(getMeta("useai")))
{
return;
}
let poses = [];
let minPoseConfidence;
let minPartConfidence;

imagectx.clearRect(0, 0, $('#output').width(), $('#output').height());

imagectx.save();
imagectx.scale(-1, 1);
imagectx.translate(-$('#output').width(), 0);
imagectx.drawImage(video, 0, 0, $('#output').width(), $('#output').height());
imagectx.restore();

const pose = await net.estimatePoses(image, {
flipHorizontal: false,
decodingMethod: 'single-person'
});

ctx.clearRect(0, 0, $('#output').width(), $('#output').height());

ctx.save();
ctx.scale(-1, 1);
ctx.translate(-$('#output').width(), 0);
ctx.drawImage(video, 0, 0, $('#output').width(), $('#output').height());
ctx.restore();

poses = poses.concat(pose);
minPoseConfidence = + 0.15;
minPartConfidence = + 0.1;
// For each pose (i.e. person) detected in an image, loop through the poses
// and draw the resulting skeleton and keypoints if over certain confidence
// Step 5

requestAnimationFrame(poseDetectionFrame);


}
poseDetectionFrame();
setTimeout(function () {
$owlCarouselNew.trigger('refresh.owl.carousel');
}, 1500);
}

第 5 步:獲取 AR 簡筆畫

AR其實很簡單,一旦你掌握了關(guān)鍵點,我們就可以畫出代表實時推理的簡筆畫。現(xiàn)在,我們在 AI 數(shù)據(jù)之上添加了 AR,以便讓用戶更好地展示他們的姿勢。

       poses.forEach(({score, keypoints}) => {

if (score >= minPoseConfidence) {
drawKeypoints(keypoints, minPartConfidence, ctx);
drawSkeleton(keypoints, minPartConfidence, ctx);
/*
if (guiState.output.showBoundingBox) {
drawBoundingBox(keypoints, ctx);
}*/
}
});

通過以下功能

function drawPoint(ctx, y, x, r, color) {
ctx.beginPath();
ctx.arc(x, y, r, 0, 2 * Math.PI);
ctx.fillStyle = color;
ctx.fill();
}

/**
* Draw the bounding box of a pose. For example, for a whole person standing
* in an image, the bounding box will begin at the nose and extend to one of
* ankles
*/
function drawBoundingBox(keypoints, ctx) {
const boundingBox = posenet.getBoundingBox(keypoints);

ctx.rect(
boundingBox.minX, boundingBox.minY, boundingBox.maxX - boundingBox.minX,
boundingBox.maxY - boundingBox.minY);

ctx.strokeStyle = boundingBoxColor;
ctx.stroke();
}

/**
* Draws a line on a canvas, i.e. a joint
*/
function drawSegment([ay, ax], [by, bx], color, scale, ctx) {
ctx.beginPath();
ctx.moveTo(ax * scale, ay * scale);
ctx.lineTo(bx * scale, by * scale);
ctx.lineWidth = lineWidth;
ctx.strokeStyle = color;
ctx.stroke();
}

/**
* Draws a pose skeleton by looking up all adjacent keypoints/joints
*/
function drawSkeleton(keypoints, minConfidence, ctx, scale = 1) {
const adjacentKeyPoints =function drawPoint(ctx, y, x, r, color) {
ctx.beginPath();
ctx.arc(x, y, r, 0, 2 * Math.PI);
ctx.fillStyle = color;
ctx.fill();
}

/**
* Draw the bounding box of a pose. For example, for a whole person standing
* in an image, the bounding box will begin at the nose and extend to one of
* ankles
*/
function drawBoundingBox(keypoints, ctx) {
const boundingBox = posenet.getBoundingBox(keypoints);

ctx.rect(
boundingBox.minX, boundingBox.minY, boundingBox.maxX - boundingBox.minX,
boundingBox.maxY - boundingBox.minY);

ctx.strokeStyle = boundingBoxColor;
ctx.stroke();
}

/**
* Draws a line on a canvas, i.e. a joint
*/
function drawSegment([ay, ax], [by, bx], color, scale, ctx) {
ctx.beginPath();
ctx.moveTo(ax * scale, ay * scale);
ctx.lineTo(bx * scale, by * scale);
ctx.lineWidth = lineWidth;
ctx.strokeStyle = color;
ctx.stroke();
}

/**
* Draws a pose skeleton by looking up all adjacent keypoints/joints
*/
function drawSkeleton(keypoints, minConfidence, ctx, scale = 1) {
const adjacentKeyPoints =
posenet.getAdjacentKeyPoints(keypoints, minConfidence);

adjacentKeyPoints.forEach((keypoints) => {
drawSegment(
toTuple(keypoints[0].position), toTuple(keypoints[1].position), color,
scale, ctx);
});
}

/**
* Draw pose keypoints onto a canvas
*/
function drawKeypoints(keypoints, minConfidence, ctx, scale = 1) {
for (let i = 0; i < keypoints.length; i++) {
const keypoint = keypoints[i];

if (keypoint.score < minConfidence) {
continue;
}

const {y, x} = keypoint.position;
drawPoint(ctx, y * scale, x * scale, 3, color);
}
}

function toTuple({y, x}) {
return [y, x];
}
posenet.getAdjacentKeyPoints(keypoints, minConfidence);

adjacentKeyPoints.forEach((keypoints) => {
drawSegment(
toTuple(keypoints[0].position), toTuple(keypoints[1].position), color,
scale, ctx);
});
}

/**
* Draw pose keypoints onto a canvas
*/
function drawKeypoints(keypoints, minConfidence, ctx, scale = 1) {
for (let i = 0; i < keypoints.length; i++) {
const keypoint = keypoints[i];

if (keypoint.score < minConfidence) {
continue;
}

const {y, x} = keypoint.position;
drawPoint(ctx, y * scale, x * scale, 3, color);
}
}

function toTuple({y, x}) {
return [y, x];
}

最后一步:現(xiàn)場測試并將其集成到生產(chǎn)中

完成所有工作后,測試通過,然后您可以將其集成到您自己的類似類型的應(yīng)用程序中

要在瑜伽課上現(xiàn)場體驗,請訪問https://mixpose.com

poYBAGOX6X2ASqQiAAJxuxgzGnc342.png
https://mixpose.com


下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評論

查看更多

下載排行

本周

  1. 1山景DSP芯片AP8248A2數(shù)據(jù)手冊
  2. 1.06 MB  |  532次下載  |  免費
  3. 2RK3399完整板原理圖(支持平板,盒子VR)
  4. 3.28 MB  |  339次下載  |  免費
  5. 3TC358743XBG評估板參考手冊
  6. 1.36 MB  |  330次下載  |  免費
  7. 4DFM軟件使用教程
  8. 0.84 MB  |  295次下載  |  免費
  9. 5元宇宙深度解析—未來的未來-風(fēng)口還是泡沫
  10. 6.40 MB  |  227次下載  |  免費
  11. 6迪文DGUS開發(fā)指南
  12. 31.67 MB  |  194次下載  |  免費
  13. 7元宇宙底層硬件系列報告
  14. 13.42 MB  |  182次下載  |  免費
  15. 8FP5207XR-G1中文應(yīng)用手冊
  16. 1.09 MB  |  178次下載  |  免費

本月

  1. 1OrCAD10.5下載OrCAD10.5中文版軟件
  2. 0.00 MB  |  234315次下載  |  免費
  3. 2555集成電路應(yīng)用800例(新編版)
  4. 0.00 MB  |  33566次下載  |  免費
  5. 3接口電路圖大全
  6. 未知  |  30323次下載  |  免費
  7. 4開關(guān)電源設(shè)計實例指南
  8. 未知  |  21549次下載  |  免費
  9. 5電氣工程師手冊免費下載(新編第二版pdf電子書)
  10. 0.00 MB  |  15349次下載  |  免費
  11. 6數(shù)字電路基礎(chǔ)pdf(下載)
  12. 未知  |  13750次下載  |  免費
  13. 7電子制作實例集錦 下載
  14. 未知  |  8113次下載  |  免費
  15. 8《LED驅(qū)動電路設(shè)計》 溫德爾著
  16. 0.00 MB  |  6656次下載  |  免費

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935054次下載  |  免費
  3. 2protel99se軟件下載(可英文版轉(zhuǎn)中文版)
  4. 78.1 MB  |  537798次下載  |  免費
  5. 3MATLAB 7.1 下載 (含軟件介紹)
  6. 未知  |  420027次下載  |  免費
  7. 4OrCAD10.5下載OrCAD10.5中文版軟件
  8. 0.00 MB  |  234315次下載  |  免費
  9. 5Altium DXP2002下載入口
  10. 未知  |  233046次下載  |  免費
  11. 6電路仿真軟件multisim 10.0免費下載
  12. 340992  |  191187次下載  |  免費
  13. 7十天學(xué)會AVR單片機(jī)與C語言視頻教程 下載
  14. 158M  |  183279次下載  |  免費
  15. 8proe5.0野火版下載(中文版免費下載)
  16. 未知  |  138040次下載  |  免費