YOLO v5 Series - FFmpeg & (HTML5 + FLV.js ) & ONNX YOLOv5s Integrating


Buffer Iterating

c 复制代码
const int width = 640, height = 640, channels = 3;
const size_t frame_size = width * height * channels;
vector<char> frame_buffer(frame_size);
vector<float> input_tensor_values(1 * channels * height * width);

while (TRUE) {
	cin.read(reinterpret_cast<char*>(frame_buffer.data()), frame_size);
	size_t bytes_read = cin.gcount();
	if (bytes_read == 0) break;
	if (bytes_read != frame_size) {
		cerr << "Error : " << frame_size << ",Read : " << bytes_read << endl;
		break;
	}

	// ⇒ float ⇒ Normalization (HWC : Height-Width-Channel)
	for (size_t i = 0; i < frame_buffer.size(); ++i) {
		input_tensor_values[i] = static_cast<float>(static_cast<unsigned char>(frame_buffer[i])) / 255.0f;
	}

	// ⇒ CHW                    (CHW : Channel-Height-Width)
	for (int c = 0; c < channels; ++c) {
		for (int h = 0; h < height; ++h) {
			for (int w = 0; w < width; ++w) {
				int src_idx = (h * width + w) * channels + c;
				int dst_idx = c * height * width + h * width + w;
				input_tensor_values[dst_idx] = frame_buffer[src_idx];
			}
		}
	}

	// .T.B.D.
}




相关推荐
sugar__salt5 天前
从网页小游戏到数据可视化:掌握 HTML5 Canvas 核心能力
前端·信息可视化·html5
大鱼>5 天前
地平线BPU部署实战:YOLOv8在J5/X3上的算法适配与性能优化
算法·yolo·性能优化
源之缘-OFD先行者5 天前
破界渲染:WinForm下的FFmpeg+Vortice极速推流引擎
ffmpeg·winform·推流·h264
stsdddd5 天前
YOLO系列目标检测数据集大全【第二十九期】
yolo·目标检测·目标跟踪
大鱼>5 天前
YOLO边缘部署深度指南:从YOLOv8n到NPU加速的全链路优化
yolo·aiot
AI棒棒牛5 天前
第 03 讲《监督学习:数据、标签、Loss与训练循环》
人工智能·学习·yolo·目标检测·yolo26
源来猿往5 天前
记ffmpeg-8.1.1 之Android库编译(window)
android·ffmpeg
FL16238631295 天前
国内快递面单识别检测数据集VOC+YOLO格式422张6类别
人工智能·yolo·机器学习
meilindehuzi_a5 天前
从 Canvas 到 Vibe Coding:HTML5 游戏开发入门与 AI 飞机大战实战
前端·人工智能·html5
stsdddd5 天前
YOLO系列目标检测数据集大全【第三十期】
yolo·目标检测·目标跟踪