356 lines
12 KiB
HTML
356 lines
12 KiB
HTML
|
|
<!DOCTYPE html>
|
|||
|
|
<html lang="zh-CN">
|
|||
|
|
<head>
|
|||
|
|
<meta charset="UTF-8" />
|
|||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|||
|
|
<title>真实体感交互测试</title>
|
|||
|
|
<style>
|
|||
|
|
body {
|
|||
|
|
font-family: Arial, sans-serif;
|
|||
|
|
max-width: 800px;
|
|||
|
|
margin: 50px auto;
|
|||
|
|
padding: 20px;
|
|||
|
|
background-color: #f5f5f5;
|
|||
|
|
}
|
|||
|
|
.container {
|
|||
|
|
background: white;
|
|||
|
|
padding: 30px;
|
|||
|
|
border-radius: 10px;
|
|||
|
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|||
|
|
text-align: center;
|
|||
|
|
}
|
|||
|
|
.feature-list {
|
|||
|
|
text-align: left;
|
|||
|
|
margin: 20px 0;
|
|||
|
|
padding: 20px;
|
|||
|
|
background: #f8f9fa;
|
|||
|
|
border-radius: 8px;
|
|||
|
|
}
|
|||
|
|
.feature-item {
|
|||
|
|
margin: 10px 0;
|
|||
|
|
padding: 10px;
|
|||
|
|
background: white;
|
|||
|
|
border-radius: 5px;
|
|||
|
|
border-left: 4px solid #4ecdc4;
|
|||
|
|
}
|
|||
|
|
.status {
|
|||
|
|
margin: 20px 0;
|
|||
|
|
padding: 15px;
|
|||
|
|
border-radius: 5px;
|
|||
|
|
font-weight: bold;
|
|||
|
|
}
|
|||
|
|
.success {
|
|||
|
|
background: #d4edda;
|
|||
|
|
color: #155724;
|
|||
|
|
border: 1px solid #c3e6cb;
|
|||
|
|
}
|
|||
|
|
.error {
|
|||
|
|
background: #f8d7da;
|
|||
|
|
color: #721c24;
|
|||
|
|
border: 1px solid #f5c6cb;
|
|||
|
|
}
|
|||
|
|
.loading {
|
|||
|
|
background: #d1ecf1;
|
|||
|
|
color: #0c5460;
|
|||
|
|
border: 1px solid #bee5eb;
|
|||
|
|
}
|
|||
|
|
button {
|
|||
|
|
background: #4ecdc4;
|
|||
|
|
color: white;
|
|||
|
|
border: none;
|
|||
|
|
padding: 10px 20px;
|
|||
|
|
border-radius: 5px;
|
|||
|
|
cursor: pointer;
|
|||
|
|
margin: 10px;
|
|||
|
|
}
|
|||
|
|
button:hover {
|
|||
|
|
background: #45b7aa;
|
|||
|
|
}
|
|||
|
|
.test-area {
|
|||
|
|
margin: 20px 0;
|
|||
|
|
padding: 20px;
|
|||
|
|
background: #f0f8ff;
|
|||
|
|
border-radius: 10px;
|
|||
|
|
border: 2px solid #4ecdc4;
|
|||
|
|
}
|
|||
|
|
.game-preview {
|
|||
|
|
display: flex;
|
|||
|
|
justify-content: space-around;
|
|||
|
|
margin: 20px 0;
|
|||
|
|
}
|
|||
|
|
.game-card {
|
|||
|
|
background: white;
|
|||
|
|
padding: 20px;
|
|||
|
|
border-radius: 10px;
|
|||
|
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|||
|
|
width: 200px;
|
|||
|
|
}
|
|||
|
|
.body-sensation-demo {
|
|||
|
|
margin: 20px 0;
|
|||
|
|
padding: 20px;
|
|||
|
|
background: #fff3cd;
|
|||
|
|
border-radius: 10px;
|
|||
|
|
border: 2px solid #ffc107;
|
|||
|
|
}
|
|||
|
|
/* 体感交互容器样式 */
|
|||
|
|
.box-body {
|
|||
|
|
position: fixed;
|
|||
|
|
top: 50%;
|
|||
|
|
left: 50%;
|
|||
|
|
transform: translate(-50%, -50%);
|
|||
|
|
background: rgba(255, 255, 255, 0.95);
|
|||
|
|
border-radius: 15px;
|
|||
|
|
padding: 20px;
|
|||
|
|
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
|
|||
|
|
z-index: 2000;
|
|||
|
|
max-width: 500px;
|
|||
|
|
text-align: center;
|
|||
|
|
}
|
|||
|
|
.box-body img {
|
|||
|
|
max-width: 100%;
|
|||
|
|
height: auto;
|
|||
|
|
border-radius: 10px;
|
|||
|
|
margin: 10px 0;
|
|||
|
|
}
|
|||
|
|
.box-body div {
|
|||
|
|
margin: 10px 0;
|
|||
|
|
padding: 5px;
|
|||
|
|
}
|
|||
|
|
</style>
|
|||
|
|
</head>
|
|||
|
|
<body>
|
|||
|
|
<div class="container">
|
|||
|
|
<h1>🦾 真实体感交互测试</h1>
|
|||
|
|
|
|||
|
|
<div class="feature-list">
|
|||
|
|
<h3>真实体感交互功能:</h3>
|
|||
|
|
<div class="feature-item">
|
|||
|
|
<strong>📹 实时摄像头检测</strong><br />
|
|||
|
|
显示用户的实时视频画面,包含人脸识别和关键点检测
|
|||
|
|
</div>
|
|||
|
|
<div class="feature-item">
|
|||
|
|
<strong>👋 手势识别</strong><br />
|
|||
|
|
检测用户举起左手或右手,并自动选择对应的游戏选项
|
|||
|
|
</div>
|
|||
|
|
<div class="feature-item">
|
|||
|
|
<strong>🎯 状态显示</strong><br />
|
|||
|
|
显示连接状态、检测状态和手势状态信息
|
|||
|
|
</div>
|
|||
|
|
<div class="feature-item">
|
|||
|
|
<strong>🔄 实时反馈</strong><br />
|
|||
|
|
根据检测结果实时更新游戏状态和提示信息
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="body-sensation-demo">
|
|||
|
|
<h3>🎥 体感交互演示</h3>
|
|||
|
|
<p>点击下方按钮启动体感交互系统,系统将:</p>
|
|||
|
|
<ul style="text-align: left; margin: 10px 0">
|
|||
|
|
<li>请求摄像头权限</li>
|
|||
|
|
<li>连接到远程体感检测服务器</li>
|
|||
|
|
<li>显示实时视频画面</li>
|
|||
|
|
<li>检测人脸和手势动作</li>
|
|||
|
|
<li>根据手势自动选择游戏选项</li>
|
|||
|
|
</ul>
|
|||
|
|
<button onclick="startBodySensation()">启动体感交互</button>
|
|||
|
|
<button onclick="stopBodySensation()">停止体感交互</button>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="test-area">
|
|||
|
|
<h3>🧪 游戏测试区域</h3>
|
|||
|
|
<div class="game-preview">
|
|||
|
|
<div class="game-card">
|
|||
|
|
<h4>比大小游戏</h4>
|
|||
|
|
<p>测试比大小游戏的体感交互功能</p>
|
|||
|
|
<button onclick="testCompareGame()">测试比大小</button>
|
|||
|
|
</div>
|
|||
|
|
<div class="game-card">
|
|||
|
|
<h4>示例游戏</h4>
|
|||
|
|
<p>测试示例游戏的体感交互功能</p>
|
|||
|
|
<button onclick="testExampleGame()">测试示例</button>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div id="status" class="status loading">准备测试真实体感交互功能...</div>
|
|||
|
|
|
|||
|
|
<button onclick="testAllGames()">测试所有游戏</button>
|
|||
|
|
<button onclick="checkBodySensationStatus()">检查体感交互状态</button>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<!-- 体感交互容器(用于directBodySensation.js) -->
|
|||
|
|
<div class="box-body" style="display: none">
|
|||
|
|
<div id="bodyConnectionStatus">未连接到服务器</div>
|
|||
|
|
<img id="bodyVideoFeed" src="" alt="体感检测视频" />
|
|||
|
|
<div id="bodyHandStatus">等待检测...</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<!-- 引入必要的脚本 -->
|
|||
|
|
<script src="../js/directBodySensation.js"></script>
|
|||
|
|
|
|||
|
|
<script>
|
|||
|
|
// 启动体感交互
|
|||
|
|
function startBodySensation() {
|
|||
|
|
const statusDiv = document.getElementById("status");
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
statusDiv.className = "status loading";
|
|||
|
|
statusDiv.textContent = "正在启动体感交互系统...";
|
|||
|
|
|
|||
|
|
// 调用体感交互启动函数
|
|||
|
|
if (typeof showBody === "function") {
|
|||
|
|
showBody();
|
|||
|
|
statusDiv.className = "status success";
|
|||
|
|
statusDiv.textContent = "✅ 体感交互系统已启动!请允许摄像头权限。";
|
|||
|
|
} else {
|
|||
|
|
statusDiv.className = "status error";
|
|||
|
|
statusDiv.textContent = "❌ 体感交互系统未加载!";
|
|||
|
|
}
|
|||
|
|
} catch (error) {
|
|||
|
|
statusDiv.className = "status error";
|
|||
|
|
statusDiv.textContent = `❌ 启动体感交互错误: ${error.message}`;
|
|||
|
|
console.error("启动体感交互错误:", error);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 停止体感交互
|
|||
|
|
function stopBodySensation() {
|
|||
|
|
const statusDiv = document.getElementById("status");
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
statusDiv.className = "status loading";
|
|||
|
|
statusDiv.textContent = "正在停止体感交互系统...";
|
|||
|
|
|
|||
|
|
// 调用体感交互停止函数
|
|||
|
|
if (typeof showBody === "function") {
|
|||
|
|
showBody(); // 再次调用会切换状态
|
|||
|
|
statusDiv.className = "status success";
|
|||
|
|
statusDiv.textContent = "✅ 体感交互系统已停止!";
|
|||
|
|
} else {
|
|||
|
|
statusDiv.className = "status error";
|
|||
|
|
statusDiv.textContent = "❌ 体感交互系统未加载!";
|
|||
|
|
}
|
|||
|
|
} catch (error) {
|
|||
|
|
statusDiv.className = "status error";
|
|||
|
|
statusDiv.textContent = `❌ 停止体感交互错误: ${error.message}`;
|
|||
|
|
console.error("停止体感交互错误:", error);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 测试比大小游戏
|
|||
|
|
function testCompareGame() {
|
|||
|
|
const statusDiv = document.getElementById("status");
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
statusDiv.className = "status loading";
|
|||
|
|
statusDiv.textContent = "正在打开比大小游戏...";
|
|||
|
|
|
|||
|
|
// 打开比大小游戏页面
|
|||
|
|
window.open("../html/play/比大小.html", "_blank");
|
|||
|
|
|
|||
|
|
statusDiv.className = "status success";
|
|||
|
|
statusDiv.textContent =
|
|||
|
|
"✅ 比大小游戏已打开!请在新窗口中测试体感交互功能。";
|
|||
|
|
} catch (error) {
|
|||
|
|
statusDiv.className = "status error";
|
|||
|
|
statusDiv.textContent = `❌ 比大小游戏测试错误: ${error.message}`;
|
|||
|
|
console.error("比大小游戏测试错误:", error);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 测试示例游戏
|
|||
|
|
function testExampleGame() {
|
|||
|
|
const statusDiv = document.getElementById("status");
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
statusDiv.className = "status loading";
|
|||
|
|
statusDiv.textContent = "正在打开示例游戏...";
|
|||
|
|
|
|||
|
|
// 打开示例游戏页面
|
|||
|
|
window.open("../html/play/示例游戏.html", "_blank");
|
|||
|
|
|
|||
|
|
statusDiv.className = "status success";
|
|||
|
|
statusDiv.textContent =
|
|||
|
|
"✅ 示例游戏已打开!请在新窗口中测试体感交互功能。";
|
|||
|
|
} catch (error) {
|
|||
|
|
statusDiv.className = "status error";
|
|||
|
|
statusDiv.textContent = `❌ 示例游戏测试错误: ${error.message}`;
|
|||
|
|
console.error("示例游戏测试错误:", error);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 测试所有游戏
|
|||
|
|
function testAllGames() {
|
|||
|
|
const statusDiv = document.getElementById("status");
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
statusDiv.className = "status loading";
|
|||
|
|
statusDiv.textContent = "正在测试所有游戏...";
|
|||
|
|
|
|||
|
|
// 测试比大小游戏
|
|||
|
|
testCompareGame();
|
|||
|
|
|
|||
|
|
// 等待1秒后测试示例游戏
|
|||
|
|
setTimeout(() => {
|
|||
|
|
testExampleGame();
|
|||
|
|
statusDiv.className = "status success";
|
|||
|
|
statusDiv.textContent =
|
|||
|
|
"✅ 所有游戏测试完成!请分别测试体感交互功能。";
|
|||
|
|
}, 1000);
|
|||
|
|
} catch (error) {
|
|||
|
|
statusDiv.className = "status error";
|
|||
|
|
statusDiv.textContent = `❌ 测试所有游戏错误: ${error.message}`;
|
|||
|
|
console.error("测试所有游戏错误:", error);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 检查体感交互状态
|
|||
|
|
function checkBodySensationStatus() {
|
|||
|
|
const statusDiv = document.getElementById("status");
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
// 检查体感交互相关元素
|
|||
|
|
const bodyContainers = document.querySelectorAll(
|
|||
|
|
".body-sensation-container"
|
|||
|
|
);
|
|||
|
|
const videoFeeds = document.querySelectorAll("#bodyVideoFeed");
|
|||
|
|
const connectionStatus = document.querySelectorAll(
|
|||
|
|
"#bodyConnectionStatus"
|
|||
|
|
);
|
|||
|
|
const handStatus = document.querySelectorAll("#bodyHandStatus");
|
|||
|
|
|
|||
|
|
let statusText = `体感交互状态检查:\n`;
|
|||
|
|
statusText += `- 找到 ${bodyContainers.length} 个体感交互容器\n`;
|
|||
|
|
statusText += `- 找到 ${videoFeeds.length} 个视频显示元素\n`;
|
|||
|
|
statusText += `- 找到 ${connectionStatus.length} 个连接状态元素\n`;
|
|||
|
|
statusText += `- 找到 ${handStatus.length} 个手势状态元素\n`;
|
|||
|
|
|
|||
|
|
if (bodyContainers.length > 0) {
|
|||
|
|
statusText += `\n✅ 体感交互视频结构已正确添加!`;
|
|||
|
|
statusDiv.className = "status success";
|
|||
|
|
} else {
|
|||
|
|
statusText += `\n❌ 未找到体感交互视频结构!`;
|
|||
|
|
statusDiv.className = "status error";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
statusDiv.textContent = statusText;
|
|||
|
|
} catch (error) {
|
|||
|
|
statusDiv.className = "status error";
|
|||
|
|
statusDiv.textContent = `❌ 检查体感交互状态错误: ${error.message}`;
|
|||
|
|
console.error("检查体感交互状态错误:", error);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 页面加载完成后自动初始化
|
|||
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|||
|
|
console.log("🦾 真实体感交互测试页面已加载");
|
|||
|
|
|
|||
|
|
const statusDiv = document.getElementById("status");
|
|||
|
|
statusDiv.className = "status success";
|
|||
|
|
statusDiv.textContent =
|
|||
|
|
"✅ 页面加载完成!可以开始测试真实体感交互功能。";
|
|||
|
|
});
|
|||
|
|
</script>
|
|||
|
|
</body>
|
|||
|
|
</html>
|