我正在编写一个测试过程,它将作为原始处理器的副本
我的班级将视频文件作为输入,然后生成与帧相关的信息
Java2DFrameConverter bufferedImgConverter = new Java2DFrameConverter();
String filePath = "Palivala.mp4";
File tsFile = new File(filePath);
FFmpegFrameGrabber ffmpegFrameGrabber = new FFmpegFrameGrabber(tsFile);
OpenCVFrameConverter matConverter = new OpenCVFrameConverter.ToMat();
ffmpegFrameGrabber.start();
try {
while ((frame = ffmpegFrameGrabber.grabFrame(false, true, true, false)) != null) {
BufferedImage bufferedImage = bufferedImgConverter.convert(frame);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try {
ImageIO.write(bufferedImage, "jpeg", buffer);
} catch (IOException e) {
e.printStackTrace();
}
byte frameAsBytes[] = buffer.toByteArray();
start = System.currentTimeMillis();
BufferedImage bufferedImage2 = ImageIO.read(new ByteArrayInputStream(frameAsBytes));
Mat mat = matConverter.convertToMat(bufferedImgConverter.convert(bufferedImage)); //problem is here, I explained problem at the bottom
if (mat.empty())
continue;
if (prevMat != null) {
// here I am generating required data and sending to the method which I want to test
}
prevMat = mat.clone();
numProcessedFrames++;
}
} catch (org.bytedeco.javacv.FrameGrabber.Exception e) {
System.out.println("Exception while grabbing frames for segment " + e);
}
ffmpegFrameGrabber.stop();
如果我使用初始BufferedImage
对象(bufferedImage
),它按预期工作但当我使用转换后的BufferedImage
对象(bufferedImage2
)时,它无法按预期工作,即实际是我的process查找有关冻结帧的信息,如果视频被冻结了20秒
最终输出为20秒(如果我使用bufferedImage
个对象)
最终输出为14秒(如果我使用bufferedImage2
个对象)
我使用来自
的standard-deviation
对象生成mat
Mat mat = matConverter.convertToMat(bufferedImgConverter.convert(bufferedImage)); //it works fine
Mat mat = matConverter.convertToMat(bufferedImgConverter.convert(bufferedImage2)); its the problem
我使用standard-deviation
获取了冻结帧信息,standard-deviation-threshold
为90
standard-deviation
持续低于90
如果我使用bufferedImage
对象
standard-deviation
持续低于90
至6秒,然后持续1帧我获得standard-deviation
值为[118.0, 118.0, 119.0]
,然后下一帧再次低于{{1}如果我使用90
对象