【发布时间】:2017-09-28 19:14:42
【问题描述】:
我正在尝试使用广泛引用的 LINEMOD 论文中用于 6D 姿势估计的数据集。 他们的数据集在http://campar.in.tum.de/Main/StefanHinterstoisser
他们的深度数据似乎是一次性的格式,需要一个特殊的函数来加载。我需要编写一个 C++ 程序来包装依赖于 OpenCV 的提供的函数,并找出从对象中提取数字并导出的最佳方法。对于整天使用 Python 和其他高级语言的人来说,这是困难的/费力的。我想知道是否有其他人已经完成了将深度数字转换为更通用或 python 友好格式的工作?我环顾四周,但一无所获。
此外,C++ 程序很简短,但对我未经训练的眼睛来说却是含糊不清的。我怀疑精通 C++/opencv 和 Python 的人可以查看源代码和一个优雅的程序来在 python 中进行类似的文件读取?为方便起见,我将其内容粘贴在下面。
http://campar.in.tum.de/personal/hinterst/index/downloads!09384230443!/loadDepth.txt
IplImage * loadDepth( std::string a_name )
{
std::ifstream l_file(a_name.c_str(),std::ofstream::in|std::ofstream::binary );
if( l_file.fail() == true )
{
printf("cv_load_depth: could not open file for writing!\n");
return NULL;
}
int l_row;
int l_col;
l_file.read((char*)&l_row,sizeof(l_row));
l_file.read((char*)&l_col,sizeof(l_col));
IplImage * lp_image = cvCreateImage(cvSize(l_col,l_row),IPL_DEPTH_16U,1);
for(int l_r=0;l_r<l_row;++l_r)
{
for(int l_c=0;l_c<l_col;++l_c)
{
l_file.read((char*)&CV_IMAGE_ELEM(lp_image,unsigned short,l_r,l_c),sizeof(unsigned short));
}
}
l_file.close();
return lp_image;
}
感谢您对此的帮助!
【问题讨论】:
标签: python c++ opencv graphics computer-vision