Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
88 lines (72 loc) · 2.83 KB

File metadata and controls

88 lines (72 loc) · 2.83 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package me;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
import org.opencv.videoio.VideoCapture;
import org.opencv.videoio.Videoio;
import origami.Origami;
import picocli.CommandLine;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.concurrent.Callable;
@CommandLine.Command(name = "fullscreenvideo", version="1.0.0", mixinStandardHelpOptions = true, description = "Play A video fullscreen")
public class FullscreenVideo extends JFrame implements Callable<Integer> {
private static final long serialVersionUID = -5957072069813017161L;
BufferedImage image;
@CommandLine.Option(names = {"-i", "--input"}, description = "Input Image", required = true, defaultValue="data/lexus.mpg")
File videoFile;
@CommandLine.Option(names = {"-f", "--fullscreen"}, description = "Fullscreen", required = false, defaultValue = "false")
Boolean fullscreen;
public static void main(String args[]) throws Exception {
Origami.init();
new CommandLine(new FullscreenVideo()).execute(args);
}
public Integer call() {
VideoCapture camera = new VideoCapture();
camera.open(videoFile.getAbsolutePath());
Mat frame = new Mat();
Dimension di = getDimensions(camera, this, fullscreen);
if (!camera.isOpened()) {
throw new RuntimeException("Cannot read file");
} else {
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// this.setExtendedState(JFrame.MAXIMIZED_BOTH);
// this.setUndecorated(true);
this.pack();
this.setVisible(true);
while (camera.grab()) {
camera.read(frame);
if(frame.empty()) {
break;
}
Mat dst = new Mat();
Imgproc.resize(frame, dst, new Size((int) di.getWidth(), 50 + (int) di.getHeight()));
this.image = Origami.matToBufferedImage(dst);
this.repaint();
}
}
camera.release();
return 0;
}
private Dimension getDimensions(VideoCapture camera, FullscreenVideo t, boolean fullscreen) {
if (fullscreen) {
java.awt.GraphicsDevice d = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice();
d.setFullScreenWindow(t);
Dimension di = d.getFullScreenWindow().getSize();
return di;
} else {
return new Dimension((int) camera.get(Videoio.CAP_PROP_FRAME_WIDTH),
(int) camera.get(Videoio.CAP_PROP_FRAME_HEIGHT));
}
}
@Override
public void paint(Graphics g) {
g.drawImage(image, 0, 0, this);
}
public FullscreenVideo() {
super();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.