-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSave_Image_01.pde
More file actions
90 lines (66 loc) · 2.35 KB
/
Copy pathSave_Image_01.pde
File metadata and controls
90 lines (66 loc) · 2.35 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
class SaveImg implements Runnable
{
//----GLOBAL VARIABLES----
String path; // this will hold the file path of the sketch
Capture cam; // this is to record from the camera
//int count = 0; // used for naming the movie files
int w ; // screen resolution
int h ;
//----GLOBAL VARIABLES----
//----CONSTRUCTOR----
SaveImg(PApplet app, int W, int H, String PATH) {
path = PATH;
w = W;
h = H;
CreateFolders(path + "Cam_Images");
String[] cameras = Capture.list(); // get camera list
if (cameras == null) { // if the camera is nothing
println("FAILED TO RETRIEVE LIST OF AVAILABLE CAMERAS");
cam = new Capture(app, w, h);
}
if (cameras.length == 0) { // if there are no cameras
println("THERE ARE NO CAMERAS AVAILABLE");
exit();
} else { // if there are cameras
println("AVAILABLE CAMERAS: ");
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
} //close for
cam = new Capture(app, w, h, 30);
cam.start();
}
}//----CLOSE CONSTRUCTOR----
//----SAVE IMAGES----
void SaveImages(int count) {
cam.read();
PImage img = cam;
try {
img.save("Cam_Images\\Img_" + count + ".jpg");
}
finally {
}
}
//----SAVE IMAGES----
//----RUN THREAD----
void run(int count) {
SaveImages(count);
}
//----RUN THREAD----
//----RUN THREAD----
void run() {
//SaveImages(count);
}
//----RUN THREAD----
//-------------------------------------------------------------------------------
// Create the appropiate file paths
private void CreateFolders(String FilePath) {
File folder = new File(FilePath);
if (!folder.exists()) { //check if file path exists
println("creating directory: " + FilePath);
folder.mkdir(); //make the file path
} else {
println("Path: '" + FilePath + "' already exists");
}
}
//-------------------------------------------------------------------------------
} //----CLOSE CLASS----