• 大小: 7.32MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-24
  • 语言: 其他
  • 标签: opencv  结构光  

资源简介

opencv扩展库,结构光代码,生成指定分辨率的结构光,并保存,example_structured_light_cap_pattern

资源截图

代码片段和文件信息

#include 
#include 
#include 
#include 
#include 
using namespace cv;
using namespace std;
static const char* keys =
{ “{@path |aaa | Path of the folder where the captured pattern images will be save }“
“{@proj_width      |608 | Projector width            }“
“{@proj_height     |684 | Projector height           }“ };
static void help()
{
cout << “\nThis example shows how to use the \“Structured Light module\“ to acquire a graycode pattern“
“\nCall (with the two cams connected):\n“
“./example_structured_light_cap_pattern    \n“
<< endl;
}
int main(int argc char** argv)
{
structured_light::GrayCodePattern::Params params;
CommandLineParser parser(argc argv keys);
String path = parser.get(0);
params.width = parser.get(1);
params.height = parser.get(2);
if (path.empty() || params.width < 1 || params.height < 1)
{
help();
return -1;
}
// Set up GraycodePattern with params
Ptr graycode = structured_light::GrayCodePattern::create(params);
// Storage for pattern
vector pattern;
graycode->generate(pattern);
cout << pattern.size() << “ pattern images + 2 images for shadows mask computation to acquire with both cameras“
<< endl;
// Generate the all-white and all-black images needed for shadows mask computation
Mat white;
Mat black;
graycode->getImagesForShadowMasks(black white);
pattern.push_back(white);
pattern.push_back(black);
// Setting pattern window on second monitor (the projector‘s one)
//namedWindow(“Pattern Window“ WINDOW_NORMAL);
//resizeWindow(“Pattern Window“ params.width params.height);
//moveWindow(“Pattern Window“ params.width + 316 -20);
//setWindowProperty(“Pattern Window“ WND_PROP_FULLSCREEN WINDOW_FULLSCREEN);

for (int i = 0; i < pattern.size(); i++)
{
char name1[30] = “gray_code_“;
char name2[] = “.bmp“;
char num[2];
itoa(i num 10);
strcat(name1 num);
strcat(name1 name2);
imwrite(name1 pattern[i]);
cout << “正在保存第“< }
waitKey(0);

//// Open camera number 1 using libgphoto2
//VideoCapture cap1(CAP_GPHOTO2);
//if (!cap1.isOpened())
//{
// // check if cam1 opened
// cout << “cam1 not opened!“ << endl;
// help();
// return -1;
//}
//// Open camera number 2
//VideoCapture cap2(1);
//if (!cap2.isOpened())
//{
// // check if cam2 opened
// cout << “cam2 not opened!“ << endl;
// help();
// return -1;
//}
//// Turning off autofocus
//cap1.set(CAP_PROP_SETTINGS 1);
//cap2.set(CAP_PROP_SETTINGS 1);
//int i = 0;
//while (i < (int)pattern.size())
//{
// cout << “Waiting to save image number “ << i + 1 << endl << “Press any key to acquire the photo“ << endl;
// imshow(“Pattern Window“ pattern[i]);
// Mat frame1;
// Mat frame2;
// cap1 >> frame1;  // get a new fram

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-01-11 10:48  test_1\
     目录           0  2018-01-07 12:14  test_1\Debug\
     文件       77824  2018-01-07 12:28  test_1\Debug\test_1.exe
     文件      555972  2018-01-07 12:28  test_1\Debug\test_1.ilk
     文件     1821696  2018-01-07 12:28  test_1\Debug\test_1.pdb
     目录           0  2018-01-07 12:11  test_1\Release\
     文件       17408  2018-01-11 10:17  test_1\Release\test_1.exe
     文件      830464  2018-01-11 10:17  test_1\Release\test_1.pdb
     目录           0  2018-01-11 10:47  test_1\test_1\
     文件    19333120  2018-01-11 10:48  test_1\test_1.sdf
     文件         964  2018-01-07 12:26  test_1\test_1.sln
     文件       39424  2018-01-11 10:48  test_1\test_1.v12.suo
     文件          15  2017-12-18 10:36  test_1\test_1\123.txt
     目录           0  2018-01-07 12:21  test_1\test_1\Debug\
     文件      222438  2018-01-07 12:21  test_1\test_1\Debug\main.obj
     文件        2790  2018-01-07 12:28  test_1\test_1\Debug\test_1.log
     目录           0  2018-01-07 12:28  test_1\test_1\Debug\test_1.tlog\
     文件        1086  2018-01-07 12:21  test_1\test_1\Debug\test_1.tlog\cl.command.1.tlog
     文件       34094  2018-01-07 12:21  test_1\test_1\Debug\test_1.tlog\CL.read.1.tlog
     文件         586  2018-01-07 12:21  test_1\test_1\Debug\test_1.tlog\CL.write.1.tlog
     文件        4660  2018-01-07 12:28  test_1\test_1\Debug\test_1.tlog\link.command.1.tlog
     文件       11070  2018-01-07 12:28  test_1\test_1\Debug\test_1.tlog\link.read.1.tlog
     文件         278  2018-01-07 12:28  test_1\test_1\Debug\test_1.tlog\link.write.1.tlog
     文件         156  2018-01-07 12:28  test_1\test_1\Debug\test_1.tlog\test_1.lastbuildstate
     文件     1100800  2018-01-07 12:21  test_1\test_1\Debug\vc120.idb
     文件      970752  2018-01-07 12:21  test_1\test_1\Debug\vc120.pdb
     文件      172153  2018-01-04 08:41  test_1\test_1\Debug\源.obj
     文件        5358  2018-01-11 10:17  test_1\test_1\main.cpp
     目录           0  2018-01-11 10:17  test_1\test_1\Release\
     文件     1310424  2018-01-11 10:17  test_1\test_1\Release\main.obj
     文件         388  2018-01-11 10:47  test_1\test_1\Release\test_1.log
............此处省略12个文件信息

评论

共有 条评论