From 308880892637f7c366c4a4b97e9e9b3a6abb1b5c Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 22 Mar 2013 18:15:48 +0400 Subject: [PATCH] Fix build of various backends --- modules/core/src/gl_core_3_1.cpp | 1 + modules/highgui/src/cap_openni.cpp | 98 ++++++++++++-------------------------- modules/highgui/src/window_QT.cpp | 2 +- 3 files changed, 33 insertions(+), 68 deletions(-) diff --git a/modules/core/src/gl_core_3_1.cpp b/modules/core/src/gl_core_3_1.cpp index 1fe3d82..e8f3718 100644 --- a/modules/core/src/gl_core_3_1.cpp +++ b/modules/core/src/gl_core_3_1.cpp @@ -2,6 +2,7 @@ #include #include "cvconfig.h" #include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" #include "gl_core_3_1.hpp" #ifdef HAVE_OPENGL diff --git a/modules/highgui/src/cap_openni.cpp b/modules/highgui/src/cap_openni.cpp index 0261acb..1ca1406 100644 --- a/modules/highgui/src/cap_openni.cpp +++ b/modules/highgui/src/cap_openni.cpp @@ -48,7 +48,6 @@ # undef HAVE_TBB #endif -#include #include #ifndef i386 @@ -558,8 +557,7 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.Init(); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to initialize the context: " - << cv::String(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to initialize the context: %s\n", xnGetStatusString(status)); return; } @@ -568,17 +566,16 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.EnumerateProductionTrees( XN_NODE_TYPE_DEVICE, NULL, devicesList, 0 ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: " - << cv::String(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: %s\n", xnGetStatusString(status)); return; } // Chose device according to index xn::NodeInfoList::Iterator it = devicesList.Begin(); - for( int i = 0; i < index && it!=devicesList.End(); ++i ) it++; + for( int i = 0; i < index && it!=devicesList.End(); ++i ) it++; if ( it == devicesList.End() ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed device with index " << index << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed device with index %d\n", index); return; } @@ -586,8 +583,7 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.CreateProductionTree( deviceNode, productionNode ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create production tree: " - << cv::String(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create production tree: %s\n", xnGetStatusString(status)); return; } @@ -595,8 +591,7 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.RunXmlScript( XMLConfig.c_str(), scriptNode ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to run xml script: " - << cv::String(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to run xml script: %s\n", xnGetStatusString(status)); return; } @@ -606,20 +601,18 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.EnumerateExistingNodes( depthList, XN_NODE_TYPE_DEPTH ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate depth generators: " - << cv::String(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate depth generators: %s\n", xnGetStatusString(status)); return; } if( depthList.IsEmpty() ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : The device doesn't have depth generator. Such devices aren't supported now." << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : The device doesn't have depth generator. Such devices aren't supported now.\n"); return; } status = depthGenerator.Create( context ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create depth generator: " - << cv::String(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create depth generator: %s\n", xnGetStatusString(status)); return; } @@ -628,8 +621,7 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.EnumerateExistingNodes( imageList, XN_NODE_TYPE_IMAGE ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate image generators: " - << cv::String(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate image generators: %s\n", xnGetStatusString(status)); return; } @@ -638,8 +630,7 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = imageGenerator.Create( context ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create image generator: " - << cv::String(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to create image generator: %s\n", xnGetStatusString(status)); return; } } @@ -666,14 +657,13 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) status = context.StartGeneratingAll(); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to start generating OpenNI data: " - << cv::String(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to start generating OpenNI data: %s\n", xnGetStatusString(status)); return; } if( !readCamerasParams() ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Could not read cameras parameters" << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Could not read cameras parameters\n"); return; } @@ -697,8 +687,7 @@ CvCapture_OpenNI::CvCapture_OpenNI(const char * filename) status = context.Init(); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to initialize the context: " - << cv::String(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to initialize the context: %s\n", xnGetStatusString(status)); return; } @@ -706,8 +695,7 @@ CvCapture_OpenNI::CvCapture_OpenNI(const char * filename) status = context.OpenFileRecording( filename, productionNode ); if( status != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed to open input file (" << filename << "): " - << cv::String(xnGetStatusString(status)) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Failed to open input file (%s): %s\n", filename, xnGetStatusString(status)); return; } @@ -716,7 +704,7 @@ CvCapture_OpenNI::CvCapture_OpenNI(const char * filename) if( !readCamerasParams() ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Could not read cameras parameters" << std::endl; + fprintf(stderr, "CvCapture_OpenNI::CvCapture_OpenNI : Could not read cameras parameters\n"); return; } @@ -736,7 +724,7 @@ bool CvCapture_OpenNI::readCamerasParams() XnDouble pixelSize = 0; if( depthGenerator.GetRealProperty( "ZPPS", pixelSize ) != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::readCamerasParams : Could not read pixel size!" << std::endl; + fprintf(stderr, "CvCapture_OpenNI::readCamerasParams : Could not read pixel size!\n"); return false; } @@ -747,13 +735,13 @@ bool CvCapture_OpenNI::readCamerasParams() XnUInt64 zeroPlanDistance; // in mm if( depthGenerator.GetIntProperty( "ZPD", zeroPlanDistance ) != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::readCamerasParams : Could not read virtual plane distance!" << std::endl; + fprintf(stderr, "CvCapture_OpenNI::readCamerasParams : Could not read virtual plane distance!\n"); return false; } if( depthGenerator.GetRealProperty( "LDDIS", baseline ) != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::readCamerasParams : Could not read base line!" << std::endl; + fprintf(stderr, "CvCapture_OpenNI::readCamerasParams : Could not read base line!\n"); return false; } @@ -765,13 +753,13 @@ bool CvCapture_OpenNI::readCamerasParams() if( depthGenerator.GetIntProperty( "ShadowValue", shadowValue ) != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::readCamerasParams : Could not read property \"ShadowValue\"!" << std::endl; + fprintf(stderr, "CvCapture_OpenNI::readCamerasParams : Could not read property \"ShadowValue\"!\n"); return false; } if( depthGenerator.GetIntProperty("NoSampleValue", noSampleValue ) != XN_STATUS_OK ) { - std::cerr << "CvCapture_OpenNI::readCamerasParams : Could not read property \"NoSampleValue\"!" <setMaxTimeDuration(maxTimeDuration); break; default: - { - cv::Stringstream ss; - ss << "Such parameter (propIdx=" << propIdx << ") isn't supported for setting.\n"; - CV_Error( CV_StsBadArg, ss.str().c_str() ); - } + CV_Error( CV_StsBadArg, cv::format("Such parameter (propIdx=%d) isn't supported for setting.\n", propIdx) ); } return isSet; @@ -977,11 +957,7 @@ double CvCapture_OpenNI::getDepthGeneratorProperty( int propIdx ) propValue = depthGenerator.GetFrameID(); break; default : - { - cv::Stringstream ss; - ss << "Depth generator does not support such parameter (propIdx=" << propIdx << ") for getting.\n"; - CV_Error( CV_StsBadArg, ss.str().c_str() ); - } + CV_Error( CV_StsBadArg, cv::format("Depth generator does not support such parameter (propIdx=%d) for getting.\n", propIdx) ); } return propValue; @@ -1009,12 +985,12 @@ bool CvCapture_OpenNI::setDepthGeneratorProperty( int propIdx, double propValue { XnStatus status = depthGenerator.GetAlternativeViewPointCap().SetViewPoint(imageGenerator); if( status != XN_STATUS_OK ) - std::cerr << "CvCapture_OpenNI::setDepthGeneratorProperty : " << xnGetStatusString(status) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::setDepthGeneratorProperty : %s\n", xnGetStatusString(status)); else isSet = true; } else - std::cerr << "CvCapture_OpenNI::setDepthGeneratorProperty : Unsupported viewpoint." << std::endl; + fprintf(stderr, "CvCapture_OpenNI::setDepthGeneratorProperty : Unsupported viewpoint.\n"); } else isSet = true; @@ -1024,18 +1000,14 @@ bool CvCapture_OpenNI::setDepthGeneratorProperty( int propIdx, double propValue { XnStatus status = depthGenerator.GetAlternativeViewPointCap().ResetViewPoint(); if( status != XN_STATUS_OK ) - std::cerr << "CvCapture_OpenNI::setDepthGeneratorProperty : " << xnGetStatusString(status) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::setDepthGeneratorProperty : %s\n", xnGetStatusString(status)); else isSet = true; } } break; default: - { - cv::Stringstream ss; - ss << "Depth generator does not support such parameter (propIdx=" << propIdx << ") for setting.\n"; - CV_Error( CV_StsBadArg, ss.str().c_str() ); - } + CV_Error( CV_StsBadArg, cv::format("Depth generator does not support such parameter (propIdx=%d) for setting.\n", propIdx) ); } return isSet; @@ -1073,11 +1045,7 @@ double CvCapture_OpenNI::getImageGeneratorProperty( int propIdx ) propValue = imageGenerator.GetFrameID(); break; default : - { - cv::Stringstream ss; - ss << "Image generator does not support such parameter (propIdx=" << propIdx << ") for getting.\n"; - CV_Error( CV_StsBadArg, ss.str().c_str() ); - } + CV_Error( CV_StsBadArg, cv::format("Image generator does not support such parameter (propIdx=%d) for getting.\n", propIdx) ); } return propValue; @@ -1128,17 +1096,13 @@ bool CvCapture_OpenNI::setImageGeneratorProperty( int propIdx, double propValue XnStatus status = imageGenerator.SetMapOutputMode( mode ); if( status != XN_STATUS_OK ) - std::cerr << "CvCapture_OpenNI::setImageGeneratorProperty : " << xnGetStatusString(status) << std::endl; + fprintf(stderr, "CvCapture_OpenNI::setImageGeneratorProperty : %s\n", xnGetStatusString(status)); else isSet = true; break; } default: - { - cv::Stringstream ss; - ss << "Image generator does not support such parameter (propIdx=" << propIdx << ") for setting.\n"; - CV_Error( CV_StsBadArg, ss.str().c_str() ); - } + CV_Error( CV_StsBadArg, cv::format("Image generator does not support such parameter (propIdx=%d) for setting.\n", propIdx) ); } return isSet; diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index 50f2b9e..7717bde 100644 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -949,7 +949,7 @@ void GuiReceiver::showImage(QString name, void* arr) mat = cvGetMat(arr, &stub); cv::Mat im(mat); - cv::imshow(name.toStdString(), im); + cv::imshow(name.toUtf8().data(), im); } else { -- 2.7.4