summaryrefslogtreecommitdiff
path: root/offsetProject/src/ofApp.h
blob: 6188611fc589a51ac0da9a413cddc0fd9bfde3d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once

#include "ofMain.h"
#include "ofxOpenCv.h"
#include "ofxKinect.h"

#define MIN_TILE_SIZE 4 //has to be a divisor of 320 and 240 as the tiles are centred
#define MAX_TILE_SIZE 32 //has to be a power of 2 * MIN_TILE_SIZE

class offsetCvColorImage : public ofxCvColorImage {
	public:
		void extend( int w, int h ) {
			IplImage* temp = cvCreateImage( cvSize(w,h), IPL_DEPTH_8U, 3 );
			cvCopyMakeBorder(cvImage,temp, cvPoint(0,0),IPL_BORDER_REPLICATE );
		    allocate( w, h );
		    cvCopy( temp, cvImage );
		    cvReleaseImage( &temp );
		}
};

class offsetCvGrayscaleImage : public ofxCvGrayscaleImage {
	public:
		void extend( int w, int h ) {
			IplImage* temp = cvCreateImage( cvSize(w,h), IPL_DEPTH_8U, 1 );
			cvCopyMakeBorder(cvImage,temp, cvPoint(0,0),IPL_BORDER_REPLICATE );
		    allocate( w, h );
		    cvCopy( temp, cvImage );
		    cvReleaseImage( &temp );
		}
};

class ofApp : public ofBaseApp {
public:
	
	void setup();
	void update();
	void draw();
	void exit();
	
	void keyPressed(int key);
	void mouseDragged(int x, int y, int button);
	void mousePressed(int x, int y, int button);
	void mouseReleased(int x, int y, int button);
	void windowResized(int w, int h);

	void checktile(int level,int x,int y,int size);
	
	ofxKinect kinect;
	
	offsetCvColorImage colourImage;
	offsetCvGrayscaleImage depthImage,depthImage2;

	vector<offsetCvColorImage> colourTiles;	
	vector<offsetCvGrayscaleImage> depthTiles;
	vector<pair<int,int> > numTiles;

	int farThreshold;	
	int angle;
	int levels;
	int extend_w,extend_h;
};