找传奇、传世资源到传世资源站!

java开发ffmpeg的具体方法哦

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

package com.ls.utils;import lombok.extern.slf4j.Slf4j;import org.bytedeco.javacpp.opencv_core;import org.bytedeco.javacv.*;import org.opencv.core.*;import org.opencv.highgui.Highgui;import org.opencv.highgui.VideoCapture;import org.opencv.objdetect.CascadeClassifier;import javax.swing.*;@Slf4jpublic class CameraOut { static { System.loadLibrary(Core.NATIVE_LIBRARY_NAME); } private static int flag = 0; public static void run() { VideoCapture camera = new VideoCapture();//创建Opencv中的视频捕捉对象 camera.open(0);//open函数中的0代表当前计算机中索引为0的摄像头,如果你的计算机有多个摄像头,那么一次1,2,3…… if (!camera.isOpened()) {//isOpened函数用来判断摄像头调用是否成功 log.info("camera 调用失败"); } else { Mat frame = new Mat();//创建一个输出帧 while (flag == 0) { camera.read(frame);//read方法读取摄像头的当前帧 CascadeClassifier faceDetector = new CascadeClassifier("D:\\test\\java_project\\test03\\haarcascade_frontalface_alt.xml"); MatOfRect faceDetections = new MatOfRect(); faceDetector.detectMultiScale(frame, faceDetections); Rect[] rectArray = faceDetections.toArray(); if (rectArray.length > 0) { for (Rect rect : rectArray) { Rect rectCrop = new Rect(rect.x, rect.y, rect.width, rect.height); if (rect.width rect.height > rectCrop.height rectCrop.width) { rectCrop = new Rect(rect.x, rect.y, rect.width, rect.height); } log.info(String.format("检测到 %s 个人脸! ", rectArray.length)); Mat imageRoi = new Mat(frame, rectCrop); String name = System.currentTimeMillis() ".png"; Highgui.imwrite(name, imageRoi); Core.rectangle(frame, new Point(rect.x, rect.y), new Point(rect.x rect.width, rect.y rect.height), new Scalar(0, 0, 255), 2); } } try { Thread.sleep(1000);//线程暂停500ms } catch (InterruptedException e) { e.printStackTrace(); } } } camera.release(); }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复