Created
September 9, 2017 02:57
-
-
Save micromeeeter/20a203269ff41b832e9823664d1c4547 to your computer and use it in GitHub Desktop.
transboundary :: webcam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofMain.h" | |
#include "ofApp.h" | |
//======================================================================== | |
int main( ){ | |
ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context | |
// this kicks off the running of my app | |
// can be OF_WINDOW or OF_FULLSCREEN | |
// pass in width and height too: | |
ofRunApp(new ofApp()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofApp.h" | |
//-------------------------------------------------------------- | |
void ofApp::setup(){ | |
// ofSetWindowPosition(2561, 0); //拡張ディスプレイ上でフルスクリーン | |
// ofSetFullscreen(true); | |
// ofHideCursor(); | |
//webcam | |
camWidth = ofGetWidth() / 2; | |
camHeight = ofGetWidth() / 16 * 9;; | |
vector<ofVideoDevice> devices = cam1.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 "; | |
} | |
} | |
ofEnableAlphaBlending(); | |
cam1.setVerbose(true); //画面左側 | |
cam1.listDevices(); | |
cam1.setDeviceID(1); | |
cam1.initGrabber(camWidth, camHeight); | |
cam2.setVerbose(true); //画面右側 | |
cam2.listDevices(); | |
cam2.setDeviceID(2); | |
cam2.initGrabber(camWidth, camHeight); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::update(){ | |
ofSetWindowTitle(ofToString(ofToString(ofGetFrameRate()))); //ウィンドウの上のバーにフレームレートを表示 | |
cam1.update(); | |
cam2.update(); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::draw(){ | |
ofBackground(0, 0, 0); | |
cam1.draw(0, ofGetHeight() / 2 - camHeight / 2, camWidth, camHeight); | |
cam2.draw(camWidth, ofGetHeight() / 2 - camHeight / 2, camWidth, camHeight); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "ofMain.h" | |
class ofApp : public ofBaseApp{ | |
public: | |
void setup(); | |
void update(); | |
void draw(); | |
ofVideoGrabber cam1, cam2; //webcamからの入力映像 | |
int camWidth, camHeight; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment