本文整理汇总了Java中org.opencv.videoio.VideoCapture.release方法的典型用法代码示例。如果您正苦于以下问题:Java VideoCapture.release方法的具体用法?Java VideoCapture.release怎么用?Java VideoCapture.release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opencv.videoio.VideoCapture
的用法示例。
在下文中一共展示了VideoCapture.release方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: patternCapture
import org.opencv.videoio.VideoCapture; //导入方法依赖的package包/类
public void patternCapture(VideoCapture capture, EyeDetection e, int length, String cmd){
//Scanner scanner = new Scanner(System.in);
List<EyeStatus> eyeStatusList = new ArrayList<>();
Calculation calculation = new Calculation(this);
Mat frame = new Mat();
List<Circle> circleList = new ArrayList<>();
//System.out.println("How big will your pattern be?");
//length = scanner.nextInt(); //excpetion
for(int i = 0; i < length; i++) {
//System.out.println("Do step " + (i + 1));
pressAnyKeyToContinue("Do step " + (i + 1));
if(capture.read(frame)) {
circleList = e.eyeDetect(frame);
e.filter(circleList);
//Calculate
eyeStatusList.add(calculation.calculate(frame, circleList));
}
}
for(EyeStatus eye : eyeStatusList) {
System.out.println(eye.getLeft() + " " + eye.getRight());
}
PatternDatabase.writeNewPattern(eyeStatusList, cmd);
capture.release();
}
示例2: CamFaceDetector
import org.opencv.videoio.VideoCapture; //导入方法依赖的package包/类
public static void CamFaceDetector() {
try {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
final CascadeClassifier objDetector = new CascadeClassifier(CameraFacialRecognition.class
.getResource("../../../../../opencv/sources/data/lbpcascades/lbpcascade_frontalface_improved.xml")
.getPath().substring(1));
final Mat capImg = new Mat();
final VideoCapture capture = new VideoCapture(0);
final int height = (int) capture.get(Videoio.CV_CAP_PROP_FRAME_HEIGHT);
final int width = (int) capture.get(Videoio.CV_CAP_PROP_FRAME_WIDTH);
if (height == 0 || width == 0) {
throw new Exception("camera not found");
}
final JFrame frame = new JFrame("camera");
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
final CameraFacialRecognition panel = new CameraFacialRecognition();
frame.setContentPane(panel);
frame.setVisible(true);
frame.setSize(width + frame.getInsets().left + frame.getInsets().right,
height + frame.getInsets().top + frame.getInsets().bottom);
Mat dst = new Mat();
while (frame.isShowing()) {
capture.read(capImg);
dst = dobj(objDetector, capImg);
panel.mImg = Mat2BufferedImage.mat2BI(dst);
panel.repaint();
}
capture.release();
} catch (final Exception e) {
System.out.println("Exception" + e);
} finally {
System.out.println("--done--");
}
}
示例3: grabImage
import org.opencv.videoio.VideoCapture; //导入方法依赖的package包/类
public void grabImage(){
Mat frame = new Mat();
//connect
videoCapture = new VideoCapture(0);
isOpened = videoCapture.isOpened();
System.out.println("connected: " + isOpened);
//setSetting
videoCapture.set(Videoio.CV_CAP_PROP_FRAME_WIDTH, 1280);
videoCapture.set(Videoio.CV_CAP_PROP_FRAME_HEIGHT, 720);
//startGrab
isSucceed = videoCapture.grab();
System.out.println("started: " + String.valueOf(isSucceed));
if ((!isOpened) || (!isSucceed))
return;
System.out.println("------- START GRAB -------");
//Wait for camera starting
while (true){
videoCapture.read(frame);
if (!frame.empty())
break;
}
int frameNo = 0;
long startSysMillis = System.currentTimeMillis();
while (frameNo < 1000){
videoCapture.read(frame);
frameNo++;
}
System.out.println(frameNo + " frames in " + (System.currentTimeMillis() - startSysMillis) + " millis");
videoCapture.release(); // release device
System.out.println('\n' + "Done");
}
示例4: checkCameras
import org.opencv.videoio.VideoCapture; //导入方法依赖的package包/类
private static int[] checkCameras(VideoCapture cap, int max){
int[] cams = new int[max];
boolean end = false;
for (int i = 0; i < max; i++) {
if(!end){
if(!cap.open(i)){
cams[i] = -1;
end = true;
}else cams[i] = i;
cap.release();
}else cams[i] = -1;
}
return cams;
}
示例5: processLiveImageFromWebcam
import org.opencv.videoio.VideoCapture; //导入方法依赖的package包/类
private void processLiveImageFromWebcam() {
VideoCapture videoCapture = new VideoCapture();
System.out.println("Capture device open: " + videoCapture.open(0));
Mat frame = new Mat();
ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
if (videoCapture.isOpened()) {
System.out.println("Camera is on");
service.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
videoCapture.read(frame);
String suffix = LocalTime.now().toString();
Imgcodecs.imwrite("frame" + suffix + ".png", frame);
}
}, 0, 33, TimeUnit.MILLISECONDS);
try {
service.awaitTermination(10, TimeUnit.SECONDS);
} catch (InterruptedException ex) {
Logger.getLogger(OpenCVTest.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
System.err.println("Camera is off");
}
service.shutdown();
videoCapture.release();
}
示例6: calibration
import org.opencv.videoio.VideoCapture; //导入方法依赖的package包/类
public void calibration(VideoCapture capture, EyeDetection e) {
initializeEvetything();
/*
System.out.println("Calibration time!");
System.out.println("Open both your eyes for 2 seconds");
*/
pressAnyKeyToContinue("Calibration time!\nOpen both your eyes for 2 seconds");
boolean first_capture;
first_capture = true;
//capture.open(0); not sure may need
/*
if(capture.isOpened()) {
capture.set(io.CV_CAP_PROP_FRAME_WIDTH, width);
capture.set(io.CV_CAP_PROP_FRAME_HEIGHT, height);
}
*/
while(openEyesList.size() < 2) {
if(!first_capture) {
//System.out.println("Can you please repeat?");
pressAnyKeyToContinue("Can you please repeat?");
} else {
first_capture = false;
}
if(capture.read(openEyesMat)) {
openEyesList = e.eyeDetect(openEyesMat);
}
}
e.filter(openEyesList);
//System.out.println();
pressAnyKeyToContinue("Nice, Now close your eyes for 2 seconds");
capture.release();
capture.open(0);
first_capture = true;
while(closedEyesList.size() < 2) {
if(!capture.isOpened())
capture.open(0);
if(first_capture) {
first_capture = false;
} else {
//System.out.println("Can you please repeat?");
pressAnyKeyToContinue("Can you please repeat?");
}
if(capture.read(closedEyesMat)) {
closedEyesList = e.eyeDetect(closedEyesMat);
}
}
e.filter(closedEyesList);
System.out.println();
capture.release();
}