void ofApp::setup() { ofSetFrameRate(8); ofSetVerticalSync(true); vector<ofVideoDevice> devices = vidGrabber.listDevices(); for(int i = 0; i < devices.size(); i++){ if(devices[i].bAvailable){ ofLogNotice() << devices[i].id << ": " << devices[i].deviceName; }else{ ofLogNotice() << devices[i].id << ": " << devices[i].deviceName << " - unavailable "; } } vidGrabber.setDeviceID(1); vidGrabber.setDesiredFrameRate(CAMFPS); vidGrabber.initGrabber(CAMX,CAMY); ofx::HTTP::SimpleIPVideoServerSettings settings; settings.setPort(9696); settings.ipVideoRouteSettings.setMaxClientConnections(100); //100 is clearly too high. but at what point have we crossed the threshold? would be wise to serve a static after a given number of connections. server.setup(settings); server.start(); #if !defined(TARGET_LINUX_ARM) // Launch a browser with the address of the server. ofLaunchBrowser(server.getURL()); #endif }
void ofApp::setup() { ofSetFrameRate(30); // Set up our video to broadcast. player.load("fingers.mp4"); player.play(); player.setLoopState(OF_LOOP_NORMAL); ofxHTTP::SimpleIPVideoServerSettings settings; // Many other settings are available. settings.setPort(7890); // The default maximum number of client connections is 5. settings.ipVideoRouteSettings.setMaxClientConnections(1); // Apply the settings. server.setup(settings); // Start the server. server.start(); #if !defined(TARGET_LINUX_ARM) // Launch a browser with the address of the server. ofLaunchBrowser(server.url()); #endif }
//-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ string url = "http"; if ( server.usingSSL() ){ url += "s"; } url += "://localhost:" + ofToString( server.getPort() ); ofLaunchBrowser(url); }
//-------------------------------------------------------------- void ofApp::keyPressed(int key){ if ( key == ' ' ){ string url = "http"; if ( server.usingSSL() ){ url += "s"; } url += "://localhost:" + ofToString( server.getPort() ); ofLaunchBrowser(url); } }
void ofxNCoreAudio::_mousePressed(ofMouseEventArgs &e) { if (showConfiguration) { controls->mousePressed(e.x, e.y, e.button); // guilistener if (e.x > 722 && e.y > 586){ofLaunchBrowser("http://nuicode.com/projects/cca-alpha");} } // printf("Mouse pressed at x=%d, y=%d\n", e.x, e.y); }
//-------------------------------------------------------------- void testApp::setup() { ofSetFrameRate(30); ofSetLogLevel(OF_LOG_VERBOSE); logo.loadImage("DocumentRoot/img/openFrameworks.png"); server = new ofxWebServerBasic(8080,"DocumentRoot"); server->start(); ofLaunchBrowser(server->getURL()); }
void ofxKCoreVision::_mousePressed(ofMouseEventArgs &e) { if (showConfiguration) { controls->mousePressed( e.x, e.y, e.button ); //guilistener if ( contourFinder.bTrackObjects ) { if ( e.x > 385 && e.x < 705 && e.y > 30 && e.y < 270 ) { isSelecting = true; rect.x = e.x; rect.y = e.y; rect.width = 0; rect.height = 0; } } //Launch the website in browser if ( e.x > 723 && e.y > 549 ) if ( e.x > 830 ) ofLaunchBrowser("http://www.patriciogonzalezvivo.com"); else ofLaunchBrowser("http://ccv.nuigroup.com/"); } }
void ofApp::setup() { ofSetFrameRate(30); bgColor = ofColor::white; HTTP::BasicWebSocketServerSettings settings; server = HTTP::BasicWebSocketServer::makeShared(settings); server->getWebSocketRoute()->registerWebSocketEvents(this); server->start(); // Launch a browser with the address of the server. ofLaunchBrowser(server->getURL()); }
void ofApp::setup() { ofSetFrameRate(30); //server BasicWebSocketServerSettings settings; server = BasicWebSocketServer::makeShared(settings); server->getWebSocketRoute()->registerWebSocketEvents(this); server->start(); // Launch a browser with the address of the server. ofLaunchBrowser(server->getURL()); //Drawing ofEnableAlphaBlending(); }
//-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ //launch urls if ( x >= 812 && x <= 995 && y >= 723 && y <= 733 ) ofLaunchBrowser(TSPS_HOME_PAGE); else if ( x >= 812 && x <= 995 && y >= 733 && y <= 743 ) ofLaunchBrowser("http://github.com/labatrockwell/openTSPS"); }
//-------------------------------------------------------------- bool API::getAuthToken( Permissions perms ){ // build call map<string,string> args; args["api_key"] = api_key; // get frob string result = makeAPICall( "flickr.auth.getFrob", args, FLICKR_XML, true ); ofxXmlSettings xml; xml.loadFromBuffer(result); xml.pushTag("rsp");{ frob = xml.getValue("frob", ""); }; xml.popTag(); // authenticate // %a = API key, %b = perms, %c = frob, %d = api_sig string authURL = auth; ofStringReplace(authURL, "%a", api_key); string perm = "write"; switch (perms) { case FLICKR_WRITE: perm = "write"; break; case FLICKR_READ: perm = "read"; break; case FLICKR_DELETE: perm = "delete"; break; } map<string,string> toEncode; toEncode["api_key"] = api_key; toEncode["perms"] = perm; toEncode["frob"] = frob; ofStringReplace(authURL, "%b", perm); ofStringReplace(authURL, "%c", frob); ofStringReplace(authURL, "%d", apiSig(toEncode)); // this part is weird! ofLaunchBrowser has a tiny bug #ifdef TARGET_OSX string commandStr = "open '"+authURL +"'"; system(commandStr.c_str()); #else cout << authURL; ofLaunchBrowser(authURL); #endif bool bValidToken = false; int numSeconds = 0; int secondsWait = 2; for( numSeconds; numSeconds<30; numSeconds+=secondsWait ){ map<string,string> auth_args; auth_args["api_key"] = api_key; auth_args["frob"] = frob; // get frob string auth_result = makeAPICall( "flickr.auth.getToken", auth_args, FLICKR_XML, true ); xml.loadFromBuffer(auth_result); xml.pushTag("rsp"); { xml.pushTag("auth"); { auth_token = xml.getValue("token", ""); } xml.popTag(); } xml.popTag(); bValidToken = !( auth_token == "" ); if ( bValidToken ) break; numSeconds += secondsWait; ofSleepMillis(1000); } //this is a workaround! bValidToken = true; if ( !bValidToken ){ ofLogError( "OAuth didn't succeed. Maybe you took too long?"); return false; } // save auth token to XML for safe keeping ofxXmlSettings toSave; toSave.addTag("settings"); toSave.pushTag("settings");{ toSave.addValue("token", auth_token); }; toSave.popTag(); toSave.saveFile("flickr.xml"); return true; }
//-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button) { if ( x > ofGetWidth()-300 && y > ofGetHeight()-30 ) ofLaunchBrowser("http://www.patriciogonzalezvivo.com"); }
void ofxTSPSGuiManager::update(ofEventArgs &e) { if(!enableGui){ //if the gui is not shown no need to propagate values return; } ofxTSPSSettings *p_Settings; p_Settings = ofxTSPSSettings::getInstance(); panel.update(); // camera //p_Settings->cameraIndex = panel.getValueF("CAMERA_INDEX"); p_Settings->bUseKinect = panel.getValueF("USE_KINECT"); // threshold p_Settings->threshold = panel.getValueF("THRESHOLD"); p_Settings->bSmooth = panel.getValueB("USE_SMOOTHING"); p_Settings->smooth = panel.getValueF("SMOOTH_AMOUNT"); panel.setGroupActive("differencing", "smoothing", p_Settings->bSmooth); p_Settings->bHighpass = panel.getValueI("USE_HIGHPASS"); p_Settings->highpassBlur = panel.getValueI("HIGHPASS_BLUR"); p_Settings->highpassNoise = panel.getValueI("HIGHPASS_NOISE"); panel.setGroupActive("differencing", "highpass", p_Settings->bHighpass); p_Settings->bAmplify = panel.getValueB("USE_AMPLIFICATION"); p_Settings->highpassAmp = panel.getValueI("AMPLIFICATION_AMOUNT"); panel.setGroupActive("video", "amplification", p_Settings->bAmplify); if(panel.getButtonPressed("open video settings") && p_Settings->getVideoGrabber() != NULL){ ofVideoGrabber * grab = dynamic_cast<ofVideoGrabber *>(p_Settings->getVideoGrabber()); grab->videoSettings(); } if (panel.getButtonPressed("open debug URL")){ ofLaunchBrowser( "http://localhost:"+panel.getValueS("WS_PORT")); } //p_Settings->bAdjustedViewInColor = panel.getValueB("ADJUSTED_VIEW_COLOR"); //panel.setGroupActive("video", "adjustedViewColor", p_Settings->bAdjustedViewInColor); p_Settings->bLearnBackground = panel.getValueB("LEARN_BACKGROUND"); if(p_Settings->bLearnBackground){ panel.setValueB("LEARN_BACKGROUND", false); } //panel.setValueB("LEARN_BACKGROUND", p_Settings->bLearnBackground); //JG 12/8/09 GUI-REDUX Removing this feature //gui.addToggle("smart learn background", &p_Settings->bSmartLearnBackground); p_Settings->minBlob = panel.getValueF("MIN_BLOB")/100.0f; //scale var to be right for tracker p_Settings->maxBlob = panel.getValueF("MAX_BLOB")/100.0f; //scale var to be right for tracker p_Settings->bLearnBackgroundProgressive = panel.getValueB("RELEARN"); p_Settings->fLearnRate = panel.getValueF("RELEARN_BACKGROUND"); panel.setGroupActive("background", "background relearn", p_Settings->bLearnBackgroundProgressive); p_Settings->bFindHoles = !(panel.getValueB("FIND_HOLES")); p_Settings->bTrackOpticalFlow = panel.getValueB("SENSE_OPTICAL_FLOW"); panel.setGroupActive("sensing", "optical flow", p_Settings->bTrackOpticalFlow); //JG 12/8/09 GUI-REDUX: p_Settings->minOpticalFlow = panel.getValueF("MIN_OPTICAL_FLOW"); p_Settings->maxOpticalFlow = panel.getValueF("MAX_OPTICAL_FLOW"); p_Settings->trackType = panel.getValueI("BLOB_TYPE"); p_Settings->bDetectHaar = panel.getValueB("SENSE_HAAR"); panel.setGroupActive("sensing", "haar tracking", p_Settings->bDetectHaar); if(haarFiles->getSelectedName() != ""){ p_Settings->haarFile = haarFiles->getSelectedName(); } p_Settings->haarAreaPadding = panel.getValueF("HAAR_PADDING"); //JG GUI-REDUX: removing this feature //gui.addToggle("send haar center as blob center", &p_Settings->bUseHaarAsCenter); //JG 1/21/10 disabled this feature to simplify the interface // p_Settings->minHaarArea = panel.getValueF("MIN_HAAR"); // p_Settings->maxHaarArea = panel.getValueF("MAX_HAAR"); //update osc stuff p_Settings->bSendOsc = panel.getValueB("SEND_OSC"); p_Settings->bSendTuio = panel.getValueB("SEND_TUIO"); p_Settings->bSendTcp = panel.getValueB("SEND_TCP"); p_Settings->bSendWebSockets = panel.getValueB("SEND_WS"); p_Settings->oscHost = panel.getValueS("OSC_HOST", 0, "localhost"); p_Settings->oscPort = (int) atoi(panel.getValueS("OSC_PORT", 0, "12000").c_str()); p_Settings->tuioHost = panel.getValueS("TUIO_HOST", 0, "localhost"); p_Settings->tuioPort = (int) atoi(panel.getValueS("TUIO_PORT", 0, "3333").c_str()); p_Settings->tcpPort = (int) atoi(panel.getValueS("TCP_PORT", 0, "8888").c_str()); p_Settings->webSocketPort = (int) atoi(panel.getValueS("WS_PORT", 0, "7681").c_str()); p_Settings->bSendOscContours = panel.getValueB("SEND_OSC_CONTOURS"); panel.setGroupActive("sensing", "options", p_Settings->bSendOscContours); panel.setGroupActive("communication", "OSC", p_Settings->bSendOsc); panel.setGroupActive("communication", "TUIO", p_Settings->bSendTuio); panel.setGroupActive("communication", "TCP", p_Settings->bSendTcp); // UPDATE GUI QUADS HERE // because this returns a pointer to the actual points that get updated, // you store it in an array so it doesn't get updated when it draws ofPoint * scaledPoints = quadGui.getScaledQuadPoints(cameraWidth,cameraHeight); for (int i=0; i<4; i++){ p_Settings->quadWarpScaled[i] = scaledPoints[i]; } //modify custom parameters vector<ofxTSPSGUICustomParam>::iterator it; for(it = params.begin(); it != params.end(); it++){ ofxTSPSGUICustomParam p = *it; switch (p.type) { case PARAM_INT: *p.i = panel.getValueI(p.key); break; case PARAM_FLOAT: *p.f = panel.getValueF(p.key); break; case PARAM_BOOL: *p.b = panel.getValueB(p.key); break; default: printf("ofxTSPSGUIManager: WARNING undefined parameter type encountered\n"); break; } } //get xml p_Settings->currentXmlFile = panel.getCurrentXMLFile(); //get current panel p_Settings->lastCurrentPanel = p_Settings->currentPanel; p_Settings->currentPanel = panel.getSelectedPanel(); }
void slitScanApp::testClickedBanner(int x, int y) { if(y > ofGetHeight() - bottomImage.getHeight()){ ofLaunchBrowser("http://www.jamesgeorge.org/"); } }
//-------------------------------------------------------------- void CloudsVHXAuth::threadedFunction() { completeArgs.success = false; completeArgs.result = ""; if (mode == REQUEST_TOKEN || mode == REFRESH_TOKEN) { _ssl.setup(); _ssl.setOpt(CURLOPT_CAINFO, ofToDataPath(GetCloudsDataPath(true) + "vhx/cacert.pem")); _ssl.setURL("https://api.vhx.tv/oauth/token"); if (mode == REQUEST_TOKEN) { _ssl.addFormField("client_id", _clientId); _ssl.addFormField("client_secret", _clientSecret); _ssl.addFormField("grant_type", "client_credentials"); } else { _ssl.addFormField("refresh_token", _refreshToken); _ssl.addFormField("grant_type", "refresh_token"); } _ssl.perform(); string response = _ssl.getResponseBody(); ofLogVerbose("CloudsVHXAuth::threadedFunction") << "Response:" << endl << response; completeArgs.success = false; ofxJSONElement json; if (json.parse(response)) { if (json.isMember("access_token")) { _accessToken = json["access_token"].asString(); _refreshToken = json["refresh_token"].asString(); _tokenExpiry = (ofGetSystemTime() / 1000.f) + json["expires_in"].asFloat(); // Save the tokens to disk. CloudsCryptoSaveTokens(_accessToken, _refreshToken, _tokenExpiry, _tokensPath); completeArgs.success = true; completeArgs.result = _accessToken; } else { ofLogError("CloudsVHXAuth::threadedFunction") << "Unexpected JSON format:" << endl << response; } } else { ofLogError("CloudsVHXAuth::threadedFunction") << "Unable to parse JSON:" << endl << response; } _ssl.clear(); bNotifyComplete = true; } else if (mode == REQUEST_CODE) { _ssl.setup(); _ssl.setOpt(CURLOPT_CAINFO, ofToDataPath(GetCloudsDataPath(true) + "vhx/cacert.pem")); _ssl.setURL("https://api.vhx.tv/oauth/codes"); _ssl.addFormField("client_id", _clientId); _ssl.addFormField("client_secret", _clientSecret); _ssl.perform(); string response = _ssl.getResponseBody(); ofLogVerbose("CloudsVHXAuth::threadedFunction") << "Response:" << endl << response; completeArgs.success = false; ofxJSONElement json; if (json.parse(response)) { if (json.isMember("code")) { _code = json["code"].asString(); _codeExpiry = (ofGetSystemTime() / 1000.f) + json["expires_in"].asFloat(); completeArgs.success = true; completeArgs.result = _code; } else { ofLogError("CloudsVHXAuth::threadedFunction") << "Unexpected JSON format:" << endl << response; } } else { ofLogError("CloudsVHXAuth::threadedFunction") << "Unable to parse JSON:" << endl << response; } _ssl.clear(); bNotifyComplete = true; } else if (mode == LINK_CODE) { stringstream ss; ss << "http://www.vhx.tv/activate/clouds"; ss << "?client_id=" << _clientId; ss << "&code=" << _code; ofLaunchBrowser(ss.str()); ss.str(""); ss << "https://api.vhx.tv/oauth/codes/" << _code; ss << "?client_id=" << _clientId; ss << "&client_secret=" << _clientSecret; completeArgs.success = false; bool bWaitForLink = true; while (bWaitForLink && isThreadRunning()) { _ssl.setup(); _ssl.setOpt(CURLOPT_CAINFO, ofToDataPath(GetCloudsDataPath(true) + "vhx/cacert.pem")); _ssl.setURL(ss.str()); _ssl.perform(); string response = _ssl.getResponseBody(); ofLogVerbose("CloudsVHXAuth::threadedFunction") << "Response:" << endl << response; ofxJSONElement json; if (json.parse(response)) { if (json.isMember("access_token")) { _accessToken = json["access_token"].asString(); _refreshToken = json["refresh_token"].asString(); _tokenExpiry = (ofGetSystemTime() / 1000.f) + json["expires_in"].asFloat(); // Save the tokens to disk. CloudsCryptoSaveTokens(_accessToken, _refreshToken, _tokenExpiry, _tokensPath); completeArgs.success = true; completeArgs.result = _accessToken; bWaitForLink = false; } else { ofLogVerbose("CloudsVHXAuth::threadedFunction") << "Unexpected JSON result:" << endl << response; } } else { ofLogError("CloudsVHXAuth::threadedFunction") << "Unable to parse JSON:" << endl << response; bWaitForLink = false; } _ssl.clear(); ofSleepMillis(500); } bNotifyComplete = true; } else if (mode == VERIFY_PACKAGE) { stringstream ss; ss << "Authorization: Bearer " << _accessToken; _ssl.setup(); _ssl.setOpt(CURLOPT_CAINFO, ofToDataPath(GetCloudsDataPath(true) + "vhx/cacert.pem")); _ssl.setURL("https://api.vhx.tv/me"); _ssl.addHeader(ss.str()); _ssl.perform(); string response = _ssl.getResponseBody(); ofLogVerbose("CloudsVHXAuth::threadedFunction") << "Response:" << endl << response; cout << "RESPONSE " << response << endl; completeArgs.success = false; ofxJSONElement json; if (json.parse(response)) { if (json.isMember("_embedded")) { const ofxJSONElement& embedded = json["_embedded"]; if (embedded.isMember("packages")) { const ofxJSONElement& packages = embedded["packages"]; if(packages.size() > 0){ for (int i = 0; i < packages.size(); ++i) { const ofxJSONElement& element = packages[i]; if (element.isMember("id")) { string packageId = element["id"].asString(); if (packageId == _packageId || packageId == "8102") { //hack for rental // Found matching package, check that purchase is valid. if (element.isMember("purchase_type")) { string purchaseType = element["purchase_type"].asString(); if (purchaseType == "purchase") { state = PURCHASE; completeArgs.success = true; completeArgs.result = "purchase"; break; } else if (purchaseType == "rental") { if (element.isMember("expires_at")) { if (element["expires_at"].isNull()) { // No expiry, assume we're good. state = RENTAL; completeArgs.success = true; completeArgs.result = "rental"; break; } else { // Parse the expiry date. Poco::DateTime dt; int tzd; if (Poco::DateTimeParser::tryParse(element["expires_at"].asString(), dt, tzd)) { Poco::LocalDateTime ldt(tzd, dt); Poco::Timestamp expiryTime = ldt.timestamp(); Poco::Timestamp nowTime; // Make sure the rental is valid. if (nowTime < expiryTime) { // Expires in the future, we're good. _packageExpiry = expiryTime.epochTime(); state = RENTAL; completeArgs.success = true; completeArgs.result = "rental"; break; } else { // Expired, no good. state = EXPIRED; completeArgs.success = true; completeArgs.result = "expired"; continue; //check other packages } } else { // Could not parse expiry, assume no good. state = EXPIRED; completeArgs.success = true; completeArgs.result = "expired"; continue; //check the other packages } } } else { // No expiry, assume we're good. state = RENTAL; completeArgs.success = true; completeArgs.result = "rental"; break; } } else { // Not a rental or purchase, assume no good. state = INACTIVE; completeArgs.success = true; completeArgs.result = "inactive"; continue; //check the other packages } } else { ofLogError("CloudsVHXAuth::threadedFunction") << "Unexpected JSON result, 'purchase_type' not found:" << endl << response; } } else { ofLogNotice("CloudsVHXAuth::threadedFunction") << "Skipping package " << packageId; } } else { ofLogError("CloudsVHXAuth::threadedFunction") << "Unexpected JSON result, 'id' not found:" << endl << response; } } } else { state = INACTIVE; completeArgs.success = true; completeArgs.result = "inactive"; } } else { ofLogError("CloudsVHXAuth::threadedFunction") << "Unexpected JSON result, 'packages' not found:" << endl << response; } } else { ofLogError("CloudsVHXAuth::threadedFunction") << "Unexpected JSON result, '_embedded' not found:" << endl << response; } } else { ofLogError("CloudsVHXAuth::threadedFunction") << "Unable to parse JSON:" << endl << response; } _ssl.clear(); bNotifyComplete = true; } else { ofLogError("CloudsVHXAuth::threadedFunction") << "Mode " << mode << " is unrecongized!"; } }