/
testApp.cpp
63 lines (54 loc) · 1.33 KB
/
testApp.cpp
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
62
63
#include "testApp.h"
void testApp::setup() {
ofSetFrameRate(60);
ofSetVerticalSync(true);
bIsRecordingMovie = false;
camera.setup();
}
void testApp::exit() {
camera.close();
}
void testApp::update() {
camera.update();
if(camera.isFrameNew()) {
// process the live view with camera.getLivePixels()
}
if(camera.isPhotoNew()) {
// process the photo with camera.getPhotoPixels()
// or just save the photo to disk (jpg only):
camera.savePhoto(ofToString(ofGetFrameNum()) + ".jpg");
}
if(camera.isMovieNew()) {
camera.savePhoto(ofToString(ofGetFrameNum()) + ".mov");
}
}
void testApp::draw() {
camera.draw(0, 0);
// camera.drawPhoto(0, 0, 432, 288);
if(camera.isLiveDataReady()) {
stringstream status;
status << camera.getWidth() << "x" << camera.getHeight() << " @ " <<
(int) ofGetFrameRate() << " app-fps " << " / " <<
(int) camera.getFrameRate() << " cam-fps";
ofDrawBitmapString(status.str(), 10, 20);
}
}
void testApp::keyPressed(int key) {
if(key == ' ') {
camera.takePhoto();
}
if(key == 's') {
camera.setup();
}
if(key == 'c') {
camera.close();
}
else if(key == 'v') {
bIsRecordingMovie ^= true;
if (bIsRecordingMovie) {
camera.beginMovieRecording();
} else {
camera.endMovieRecording();
}
}
}