void ofApp::setup() { ofSetVerticalSync(true); int camWidth = 320; int camHeight = 240; int camFrameRate = 15; // We can get a list of devices. std::vector<ofVideoDevice> devices = ofxPS3EyeGrabber().listDevices(); // Now cycle through the devices and set up grabbers for each. for (std::size_t i = 0; i < devices.size(); ++i) { std::stringstream ss; ss << devices[i].id << ": " << devices[i].deviceName << " : " << devices[i].serialID; if (!devices[i].bAvailable) { ss << " - unavailable "; } else { std::shared_ptr<ofVideoGrabber> grabber = std::make_shared<ofVideoGrabber>(); grabber->setGrabber(std::make_shared<ofxPS3EyeGrabber>()); grabber->setDeviceID(i); grabber->setDesiredFrameRate(camFrameRate); // The native pixel format for the ofxPS3EyeGrabber is OF_PIXELS_YUY2 // (aka YUV422). When used this way, no additional pixel copies are made // or colorspace conversions are performed. // // The programmable renderer is able to directly render YUV422 pixels. // so be sure to that the OpenGL version is > 3.2, otherwise you'll // get a blank screen. grabber->setPixelFormat(OF_PIXELS_NATIVE); grabber->setup(camWidth, camHeight); // Make ofxPS3EyeGrabber-specific settings updates. grabber->getGrabber<ofxPS3EyeGrabber>()->setAutogain(true); grabber->getGrabber<ofxPS3EyeGrabber>()->setAutoWhiteBalance(true); grabbers.push_back(grabber); } ofLogNotice("ofApp::setup") << ss.str(); } }
//-------------------------------------------------------------- void ofApp::setup(){ minimised=false; ofSetVerticalSync(false); XML.loadFile("cameraSettings.xml"); camWidth = XML.getValue("CAMWIDTH", 640); camHeight = XML.getValue("CAMHEIGHT", 480); frameRate = XML.getValue("FRAMERATE", 60); recievePort = XML.getValue("RECIEVEPORT", 12334); sendPort =XML.getValue("SENDPORT", 12335); sendIp = XML.getValue("SENDIP", "127.0.0.1"); minimised = XML.getValue("MINIMISED", 0); receiver.setup(recievePort); sender.setup(sendIp, sendPort); bHide=false; drawColour.set(0, 0, 0); setIncomingPort=false; setOutGoingPort=false; // QVGA - 15, 30, 60, 75, 100, 125, 200 // VGA - 15, 30, 40, 50, 60, 75 vector<ofVideoDevice> deviceList = ofxPS3EyeGrabber().listDevices(); for (int i = 0; i < deviceList.size(); i++) { camParameterGroup params; params.setup(i); camParams.push_back(params); camParams[i].camExposure.addListener(this, &ofApp::onShutterChange); camParams[i].camGain.addListener(this, &ofApp::onGainChange); camParams[i].camSharpness.addListener(this, &ofApp::onSharpnessChanged); camParams[i].camBrightness.addListener(this, &ofApp::onBrightnessChange); camParams[i].camContrast.addListener(this, &ofApp::onContrastChange); camParams[i].camRedBalance.addListener(this, &ofApp::onRedBalanceChanged); camParams[i].camBlueBalance.addListener(this, &ofApp::onBlueBalanceChanged); camParams[i].camGreenBalance.addListener(this, &ofApp::onGreenBalanceChanged); camParams[i].camHue.addListener(this, &ofApp::onHueChange); camParams[i].drawcam.addListener(this, &ofApp::onCamDrawChanged); camParams[i].camAutoGain.addListener(this, &ofApp::onAutoGainAndShutterChange); camParams[i].camAutoBalance.addListener(this, &ofApp::onAutoBalanceChanged); camParams[i].camflipHoriz.addListener(this, &ofApp::onFlipHorizChanged); camParams[i].camflipVert.addListener(this, &ofApp::onFlipVertChanged); parameters.add(camParams[i].parameters); } parameters.setName("settings"); gui.setup(parameters); for (int i = 0; i < deviceList.size(); i++) { ofxSyphonServer * server = new ofxSyphonServer(); std::shared_ptr<ofxPS3EyeGrabber> camera = std::shared_ptr<ofxPS3EyeGrabber>(new ofxPS3EyeGrabber()); ofTexture * texture = new ofTexture(); camera->setDeviceID(i); camera->setDesiredFrameRate(frameRate); camera->setup(camWidth, camHeight); camera->setAutogain(true); camera->setAutoWhiteBalance(true); cameras.push_back(camera); server->setName("Camera " +ofToString(i+1)+" Output"); servers.push_back(server); texture->allocate(camWidth, camHeight, GL_RGBA); if (texture->isAllocated()) { textures.push_back(texture); } cameras[i]->setBrightness(uint8_t(camParams[i].camBrightness)); cameras[i]->setContrast(uint8_t(camParams[i].camContrast)); if (!camParams[i].camAutoGain) { cameras[i]->setGain(uint8_t(camParams[i].camGain)); cameras[i]->setSharpness(uint8_t(63-camParams[i].camSharpness)); cameras[i]->setExposure(uint8_t(camParams[i].camExposure)); } if (!camParams[i].camAutoBalance) { cameras[i]->setRedBalance(uint8_t(camParams[i].camRedBalance)); cameras[i]->setBlueBalance(uint8_t(camParams[i].camBlueBalance)); cameras[i]->setGreenBalance(uint8_t(camParams[i].camGreenBalance)); cameras[i]->setHue(uint8_t(camParams[i].camHue)); } cameras[i]->setAutogain(camParams[i].camAutoGain); cameras[i]->setAutoWhiteBalance(camParams[i].camAutoBalance); cameras[i]->setFlip(camParams[i].camflipHoriz, camParams[i].camflipVert); } camCounter=deviceList.size(); ofBackground(0, 0, 0); portInputOutgoing.setup(); portInputOutgoing.text = ofToString(sendPort); portInputOutgoing.bounds.x = 20; portInputOutgoing.bounds.y = 40 + gui.getHeight(); portInputOutgoing.bounds.height = 20; portInputOutgoing.bounds.width = 100; portInputOutgoing.drawCursor=true; portInputIncoming.setup(); portInputIncoming.text = ofToString(recievePort); portInputIncoming.bounds.x = 20; portInputIncoming.bounds.y = 40 + gui.getHeight()+25; portInputIncoming.bounds.height = 20; portInputIncoming.bounds.width = 100; portInputIncoming.drawCursor=true; if (!minimised) { if (cameras.size()*camHeight<gui.getShape().height+80) { ofSetWindowShape(gui.getWidth()+80+camWidth * cameras.size(), gui.getShape().height+80); } if (cameras.size()*camHeight>gui.getShape().height+80) { ofSetWindowShape(gui.getWidth()+80+camWidth * cameras.size(), cameras.size()*camHeight); } } if (minimised) { ofSetWindowShape(300, 30); } gui.loadFromFile("settings.xml"); }