Commit c1a6cb62 authored by Maria Dimashova's avatar Maria Dimashova

added oni-files reading

parent 82a2a50f
This diff is collapsed.
...@@ -93,9 +93,11 @@ void printCommandLineParams() ...@@ -93,9 +93,11 @@ void printCommandLineParams()
cout << "-m Mask to set which output images are need. It is a string of size 5. Each element of this is '0' or '1' and" << endl; cout << "-m Mask to set which output images are need. It is a string of size 5. Each element of this is '0' or '1' and" << endl;
cout << " determine: is depth map, disparity map, valid pixels mask, rgb image, gray image need or not (correspondently)?" << endl ; cout << " determine: is depth map, disparity map, valid pixels mask, rgb image, gray image need or not (correspondently)?" << endl ;
cout << " By default -m 01010 i.e. disparity map and rgb image will be shown." << endl ; cout << " By default -m 01010 i.e. disparity map and rgb image will be shown." << endl ;
cout << "-r Filename of .oni video file. The data will grabbed from it." << endl ;
} }
void parseCommandLine( int argc, char* argv[], bool& isColorizeDisp, bool& isFixedMaxDisp, int& imageMode, bool retrievedImageFlags[] ) void parseCommandLine( int argc, char* argv[], bool& isColorizeDisp, bool& isFixedMaxDisp, int& imageMode, bool retrievedImageFlags[],
string& filename, bool& isFileReading )
{ {
// set defaut values // set defaut values
isColorizeDisp = true; isColorizeDisp = true;
...@@ -108,6 +110,9 @@ void parseCommandLine( int argc, char* argv[], bool& isColorizeDisp, bool& isFix ...@@ -108,6 +110,9 @@ void parseCommandLine( int argc, char* argv[], bool& isColorizeDisp, bool& isFix
retrievedImageFlags[3] = true; retrievedImageFlags[3] = true;
retrievedImageFlags[4] = false; retrievedImageFlags[4] = false;
filename.clear();
isFileReading = false;
if( argc == 1 ) if( argc == 1 )
{ {
help(); help();
...@@ -154,6 +159,11 @@ void parseCommandLine( int argc, char* argv[], bool& isColorizeDisp, bool& isFix ...@@ -154,6 +159,11 @@ void parseCommandLine( int argc, char* argv[], bool& isColorizeDisp, bool& isFix
exit(0); exit(0);
} }
} }
else if( !strcmp( argv[i], "-r" ) )
{
filename = argv[++i];
isFileReading = true;
}
else else
{ {
cout << "Unsupported command line argument: " << argv[i] << "." << endl; cout << "Unsupported command line argument: " << argv[i] << "." << endl;
...@@ -172,10 +182,17 @@ int main( int argc, char* argv[] ) ...@@ -172,10 +182,17 @@ int main( int argc, char* argv[] )
bool isColorizeDisp, isFixedMaxDisp; bool isColorizeDisp, isFixedMaxDisp;
int imageMode; int imageMode;
bool retrievedImageFlags[5]; bool retrievedImageFlags[5];
parseCommandLine( argc, argv, isColorizeDisp, isFixedMaxDisp, imageMode, retrievedImageFlags ); string filename;
bool isVideoReading;
parseCommandLine( argc, argv, isColorizeDisp, isFixedMaxDisp, imageMode, retrievedImageFlags, filename, isVideoReading );
cout << "Device opening ..." << endl; cout << "Device opening ..." << endl;
VideoCapture capture( CV_CAP_OPENNI ); VideoCapture capture;
if( isVideoReading )
capture.open( filename );
else
capture.open( CV_CAP_OPENNI );
cout << "done." << endl; cout << "done." << endl;
if( !capture.isOpened() ) if( !capture.isOpened() )
...@@ -184,37 +201,41 @@ int main( int argc, char* argv[] ) ...@@ -184,37 +201,41 @@ int main( int argc, char* argv[] )
return -1; return -1;
} }
bool modeRes=false; if( !isVideoReading )
switch ( imageMode )
{ {
case 0: bool modeRes=false;
modeRes = capture.set( CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, CV_CAP_OPENNI_VGA_30HZ ); switch ( imageMode )
break; {
case 1: case 0:
modeRes = capture.set( CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, CV_CAP_OPENNI_SXGA_15HZ ); modeRes = capture.set( CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, CV_CAP_OPENNI_VGA_30HZ );
break; break;
case 2: case 1:
modeRes = capture.set( CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, CV_CAP_OPENNI_SXGA_30HZ ); modeRes = capture.set( CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, CV_CAP_OPENNI_SXGA_15HZ );
break; break;
default: case 2:
CV_Error( CV_StsBadArg, "Unsupported image mode property.\n"); modeRes = capture.set( CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, CV_CAP_OPENNI_SXGA_30HZ );
break;
default:
CV_Error( CV_StsBadArg, "Unsupported image mode property.\n");
}
if (!modeRes)
cout << "\nThis image mode is not supported by the device, the default value (CV_CAP_OPENNI_SXGA_15HZ) will be used.\n" << endl;
} }
if (!modeRes)
cout << "\nThis image mode is not supported by the device, the default value (CV_CAP_OPENNI_SXGA_15HZ) will be used.\n" << endl;
// Print some avalible device settings. // Print some avalible device settings.
cout << "\nDepth generator output mode:" << endl << cout << "\nDepth generator output mode:" << endl <<
"FRAME_WIDTH " << capture.get( CV_CAP_PROP_FRAME_WIDTH ) << endl << "FRAME_WIDTH " << capture.get( CV_CAP_PROP_FRAME_WIDTH ) << endl <<
"FRAME_HEIGHT " << capture.get( CV_CAP_PROP_FRAME_HEIGHT ) << endl << "FRAME_HEIGHT " << capture.get( CV_CAP_PROP_FRAME_HEIGHT ) << endl <<
"FRAME_MAX_DEPTH " << capture.get( CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH ) << " mm" << endl << "FRAME_MAX_DEPTH " << capture.get( CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH ) << " mm" << endl <<
"FPS " << capture.get( CV_CAP_PROP_FPS ) << endl; "FPS " << capture.get( CV_CAP_PROP_FPS ) << endl <<
"REGISTRATION " << capture.get( CV_CAP_PROP_OPENNI_REGISTRATION ) << endl;
if( capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR_PRESENT ) ) if( capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR_PRESENT ) )
{ {
cout << cout <<
"\nImage generator output mode:" << endl << "\nImage generator output mode:" << endl <<
"FRAME_WIDTH " << capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR+CV_CAP_PROP_FRAME_WIDTH ) << endl << "FRAME_WIDTH " << capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR+CV_CAP_PROP_FRAME_WIDTH ) << endl <<
"FRAME_HEIGHT " << capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR+CV_CAP_PROP_FRAME_HEIGHT ) << endl << "FRAME_HEIGHT " << capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR+CV_CAP_PROP_FRAME_HEIGHT ) << endl <<
"FPS " << capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR+CV_CAP_PROP_FPS ) << endl; "FPS " << capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR+CV_CAP_PROP_FPS ) << endl;
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment