先展示maven依赖吧,就一个javacv
org.bytedeco
javacv-platform
1.5.1
pom
然后就是测试类
public static void testzc() throws FrameGrabber.Exception
{
String rtsp = “获取的对应rtsp流”;
FFmpegFrameGrabber grabber = FFmpegFrameGrabber.createDefault(rtsp);
grabber.setOption(“rtsp_transport”, “tcp”); // 使用tcp的方式,不然会丢包很严重
grabber.setImageWidth(960);
grabber.setImageHeight(540);
grabber.start();
CanvasFrame canvasFrame = new CanvasFrame(“正茂”);// 创建窗口
canvasFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 设置窗口关闭程序是否也跟随关闭
canvasFrame.setAlwaysOnTop(true);
OpenCVFrameConverter.ToMat converter = new OpenCVFrameConverter.ToMat();
int ex = 0;
while (true)
{