本文整理汇总了C++中openni::VideoStream::setVideoMode方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoStream::setVideoMode方法的具体用法?C++ VideoStream::setVideoMode怎么用?C++ VideoStream::setVideoMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openni::VideoStream
的用法示例。
在下文中一共展示了VideoStream::setVideoMode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setONI2StreamMode
/*
void openni::VideoMode::setResolution()
Setter function for the resolution of this VideoMode. Application use of this function is not recommended.
Instead, use SensorInfo::getSupportedVideoModes() to obtain a list of valid video modes
-- cited from OpenNI2 help. setResolution() is not recommended.
*/
bool setONI2StreamMode(openni::VideoStream& stream, int w, int h, int fps, openni::PixelFormat format){
//std::cout << "Ask mode: " << w << "x" << h << " " << fps << " fps. format " << format << std::endl;
bool found = false;
const openni::Array<openni::VideoMode>& modes = stream.getSensorInfo().getSupportedVideoModes();
for(int i = 0, i_end = modes.getSize();i < i_end;++i){
// std::cout << "Mode: " << modes[i].getResolutionX() << "x" << modes[i].getResolutionY() << " " << modes[i].getFps() << " fps. format " << modes[i].getPixelFormat() << std::endl;
if(modes[i].getResolutionX() != w){
continue;
}
if(modes[i].getResolutionY() != h){
continue;
}
if(modes[i].getFps() != fps){
continue;
}
if(modes[i].getPixelFormat() != format){
continue;
}
openni::Status rc = stream.setVideoMode(modes[i]);
if(rc != openni::STATUS_OK){
return false;
}
return true;
}
return false;
}
示例2: setONI2StreamMode
bool setONI2StreamMode(openni::VideoStream& stream, int w, int h, int fps, openni::PixelFormat format){
/*
void openni::VideoMode::setResolution()
Setter function for the resolution of this VideoMode. Application use of this function is not recommended.
Instead, use SensorInfo::getSupportedVideoModes() to obtain a list of valid video modes
-- cited from OpenNI2 help. setResolution() is not recommended.
*/
bool found = false;
const openni::Array<openni::VideoMode>& modes = stream.getSensorInfo().getSupportedVideoModes();
for(int i = 0, i_end = modes.getSize();i < i_end;++i){
if(modes[i].getResolutionX() != w){
continue;
}
if(modes[i].getResolutionY() != h){
continue;
}
if(modes[i].getPixelFormat() != format){
continue;
}
openni::Status rc = stream.setVideoMode(modes[i]);
if(rc != openni::STATUS_OK){
printf("%s:Couldn't find RGB stream:\n%s\n", __FUNCTION__, openni::OpenNI::getExtendedError());
return false;
}
return true;
}
return false;
}
示例3: setDepthVideoMode
void setDepthVideoMode(int mode)
{
bool bIsStreamOn = g_bIsDepthOn;
if (bIsStreamOn)
{
g_bIsDepthOn = false;
g_depthStream.stop();
}
g_depthStream.setVideoMode(g_depthSensorInfo->getSupportedVideoModes()[mode]);
if (bIsStreamOn)
{
g_depthStream.start();
g_bIsDepthOn = true;
}
}
示例4: setIRVideoMode
void setIRVideoMode(int mode)
{
bool bIsStreamOn = g_bIsIROn;
if (bIsStreamOn)
{
g_bIsIROn = false;
g_irStream.stop();
}
g_irFrame.release();
g_irStream.setVideoMode(g_irSensorInfo->getSupportedVideoModes()[mode]);
if (bIsStreamOn)
{
g_irStream.start();
g_bIsIROn = true;
}
}
示例5: open
void open(const char* uri) {
if (device.open(uri) != openni::STATUS_OK)
BOOST_THROW_EXCEPTION(GrabberException("Failed to open device")
<< GrabberException::ErrorInfo(openni::OpenNI::getExtendedError()));
if (color_stream.create(device, openni::SENSOR_COLOR) != openni::STATUS_OK)
BOOST_THROW_EXCEPTION(GrabberException("Failed to create color stream")
<< GrabberException::ErrorInfo(openni::OpenNI::getExtendedError()));
openni::VideoMode color_mode;
color_mode.setFps(30);
color_mode.setResolution(color_image_resolution.width, color_image_resolution.height);
color_mode.setPixelFormat(openni::PIXEL_FORMAT_RGB888);
color_stream.setVideoMode(color_mode);
color_image_size = color_image_resolution.width * color_image_resolution.height * 3;
color_stream.setMirroringEnabled(false);
if (color_stream.start() != openni::STATUS_OK) {
color_stream.destroy();
BOOST_THROW_EXCEPTION(GrabberException("Failed to start color stream")
<< GrabberException::ErrorInfo(openni::OpenNI::getExtendedError()));
}
streams.push_back(&color_stream);
auto control = device.getPlaybackControl();
if (control != nullptr) {
// This is a file, make sure we get every frame
control->setSpeed(-1.0f);
control->setRepeatEnabled(false);
num_frames = control->getNumberOfFrames(color_stream);
is_file = true;
if (num_frames == -1)
BOOST_THROW_EXCEPTION(GrabberException("Unable to determine number of frames in ONI file"));
}
}
示例6: initialize
int SensorOpenNI::initialize()
{
LOG(INFO) << "Initializing OpenNI";
///< force shutdown before starting!!
kinect::OpenNI::shutdown();
kinect::Status rc;
rc = kinect::STATUS_OK;
/// Fetch the device URI to pass to Device::open()
const char* deviceURI = kinect::ANY_DEVICE;
/// Initialize the device
rc = kinect::OpenNI::initialize();
if(rc!=kinect::STATUS_OK)
{
mDebug()<<"Initialization Errors (if any): "<< kinect::OpenNI::getExtendedError();
kinect::OpenNI::shutdown();
exit(0);
}
/// Open the device using the previously fetched device URI
rc = device.open(deviceURI);
if (rc != kinect::STATUS_OK)
{
mDebug()<<"Device open failed: "<<kinect::OpenNI::getExtendedError();
kinect::OpenNI::shutdown();
exit(0);
}
/// Create the depth stream
rc = g_depthStream.create(device, kinect::SENSOR_DEPTH);
if (rc == kinect::STATUS_OK)
{
/// start the depth stream, if its creation was successful
rc = g_depthStream.start();
if (rc != kinect::STATUS_OK)
{
mDebug()<<"Couldn't start depth stream: "<<kinect::OpenNI::getExtendedError();
g_depthStream.destroy();
exit(0);
}
}
else
{
mDebug()<<"Couldn't find depth stream: "<<kinect::OpenNI::getExtendedError();
exit(0);
}
if (!g_depthStream.isValid())
{
mDebug()<<"No valid depth streams. Exiting";
kinect::OpenNI::shutdown();
exit(0);
}
/// Create the color stream
rc = g_colorStream.create(device, kinect::SENSOR_COLOR);
if (rc == kinect::STATUS_OK)
{
/// start the color stream, if its creation was successful
rc = g_colorStream.start();
if (rc != kinect::STATUS_OK)
{
mDebug()<<"Couldn't start color stream: "<<kinect::OpenNI::getExtendedError();
g_colorStream.destroy();
exit(0);
}
}
else
{
mDebug()<<"Couldn't find color stream: "<<kinect::OpenNI::getExtendedError();
exit(0);
}
if (!g_colorStream.isValid())
{
mDebug()<<"No valid color streams. Exiting";
kinect::OpenNI::shutdown();
exit(0);
}
/// Configure resolutions
{
/// Attempt to set for depth
{
kinect::VideoMode mode = g_depthStream.getVideoMode();
if(((int)camera->FPS())==60)
mode.setFps(60);
else
mode.setFps(30);
mode.setResolution(camera->width(), camera->height());
rc = g_depthStream.setVideoMode(mode);
if (rc != kinect::STATUS_OK)
std::cerr << "error setting video mode (depth)" << std::endl;
}
/// Attempt to set for color
//.........这里部分代码省略.........