javacv
javacv copied to clipboard
grabber.grabImage() ist zu langsam, um mehrere Frames hintereinander zu erhalten
I want to get multiple frames in a row, but the grabber.grabImage() method is too slow, can it be optimized? Below is my code
`int flag = 1; List<Map<Integer, Frame>> lists = new ArrayList<>(); while (flag < 64) { Map<Integer,Frame> map = new HashMap<>(); Frame frame = grabber.grabImage(); map.put(flag,frame); lists.add(map); flag++; } log.info("lists");
for (Map<Integer, Frame> map : lists) {
map.forEach((k,v)->{
DecimalFormat decimalFormat = new DecimalFormat("00000");
String name = decimalFormat.format(k);
File imgUrl = new File("C:\\Users\\Administrator\\Desktop\\video\\" + name + ".jpg");
Java2DFrameConverter converter = new Java2DFrameConverter();
BufferedImage bufferedImage = converter.getBufferedImage(v);
try {
ImageIO.write(bufferedImage, "jpg", imgUrl);
} catch (IOException e) {
e.printStackTrace();
}
});
}`