pref: 删除标注页面信息栏, 减小摄像头采集分辨率
This commit is contained in:
24
cam_cap.py
24
cam_cap.py
@@ -82,10 +82,10 @@ def capture_thread():
|
||||
cam_right = cv2.VideoCapture('/dev/videoR')
|
||||
|
||||
# # 设置摄像头分辨率
|
||||
cam_left.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
|
||||
cam_left.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
|
||||
cam_right.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
|
||||
cam_right.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
|
||||
cam_left.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
|
||||
cam_left.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
|
||||
cam_right.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
|
||||
cam_right.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
|
||||
|
||||
while True:
|
||||
ret_left, frame_left = cam_left.read()
|
||||
@@ -104,20 +104,20 @@ def capture_thread():
|
||||
cam_right.release()
|
||||
|
||||
async def send_image_to_web_server(frame_left, frame_right, metadata):
|
||||
"""异步发送图片到Web服务器(留空实现)"""
|
||||
"""异步发送图片到 Web 服务器(留空实现)"""
|
||||
try:
|
||||
# 编码为JPEG
|
||||
# 编码为 JPEG
|
||||
_, jpeg_left = cv2.imencode('.jpg', frame_left)
|
||||
_, jpeg_right = cv2.imencode('.jpg', frame_right)
|
||||
jpeg_left = jpeg_left.tobytes()
|
||||
jpeg_right = jpeg_right.tobytes()
|
||||
|
||||
# HTTP POST请求实现留空
|
||||
# HTTP POST 请求实现留空
|
||||
print(f"Would send frame {metadata['timestamp']} to web server via HTTP POST")
|
||||
# print(f"Client ID: {metadata['client_id']}")
|
||||
cv2.imwrite(f"./saved/left_{metadata['timestamp']}.jpg", frame_left)
|
||||
cv2.imwrite(f"./saved/right_{metadata['timestamp']}.jpg", frame_right)
|
||||
# 这里可以添加实际的HTTP POST请求代码
|
||||
# 这里可以添加实际的 HTTP POST 请求代码
|
||||
# 示例:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
data = aiohttp.FormData()
|
||||
@@ -143,7 +143,7 @@ class ImageServer:
|
||||
self.socket = None
|
||||
|
||||
async def handle_client_request(self, client_id):
|
||||
"""处理客户端请求:获取最新帧并发送到Web服务器"""
|
||||
"""处理客户端请求:获取最新帧并发送到 Web 服务器"""
|
||||
try:
|
||||
# 从缓冲区获取最新帧
|
||||
frame_left, frame_right = image_buffer.get_latest_frames()
|
||||
@@ -158,7 +158,7 @@ class ImageServer:
|
||||
# }
|
||||
}
|
||||
|
||||
# 异步发送图片到Web服务器
|
||||
# 异步发送图片到 Web 服务器
|
||||
asyncio.create_task(send_image_to_web_server(frame_left, frame_right, metadata))
|
||||
|
||||
logger.info(f"Processed request from client {client_id}, frames sent to web server")
|
||||
@@ -179,10 +179,10 @@ class ImageServer:
|
||||
|
||||
while True:
|
||||
try:
|
||||
# 接收客户端请求(客户端ID)
|
||||
# 接收客户端请求(客户端 ID)
|
||||
data = await self.socket.arecv()
|
||||
|
||||
# 解析客户端ID
|
||||
# 解析客户端 ID
|
||||
client_id = data.decode('utf-8') if data else "unknown"
|
||||
# logger.info(f"Received request from client: {client_id}")
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>人工标注</title>
|
||||
<title>Mark</title>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/5.3.1/fabric.min.js"></script>
|
||||
<style>
|
||||
body {
|
||||
@@ -178,16 +178,16 @@
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>人工标注</h1>
|
||||
<h1>ReMark</h1>
|
||||
<a href="/list" class="btn-secondary">返回图片列表</a>
|
||||
</div>
|
||||
|
||||
<div class="info-panel">
|
||||
<!-- <div class="info-panel">
|
||||
<h3>图像信息</h3>
|
||||
<p><strong>图像ID:</strong> <span id="image-id"></span></p>
|
||||
<p><strong>时间戳:</strong> <span id="image-timestamp"></span></p>
|
||||
<p><strong>备注:</strong> <span id="image-comment"></span></p>
|
||||
</div>
|
||||
<p><strong>图像 ID:</strong> <span id="image-id"></span></p>
|
||||
<p><strong>时间戳:</strong> <span id="image-timestamp"></span></p>
|
||||
<p><strong>备注:</strong> <span id="image-comment"></span></p>
|
||||
</div> -->
|
||||
|
||||
<!-- <div class="instructions">
|
||||
<h3>操作说明</h3>
|
||||
@@ -216,8 +216,8 @@
|
||||
</div>
|
||||
|
||||
<div class="status">
|
||||
<p>当前状态: <span id="status-text">请选择一个目标类别开始标注</span></p>
|
||||
<p>当前选中类别: <span id="selected-label">无</span></p>
|
||||
<p>当前状态:<span id="status-text">请选择一个目标类别开始标注</span></p>
|
||||
<p>当前选中类别:<span id="selected-label">无</span></p>
|
||||
</div>
|
||||
|
||||
<button class="btn-primary" id="save-btn">保存标注结果</button>
|
||||
@@ -231,7 +231,7 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 从URL参数获取图像ID
|
||||
// 从 URL 参数获取图像 ID
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const imageId = urlParams.get('id');
|
||||
const side = urlParams.get('side') || 'left';
|
||||
@@ -248,7 +248,7 @@
|
||||
// 页面加载时初始化
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
if (!imageId) {
|
||||
alert('缺少图像ID参数');
|
||||
alert('缺少图像 ID 参数');
|
||||
window.location.href = '/list';
|
||||
return;
|
||||
}
|
||||
@@ -256,7 +256,7 @@
|
||||
window.currentSide = side;
|
||||
document.querySelector('h1').textContent = `人工标注 (${side === 'left' ? '左侧' : '右侧'}图像)`;
|
||||
|
||||
// 初始化Fabric.js画布
|
||||
// 初始化 Fabric.js 画布
|
||||
canvas = new fabric.Canvas('canvas', {
|
||||
selection: false,
|
||||
preserveObjectStacking: true
|
||||
@@ -443,7 +443,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 根据标签ID获取颜色
|
||||
// 根据标签 ID 获取颜色
|
||||
function getColorForLabel(id) {
|
||||
const colorMap = {
|
||||
1: '#28a745', // 绿色 - 弹药箱
|
||||
@@ -461,7 +461,7 @@
|
||||
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||
const images = await response.json();
|
||||
|
||||
// 查找指定ID的图像
|
||||
// 查找指定 ID 的图像
|
||||
const image = images.find(img => img.id == id);
|
||||
if (!image) {
|
||||
throw new Error('未找到指定的图像');
|
||||
@@ -474,14 +474,14 @@
|
||||
document.getElementById('image-timestamp').textContent = new Date(image.timestamp * 1000).toISOString();
|
||||
document.getElementById('image-comment').textContent = image.comment || '无';
|
||||
|
||||
// 根据side参数决定加载哪一侧的图像
|
||||
// 根据 side 参数决定加载哪一侧的图像
|
||||
const imagePath = side === 'left'
|
||||
? `/static/received/left/${image.left_filename}`
|
||||
: `/static/received/right/${image.right_filename}`;
|
||||
|
||||
const imageInfo = side === 'left'
|
||||
? `左摄像头图像: ${image.left_filename}`
|
||||
: `右摄像头图像: ${image.right_filename}`;
|
||||
? `左摄像头图像:${image.left_filename}`
|
||||
: `右摄像头图像:${image.right_filename}`;
|
||||
|
||||
// 更新图像信息显示
|
||||
document.querySelector('.info-panel h3').textContent = imageInfo;
|
||||
@@ -513,7 +513,7 @@
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading image data:', error);
|
||||
alert('加载图像数据失败: ' + error.message);
|
||||
alert('加载图像数据失败:' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,7 +551,7 @@
|
||||
item.className = 'detection-item';
|
||||
item.innerHTML = `
|
||||
<strong>${detection.label} (${detection.categoryId})</strong><br>
|
||||
边界框: [${detection.bbox.join(', ')}]
|
||||
边界框:[${detection.bbox.join(', ')}]
|
||||
`;
|
||||
container.appendChild(item);
|
||||
});
|
||||
@@ -582,7 +582,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 构造与机器标注格式一致的JSON数据
|
||||
// 构造与机器标注格式一致的 JSON 数据
|
||||
const annotationData = {
|
||||
detections: detections.map(d => ({
|
||||
id: d.categoryId,
|
||||
@@ -592,7 +592,7 @@
|
||||
};
|
||||
|
||||
try {
|
||||
// 发送请求更新标注结果,包含side参数
|
||||
// 发送请求更新标注结果,包含 side 参数
|
||||
const response = await fetch('/api/images/manual-detections', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
@@ -600,7 +600,7 @@
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: currentImageData.id,
|
||||
side: window.currentSide, // 添加side参数
|
||||
side: window.currentSide, // 添加 side 参数
|
||||
detections: annotationData.detections
|
||||
})
|
||||
});
|
||||
@@ -618,7 +618,7 @@
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error saving manual annotations:', error);
|
||||
alert('保存失败: ' + error.message);
|
||||
alert('保存失败:' + error.message);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user