-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcollectImg.java
42 lines (35 loc) · 1.27 KB
/
collectImg.java
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
package test2;
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.video.BackgroundSubtractor;
import org.opencv.video.Video;
public class collectImg {
public static void main(String[] args) throws AWTException, IOException, InterruptedException {
collect("C:\\Users\\86175\\Pictures\\aaaa","jpg");
}
//文件夹路径
public static void collect(String path,String format) throws InterruptedException, AWTException, IOException {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
int i=0;
while(true) {
i++;
Thread.sleep(3000);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
Robot robot = new Robot();
BufferedImage bufferedImage = robot.createScreenCapture(new Rectangle(d.width, d.height));
ImageIO.write(bufferedImage, "jpg", new File(path+"\\" +i+ "."+format));
System.out.println("ok");
}
}
}