c++ - 是否可以从 OpenPose 库中实时输出 JSON 数据?
问题描述
我正在尝试使用OpenPose姿势估计库(C++)来输出身体位置信息,以便使用SuperCollider创建声音。
JSON信息作为文件输出,我想实时输出数据。我尝试查看 OpenPose 的源代码,但找不到指定输出格式的任何特定部分。“filestream”文件夹中的头文件似乎只包含变量声明,如下图:
#ifndef
OPENPOSE_FILESTREAM_DATA_SAVER_HPP
#define
OPENPOSE_FILESTREAM_DATA_SAVER_HPP
#include <openpose/core/common.hpp>
#include <openpose/utilities/string.hpp>
namespace op
{
class OP_API FileSaver
{
protected:
explicit FileSaver(const std::string& directoryPath);
virtual ~FileSaver();
std::string getNextFileName(const unsigned long long index) const;
std::string getNextFileName(const std::string& fileNameNoExtension) const;
private:
const std::string mDirectoryPath;
};
}
#endif // OPENPOSE_FILESTREAM_DATA_SAVER_HPP
我希望找到一个文件路径或类似的东西,引导我了解数据的输出方向。如果有人熟悉这个库并且可以指出我正确的方向,那将不胜感激。
我的计划是使用Quarks API通过OSC将关键点数据发送到 SuperCollider 。我正在使用 MacOS X 10.11.6。
解决方案
如果您已经下载了 openpose 示例代码,在文件openpose.cpp中,您会找到该行
DEFINE_string(write_json,"","Directory to write OpenPose output in JSON format. It includes body, hand, and face pose keypoints (2-D and 3-D), as well as pose candidates (if `--part_candidates` enabled).");
json输出文件的路径由main的参数--write_json指定。例如:
c:>openpose.exe --video "D:\user\video.avi"--write_json "D:\user\desktop\output.json"
输入是视频“ D:\user\video.avi ”,json 输出是“ D:\user\desktop\output.json ”
注意:如果不使用参数--write_json,则不会写入json输出。
更新 1:如果您想直接访问关键点,您可以按照如何访问姿势关键点
推荐阅读
- javascript - 如何在 jquery 语法函数中发送参数?
- r - R中的正则表达式以反转字符串拆分
- python - 在 __init__ 中创建的 Django 表单字段在 request.POST 中不存在
- javascript - 如何在使用 jquery 或 JavaScript 播放视频之前或不播放视频之前获取所有视频的持续时间?
- postgresql - Postgres:如果列包含null,则使用false更新布尔列
- c# - 何时使用 EF Core 从数据库中真正检索到数据?
- java - 如何申请功能
来自列表的参数(不是列表) - html - 移动元素时如何阻止img晃动?
- azure - Azure AD B2C 并发访问令牌请求
- gcc - 编译llvm时,/usr/local/bin/ar线程太多,占用内存太多