diff options
| author | Tim Redfern <tim@eclectronics.org> | 2014-02-19 13:03:32 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2014-02-19 13:03:32 +0000 |
| commit | d63937d54f41aa94236be6d7da3eede9b07196c7 (patch) | |
| tree | 5d0912ae9e74c30ddeae39c38754c87baf3a6688 /offsetProject/src | |
| parent | 4ee3054aa1af56d9fe00f70b62ab107f206e19b1 (diff) | |
preparing mip maps
Diffstat (limited to 'offsetProject/src')
| -rw-r--r-- | offsetProject/src/ofApp.cpp | 48 | ||||
| -rw-r--r-- | offsetProject/src/ofApp.h | 2 |
2 files changed, 26 insertions, 24 deletions
diff --git a/offsetProject/src/ofApp.cpp b/offsetProject/src/ofApp.cpp index 1c61832..3399aca 100644 --- a/offsetProject/src/ofApp.cpp +++ b/offsetProject/src/ofApp.cpp @@ -36,7 +36,6 @@ void ofApp::setup() { angle = 0; kinect.setCameraTiltAngle(angle); - //how to draw a pyramid mosaic //start with the largest size square //get the depth, if below a certain size, subdivide and repeat @@ -45,23 +44,29 @@ void ofApp::setup() { //1 - create a pyramid of mip maps of depth //2 - work upwards - int min_w=ceil(kinect.width/(MAX_TILE_SIZE*2))*2; - int min_h=ceil(kinect.height/(MAX_TILE_SIZE*2))*2; + //a find layout of largest tiles + //b extend captured frame to this ratio + //c mip map this down into prepared containers + + int tiles_w=ceil(kinect.width/(MAX_TILE_SIZE*2))*2; + int tiles_h=ceil(kinect.height/(MAX_TILE_SIZE*2))*2; + extend_w=(tiles_w)*MAX_TILE_SIZE; + extend_h=(tiles_h)*MAX_TILE_SIZE; //get number of levels int levels=0; - for (int i=MIN_TILE_SIZE;i>=MAX_TILE_SIZE;i*=2) { + for (int i=MIN_TILE_SIZE;i<=MAX_TILE_SIZE;i*=2) { levels++; - int w=ceil(kinect.width/(i*2))*2; - int h=ceil(kinect.height/(i*2))*2; - numTiles.push_back(make_pair(w,h)); - cerr<<"level "<<levels<<" mipmap: "<<w<<"x"<<h<<endl; } - numTiles.resiz - colourTiles.resize(levels); depthTiles.resize(levels); + + for (int i=MIN_TILE_SIZE,l=0;i<=MAX_TILE_SIZE;i*=2,l++) { + colourTiles[l].allocate(extend_w/i,extend_h/i); + depthTiles[l].allocate(extend_w/i,extend_h/i); + cerr<<"level "<<levels<<" mipmap: "<<colourTiles[l].getWidth()<<"x"<<colourTiles[l].getHeight()<<endl; + } } @@ -80,7 +85,8 @@ void ofApp::update() { depthImage.threshold(farThreshold); - depthImage.extend() + depthImage.extend(extend_w,extend_h); + colourImage.extend(extend_w,extend_h); // mark pixels and texture dirty depthImage.flagImageChanged(); @@ -89,18 +95,14 @@ void ofApp::update() { ofxCvColorImage *prevCol=&colourImage; ofxCvGrayscaleImage *prevDepth=&depthImage; - for (int i=MIN_TILE_SIZE,l=0;i>=MAX_TILE_SIZE;i*=2,l++){ - colourTiles[l].allocate(numTiles[l].first,numTiles[l].second); - colourTiles[l].scaleIntoMe(*prevCol); - depthTiles[l].allocate(numTiles[l].first,numTiles[l].second); - depthTiles[l].scaleIntoMe(*prevDepth); - //extend borders to a whole number of tiles of the next size - if (l<colourTiles.size()-1){ - colourTiles[l].extend(numTiles[l+1].first*2,numTiles[l+1].second*2); - depthTiles[l].extend(numTiles[l+1].first*2,numTiles[l+1].second*2); - } - prevCol=&colourTiles[l]; - prevDepth=&depthTiles[l]; + for (int i=0;i<colourTiles.size();i++){ + colourTiles[i].scaleIntoMe(*prevCol); + depthTiles[i].scaleIntoMe(*prevDepth); + prevCol=&colourTiles[i]; + prevDepth=&depthTiles[i]; + + colourTiles[i].flagImageChanged(); + depthTiles[i].flagImageChanged(); } } } diff --git a/offsetProject/src/ofApp.h b/offsetProject/src/ofApp.h index 57ee0d0..ce00cc8 100644 --- a/offsetProject/src/ofApp.h +++ b/offsetProject/src/ofApp.h @@ -47,5 +47,5 @@ public: int farThreshold; int angle; - + int extend_w,extend_h; }; |
