void CVideoSourceKinect::initPlayer(std::string& strPathFileName_){ init(); _nMode = PLAYING_BACK; PRINTSTR("Initialize OpenNI Player..."); //inizialization Status nRetVal = openni::OpenNI::initialize(); printf("After initialization:\n%s\n", openni::OpenNI::getExtendedError()); nRetVal = _device.open(strPathFileName_.c_str()); CHECK_RC_(nRetVal, "Open oni file"); nRetVal = _depth.create(_device, openni::SENSOR_DEPTH); CHECK_RC_(nRetVal, "Initialize _cContext"); nRetVal = _color.create(_device, openni::SENSOR_COLOR); CHECK_RC_(nRetVal, "Initialize _cContext"); nRetVal = _depth.start(); CHECK_RC_(nRetVal, "Create depth video stream fail"); nRetVal = _color.start(); CHECK_RC_(nRetVal, "Create color video stream fail"); if (_depth.isValid() && _color.isValid()) { VideoMode depthVideoMode = _depth.getVideoMode(); VideoMode colorVideoMode = _color.getVideoMode(); int depthWidth = depthVideoMode.getResolutionX(); int depthHeight = depthVideoMode.getResolutionY(); int colorWidth = colorVideoMode.getResolutionX(); int colorHeight = colorVideoMode.getResolutionY(); if (depthWidth != colorWidth || depthHeight != colorHeight) { printf("Warning - expect color and depth to be in same resolution: D: %dx%d, C: %dx%d\n", depthWidth, depthHeight, colorWidth, colorHeight); //return ; } } _streams = new VideoStream*[2]; _streams[0] = &_depth; _streams[1] = &_color; // set as the highest resolution 0 for 480x640 //register the depth generator with the image generator if ( _nRawDataProcessingMethod == BIFILTER_IN_ORIGINAL || _nRawDataProcessingMethod == BIFILTER_IN_DISPARITY ){ nRetVal = _device.setImageRegistrationMode(IMAGE_REGISTRATION_DEPTH_TO_COLOR); //nRetVal = _depth.GetAlternativeViewPointCap().getGLModelViewMatrixPoint ( _color ); CHECK_RC_ ( nRetVal, "Getting and setting AlternativeViewPoint failed: " ); // Set Hole Filter _device.setDepthColorSyncEnabled(TRUE); }//if (_bUseNIRegistration) PRINTSTR(" Done."); return; }//initPlayer()
void DeviceController::printVideoMode(VideoMode mode) { PixelFormat pixelFormat = mode.getPixelFormat(); string pixelFormatName; switch (pixelFormat) { case PIXEL_FORMAT_DEPTH_1_MM: { pixelFormatName = "PIXEL_FORMAT_DEPTH_1_MM"; break; } case PIXEL_FORMAT_DEPTH_100_UM: { pixelFormatName = "PIXEL_FORMAT_DEPTH_100_UM"; break; } case PIXEL_FORMAT_SHIFT_9_2: { pixelFormatName = "PIXEL_FORMAT_SHIFT_9_2"; break; } case PIXEL_FORMAT_SHIFT_9_3: { pixelFormatName = "PIXEL_FORMAT_SHIFT_9_3"; break; } case PIXEL_FORMAT_RGB888: { pixelFormatName = "PIXEL_FORMAT_RGB888"; break; } case PIXEL_FORMAT_YUV422: { pixelFormatName = "PIXEL_FORMAT_YUV422"; break; } case PIXEL_FORMAT_GRAY8: { pixelFormatName = "PIXEL_FORMAT_GRAY8"; break; } case PIXEL_FORMAT_GRAY16: { pixelFormatName = "PIXEL_FORMAT_GRAY16"; break; } case PIXEL_FORMAT_JPEG: { pixelFormatName = "PIXEL_FORMAT_JPEG"; break; } } ofLogVerbose() << "PixelFormat: " << pixelFormatName; ofLogVerbose() << "ResolutionX: " << mode.getResolutionX(); ofLogVerbose() << "ResolutionY: " << mode.getResolutionY(); ofLogVerbose() << "FPS: " << mode.getFps(); }
DepthResolution XtionDepthDriverImpl::depthCameraResolution() const { const VideoMode mode = _stream.getVideoMode(); int res_x = mode.getResolutionX(); int res_y = mode.getResolutionY(); if((res_x == 320) && (res_y = 240)) { return DEPTH_RESOLUTION_320_240; } else if((res_x == 640) && (res_y = 480)) { return DEPTH_RESOLUTION_640_480; } return DEPTH_INVALID_RESOLUTION; }
void VideoSourceKinect::initKinect() { init(); cout<<("Initialize RGBD camera..."); //inizialization Status nRetVal = openni::OpenNI::initialize(); printf("After initialization:\n%s\n", openni::OpenNI::getExtendedError()); nRetVal = _device.open(openni::ANY_DEVICE); nRetVal = _depth.create(_device, openni::SENSOR_DEPTH); _depth.setMirroringEnabled(false); nRetVal = _color.create(_device, openni::SENSOR_COLOR); _color.setMirroringEnabled(false); _colorSensorInfo = _device.getSensorInfo(openni::SENSOR_COLOR); if( setVideoMode(_uResolution) == STATUS_OK ) { nRetVal = _depth.start(); nRetVal = _color.start(); } if (_depth.isValid() && _color.isValid()) { VideoMode depthVideoMode = _depth.getVideoMode(); VideoMode colorVideoMode = _color.getVideoMode(); int depthWidth = depthVideoMode.getResolutionX(); int depthHeight = depthVideoMode.getResolutionY(); int colorWidth = colorVideoMode.getResolutionX(); int colorHeight = colorVideoMode.getResolutionY(); if (depthWidth != colorWidth || depthHeight != colorHeight) { printf("Warning - expect color and depth to be in same resolution: D: %dx%d, C: %dx%d\n", depthWidth, depthHeight, colorWidth, colorHeight); //return ; } } _streams = new VideoStream*[2]; _streams[0] = &_depth; _streams[1] = &_color; // set as the highest resolution 0 for 480x640 char _serial[100]; int size = sizeof(_serial); _device.getProperty(openni::DEVICE_PROPERTY_SERIAL_NUMBER, &_serial, &size); _serial_number = string(_serial); cout << _serial_number << endl; boost::filesystem::path dir("..//" + _serial_number); if (boost::filesystem::create_directory(dir)) std::cout << "Success" << "\n"; else std::cout << "Fail" << "\n"; boost::filesystem::path dir_dep("..//" + _serial_number +"//depth//"); if (boost::filesystem::create_directory(dir_dep)) std::cout << "Success" << "\n"; else std::cout << "Fail" << "\n"; Mat cpuClibXYxZ0, cpuMask0; if (true){ _color.getCameraSettings()->setAutoExposureEnabled(false); _color.getCameraSettings()->setAutoWhiteBalanceEnabled(false); _color.getCameraSettings()->setExposure(_exposure); _color.getCameraSettings()->setGain(_gain); } cout<<(" Done."); return; }