我克隆了这个存储库:
OpenPose/DLIB Gesture, Action and Face Recognition.
resolution: 640x480
net_resolution: 656x368
handNetInputSize: 368x368
face_net_resolution: 368x368
cCamera Resolution set to: 640x480
Push following keys:
p for pause sample generation
f for generating face samples
t for train samples
c for continue camera feed
h for display key commands
q for quit program
terminate called after throwing an instance of 'boost::archive::archive_exception'
what(): unsupported version
构建并运行,出现此错误:
https://github.com/srianant/computer_vision/blob/master/openpose/src/openpose/user_code/pose_model.cpp
此文件抛出此异常:line:32
https://github.com/srianant/computer_vision/blob/master/openpose/train_data/pose/pose.model
我认为它正在尝试反序列化此文件:
document.getElementById('kode_barang').value = kode_barang[id].name;
document.getElementById('nama_barang').value = kode_barang[id].desc;
答案 0 :(得分:0)
你可能做错了什么:你检查过你的升级版吗?它可能(非常)老了。
我可以反序化所有使用boost的输入档案。
增强的唯一用途是在ScrollView
中,正在阅读的唯一档案是来自训练数据的文本档案。
很容易创建一个独立的程序来验证这些文件是否可以反序列化。
从pose_model.hpp中提取:
openpose_recognition.cpp
所有提取都遵循相同的模式,让我们稍后添加// Timesteps per samples
const int timesteps = 5; // 5 frames per sample
// 2-dim data to store different postures
const int max_pose_count = 10;
const int max_pose_score_pair = 36; // 34 pairs for pose + 2 padding for multiples of 4
typedef std::array<std::string, max_pose_count> pose;
typedef std::array<double,max_pose_score_pair*timesteps> pose_sample_type;
// 2-dim data to store different hand actions
const int max_hand_count = 10;
const int max_hand_score_pair = 40; // 40 pairs for hand
typedef std::array<std::string,max_hand_count> hand;
typedef std::array<double,max_hand_score_pair*timesteps> hand_sample_type;
// 2-dim data to store different faces
const int max_face_count = 10;
const int max_face_score_pair = 96; // 96 pairs (94 + 2 pairs for padding for multiples of 4)
typedef std::array<std::string,max_face_count> face;
typedef std::array<double,max_face_score_pair*timesteps> face_sample_type;
方法:
debug_print
注意:调整路径以匹配您的文件位置
template <typename T>
void read_and_verify(std::string name, T& into) {
std::ifstream ifs("/tmp/so/computer_vision/openpose/train_data/" + name);
boost::archive::text_iarchive ia(ifs);
ia >> into;
debug_print(name, into);
}
对于名称,样本和标签,我们只需要三个不同的int main() {
{
pose pose_names;
std::vector<pose_sample_type> pose_samples; // vector of m_pose_sample vectors
std::vector<double> pose_labels; // vector of pose labels (eg. 1,2,3...)
read_and_verify("pose/pose_names.txt", pose_names);
read_and_verify("pose/pose_samples.txt", pose_samples);
read_and_verify("pose/pose_labels.txt", pose_labels);
}
{
face face_names; // vector of face emotions names (eg. normal, sad, happy...)
std::vector<face_sample_type> face_samples; // vector of m_face_sample vectors
std::vector<double> face_labels; // vector of face emotions labels (eg. 1,2,3...)
read_and_verify("face/face_names.txt", face_names);
read_and_verify("face/face_samples.txt", face_samples);
read_and_verify("face/face_labels.txt", face_labels);
}
{
hand hand_names; // vector of hand gesture names (eg. fist, victory, stop...);
std::vector<hand_sample_type> left_hand_samples; // vector of m_left_hand_sample vectors
std::vector<hand_sample_type> right_hand_samples; // vector of m_right_hand_sample vectors
std::vector<double> left_hand_labels; // vector of left hand labels (eg. 1,2,3...)
std::vector<double> right_hand_labels; // vector of right hand labels (eg. 1,2,3...)
read_and_verify("hand/hand_names.txt", hand_names);
read_and_verify("hand/left_hand_samples.txt", left_hand_samples);
read_and_verify("hand/right_hand_samples.txt", right_hand_samples);
read_and_verify("hand/left_hand_labels.txt", left_hand_labels);
read_and_verify("hand/right_hand_labels.txt", right_hand_labels);
}
}
重载:
debug_print
完整的程序在这里:
<强> Live On Coliru 强>
template <size_t N> // names
void debug_print(std::string name, std::array<std::string, N> const& data) {
std::cout << name << ": ";
for (auto& n : data)
if (!n.empty())
std::cout << n << " ";
std::cout << "\n";
}
// labels
void debug_print(std::string name, std::vector<double> const& data) {
std::cout << name << ": ";
for (auto& a : data)
std::cout << a << " ";
std::cout << "\n";
}
template <size_t N> // samples
void debug_print(std::string name, std::vector<std::array<double, N> > const& data) {
std::cout << name << ": ";
for (auto& a : data)
std::cout << "{" << a[0] << "...} ";
std::cout << "\n";
}
打印(截断为100个字符的行):
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/vector.hpp>
#include <fstream>
#include <iostream>
///////////////// from pose_model.hpp
//
// Timesteps per samples
const int timesteps = 5; // 5 frames per sample
// 2-dim data to store different postures
const int max_pose_count = 10;
const int max_pose_score_pair = 36; // 34 pairs for pose + 2 padding for multiples of 4
typedef std::array<std::string, max_pose_count> pose;
typedef std::array<double,max_pose_score_pair*timesteps> pose_sample_type;
// 2-dim data to store different hand actions
const int max_hand_count = 10;
const int max_hand_score_pair = 40; // 40 pairs for hand
typedef std::array<std::string,max_hand_count> hand;
typedef std::array<double,max_hand_score_pair*timesteps> hand_sample_type;
// 2-dim data to store different faces
const int max_face_count = 10;
const int max_face_score_pair = 96; // 96 pairs (94 + 2 pairs for padding for multiples of 4)
typedef std::array<std::string,max_face_count> face;
typedef std::array<double,max_face_score_pair*timesteps> face_sample_type;
//
///////////////// end pose_model.hpp
template <size_t N> // names
void debug_print(std::string name, std::array<std::string, N> const& data) {
std::cout << name << ": ";
for (auto& n : data)
if (!n.empty())
std::cout << n << " ";
std::cout << "\n";
}
// labels
void debug_print(std::string name, std::vector<double> const& data) {
std::cout << name << ": ";
for (auto& a : data)
std::cout << a << " ";
std::cout << "\n";
}
template <size_t N> // samples
void debug_print(std::string name, std::vector<std::array<double, N> > const& data) {
std::cout << name << ": ";
for (auto& a : data)
std::cout << "{" << a[0] << "...} ";
std::cout << "\n";
}
template <typename T>
void read_and_verify(std::string name, T& into) {
std::ifstream ifs("/tmp/so/computer_vision/openpose/train_data/" + name);
boost::archive::text_iarchive ia(ifs);
ia >> into;
debug_print(name, into);
}
int main() {
{
pose pose_names;
std::vector<pose_sample_type> pose_samples; // vector of m_pose_sample vectors
std::vector<double> pose_labels; // vector of pose labels (eg. 1,2,3...)
read_and_verify("pose/pose_names.txt", pose_names);
read_and_verify("pose/pose_samples.txt", pose_samples);
read_and_verify("pose/pose_labels.txt", pose_labels);
}
{
face face_names; // vector of face emotions names (eg. normal, sad, happy...)
std::vector<face_sample_type> face_samples; // vector of m_face_sample vectors
std::vector<double> face_labels; // vector of face emotions labels (eg. 1,2,3...)
read_and_verify("face/face_names.txt", face_names);
read_and_verify("face/face_samples.txt", face_samples);
read_and_verify("face/face_labels.txt", face_labels);
}
{
hand hand_names; // vector of hand gesture names (eg. fist, victory, stop...);
std::vector<hand_sample_type> left_hand_samples; // vector of m_left_hand_sample vectors
std::vector<hand_sample_type> right_hand_samples; // vector of m_right_hand_sample vectors
std::vector<double> left_hand_labels; // vector of left hand labels (eg. 1,2,3...)
std::vector<double> right_hand_labels; // vector of right hand labels (eg. 1,2,3...)
read_and_verify("hand/hand_names.txt", hand_names);
read_and_verify("hand/left_hand_samples.txt", left_hand_samples);
read_and_verify("hand/right_hand_samples.txt", right_hand_samples);
read_and_verify("hand/left_hand_labels.txt", left_hand_labels);
read_and_verify("hand/right_hand_labels.txt", right_hand_labels);
}
}
我不得不使用黑客来规避Coliru的文件大小限制:我改为代码来读取bzip2压缩文件:
pose/pose_names.txt: unknown close_to_camera standing sitting
pose/pose_samples.txt: {204.658...} {196.314...} {210.322...} {191.529...} {192.8...} {187.155...} {...
pose/pose_labels.txt: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
face/face_names.txt: unknown normal happy sad surprise
face/face_samples.txt: {89.5967...} {93.7026...} {97.6529...} {91.7247...} {91.8048...} {91.3076...}...
face/face_labels.txt: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
hand/hand_names.txt: unknown fist pinch wave victory stop thumbsup
hand/left_hand_samples.txt: {0...} {0.000524104...} {0...} {0...} {0...} {0...} {0...} {0...} {0...}...
hand/right_hand_samples.txt: {0...} {0.00166845...} {0.00161618...} {0.00176376...} {0.00167096...} ...
hand/left_hand_labels.txt: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
hand/right_hand_labels.txt: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
现在您实际上可以看到输出 Live On Coliru
答案 1 :(得分:0)
在所有txt文件中用:: archive 12替换:: archive 14后,这个问题消失了,@非常感谢