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.
}




相关推荐
m0_747124536 小时前
多媒体框架 FFmpeg 和 GStreamer
ffmpeg·gstreamer
li-xun7 小时前
我的在线工具箱继续升级:新增 Token 计算器、AI 提示词生成器和开发者格式化工具
javascript·django·html5
bryant_meng11 小时前
【YOLO-Master】When YOLO-Master Sees Ghosts
yolo·moe·yolo-master
前网易架构师-高司机11 小时前
带标注的土豆马铃薯病叶数据集,识别6种病害和健康叶,识别率93.4%,3718张图,支持yolo,coco json,voc xml,文末有模型训练代码
yolo·数据集·病害·病叶·叶子·马铃薯·土豆
小鹿研究点东西11 小时前
AI直播系统怎么搭?
人工智能·ffmpeg·自动化·音视频·语音识别
Nightwish513 小时前
Oracle 数据库巡检检查清单
数据库·oracle·ffmpeg
FL16238631291 天前
户外垃圾类型检测数据集VOC+YOLO格式4278张10类别
人工智能·yolo·机器学习
luoyayun3611 天前
Qt/QML + FFmpeg 实现多音频文件顺序拼接功能
qt·ffmpeg·音频拼接
前网易架构师-高司机1 天前
带标注的番茄成熟颜色识别数据集,可识别红色,橙色,绿色,识别率80.6%,2517张图,支持yolo,coco json,voc xml,文末有模型训练代码
yolo·数据集·颜色·番茄·西红柿·成熟·红色
YOLO视觉与编程1 天前
jetson orin nano烧录jetpack7.2系统
人工智能·深度学习·yolo·目标检测·机器学习