本文整理汇总了C++中Viewer::addFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewer::addFrame方法的具体用法?C++ Viewer::addFrame怎么用?C++ Viewer::addFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Viewer
的用法示例。
在下文中一共展示了Viewer::addFrame方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
Streamer streamer; // have to declare it outside statements to be accessible everywhere
Recorder recorder;
if(streamer_enabled)
{
streamer.initialize();
}
if(recorder_enabled)
{
recorder.initialize();
}
/// [loop start]
while(!protonect_shutdown && (framemax == (size_t)-1 || framecount < framemax))
{
if (!listener.waitForNewFrame(frames, 10*1000)) // 10 sconds
{
std::cout << "timeout!" << std::endl;
return -1;
}
libfreenect2::Frame *rgb = frames[libfreenect2::Frame::Color];
libfreenect2::Frame *ir = frames[libfreenect2::Frame::Ir];
libfreenect2::Frame *depth = frames[libfreenect2::Frame::Depth];
/// [loop start]
if (enable_rgb && enable_depth)
{
/// [registration]
registration->apply(rgb, depth, &undistorted, ®istered);
/// [registration]
}
framecount++;
if (streamer_enabled)
{
streamer.stream(depth);
}
if (recorder_enabled)
{
// TODO: add recording timestamp if max frame number reached
// + avoid recording new ones
recorder.record(depth, "depth");
recorder.record(®istered, "registered");
// recorder.record(rgb,"rgb");
recorder.registTimeStamp();
}
if (!viewer_enabled)
{
if (framecount % 100 == 0)
std::cout << "The viewer is turned off. Received " << framecount << " frames. Ctrl-C to stop." << std::endl;
listener.release(frames);
continue;
}
#ifdef EXAMPLES_WITH_OPENGL_SUPPORT
if (enable_rgb)
{
viewer.addFrame("RGB", rgb);
}
if (enable_depth)
{
viewer.addFrame("ir", ir);
viewer.addFrame("depth", depth);
}
if (enable_rgb && enable_depth)
{
viewer.addFrame("registered", ®istered);
}
protonect_shutdown = protonect_shutdown || viewer.render();
#endif
/// [loop end]
listener.release(frames);
/** libfreenect2::this_thread::sleep_for(libfreenect2::chrono::milliseconds(100)); */
}
/// [loop end]
if (recorder_enabled)
{
recorder.saveTimeStamp();
}
// TODO: restarting ir stream doesn't work!
// TODO: bad things will happen, if frame listeners are freed before dev->stop() :(
/// [stop]
dev->stop();
dev->close();
/// [stop]
delete registration;
return 0;
}
示例2: main
//.........这里部分代码省略.........
if(!pipeline)
pipeline = new libfreenect2::OpenCLPacketPipeline();
#else
std::cout << "OpenCL pipeline is not supported!" << std::endl;
#endif
}
else if(arg.find_first_not_of("0123456789") == std::string::npos) //check if parameter could be a serial number
{
serial = arg;
}
else if(arg == "-noviewer")
{
viewer_enabled = false;
}
else
{
std::cout << "Unknown argument: " << arg << std::endl;
}
}
if(pipeline)
{
dev = freenect2.openDevice(serial, pipeline);
}
else
{
dev = freenect2.openDevice(serial);
}
if(dev == 0)
{
std::cout << "failure opening device!" << std::endl;
return -1;
}
signal(SIGINT,sigint_handler);
protonect_shutdown = false;
libfreenect2::SyncMultiFrameListener listener(libfreenect2::Frame::Color | libfreenect2::Frame::Ir | libfreenect2::Frame::Depth);
libfreenect2::FrameMap frames;
libfreenect2::Frame undistorted(512, 424, 4), registered(512, 424, 4);
dev->setColorFrameListener(&listener);
dev->setIrAndDepthFrameListener(&listener);
dev->start();
std::cout << "device serial: " << dev->getSerialNumber() << std::endl;
std::cout << "device firmware: " << dev->getFirmwareVersion() << std::endl;
libfreenect2::Registration* registration = new libfreenect2::Registration(dev->getIrCameraParams(), dev->getColorCameraParams());
size_t framecount = 0;
#ifdef LIBFREENECT2_WITH_OPENGL_SUPPORT
Viewer viewer;
if (viewer_enabled)
viewer.initialize();
#else
viewer_enabled = false;
#endif
while(!protonect_shutdown)
{
listener.waitForNewFrame(frames);
libfreenect2::Frame *rgb = frames[libfreenect2::Frame::Color];
libfreenect2::Frame *ir = frames[libfreenect2::Frame::Ir];
libfreenect2::Frame *depth = frames[libfreenect2::Frame::Depth];
registration->apply(rgb, depth, &undistorted, ®istered);
framecount++;
if (!viewer_enabled)
{
if (framecount % 100 == 0)
std::cout << "The viewer is turned off. Received " << framecount << " frames. Ctrl-C to stop." << std::endl;
listener.release(frames);
continue;
}
#ifdef LIBFREENECT2_WITH_OPENGL_SUPPORT
viewer.addFrame("RGB", rgb);
viewer.addFrame("ir", ir);
viewer.addFrame("depth", depth);
viewer.addFrame("registered", ®istered);
protonect_shutdown = protonect_shutdown || viewer.render();
#endif
listener.release(frames);
//libfreenect2::this_thread::sleep_for(libfreenect2::chrono::milliseconds(100));
}
// TODO: restarting ir stream doesn't work!
// TODO: bad things will happen, if frame listeners are freed before dev->stop() :(
dev->stop();
dev->close();
delete registration;
return 0;
}
示例3: main
//.........这里部分代码省略.........
types |= libfreenect2::Frame::Color;
if (enable_depth)
types |= libfreenect2::Frame::Ir | libfreenect2::Frame::Depth;
libfreenect2::SyncMultiFrameListener listener(types);
libfreenect2::FrameMap frames;
dev->setColorFrameListener(&listener);
dev->setIrAndDepthFrameListener(&listener);
/// [listeners]
/// [start]
if (enable_rgb && enable_depth)
{
if (!dev->start())
return -1;
}
else
{
if (!dev->startStreams(enable_rgb, enable_depth))
return -1;
}
std::cout << "device serial: " << dev->getSerialNumber() << std::endl;
std::cout << "device firmware: " << dev->getFirmwareVersion() << std::endl;
/// [start]
/// [registration setup]
libfreenect2::Registration* registration = new libfreenect2::Registration(dev->getIrCameraParams(), dev->getColorCameraParams());
libfreenect2::Frame undistorted(512, 424, 4), registered(512, 424, 4);
/// [registration setup]
size_t framecount = 0;
#ifdef EXAMPLES_WITH_OPENGL_SUPPORT
Viewer viewer;
if (viewer_enabled)
viewer.initialize();
#else
viewer_enabled = false;
#endif
/// [loop start]
while(!protonect_shutdown)
{
listener.waitForNewFrame(frames);
libfreenect2::Frame *rgb = frames[libfreenect2::Frame::Color];
libfreenect2::Frame *ir = frames[libfreenect2::Frame::Ir];
libfreenect2::Frame *depth = frames[libfreenect2::Frame::Depth];
/// [loop start]
if (enable_rgb && enable_depth)
{
/// [registration]
registration->apply(rgb, depth, &undistorted, ®istered);
/// [registration]
}
framecount++;
if (!viewer_enabled)
{
if (framecount % 100 == 0)
std::cout << "The viewer is turned off. Received " << framecount << " frames. Ctrl-C to stop." << std::endl;
listener.release(frames);
continue;
}
#ifdef EXAMPLES_WITH_OPENGL_SUPPORT
if (enable_rgb)
{
viewer.addFrame("RGB", rgb);
}
if (enable_depth)
{
viewer.addFrame("ir", ir);
viewer.addFrame("depth", depth);
}
if (enable_rgb && enable_depth)
{
viewer.addFrame("registered", ®istered);
}
protonect_shutdown = protonect_shutdown || viewer.render();
#endif
/// [loop end]
listener.release(frames);
/** libfreenect2::this_thread::sleep_for(libfreenect2::chrono::milliseconds(100)); */
}
/// [loop end]
// TODO: restarting ir stream doesn't work!
// TODO: bad things will happen, if frame listeners are freed before dev->stop() :(
/// [stop]
dev->stop();
dev->close();
/// [stop]
delete registration;
return 0;
}