org.opencv.videoio.VideoCapture Java Examples

The following examples show how to use org.opencv.videoio.VideoCapture. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VideoFaceTests.java    From super-cloudops with Apache License 2.0 6 votes vote down vote up
/**
 * OpenCV-4.0.0 实时人脸识fF别
 * 
 * @return: void
 * @throws IOException
 * @date: 2019年5月7日12:16:55
 */
public static void videoFace() throws IOException {
	VideoCapture capture = new VideoCapture(0);
	Mat image = new Mat();
	int index = 0;
	if (capture.isOpened()) {
		while (true) {
			capture.read(image);
			HighGui.imshow("实时人脸识别", getFace(image));
			index = HighGui.waitKey(1);
			if (index == 27) {
				break;
			}
		}
	}
	return;
}
 
Example #2
Source File: FXController.java    From Face-Recognition with Apache License 2.0 5 votes vote down vote up
/**
 * Init the controller, at start time
 */
public void init()
{
	this.capture = new VideoCapture();
	this.faceCascade = new CascadeClassifier();
	this.absoluteFaceSize = 0;
	
	// disable 'new user' functionality
	this.newUserNameSubmit.setDisable(true);
	this.newUserName.setDisable(true);
	// Takes some time thus use only when training set
	// was updated 
	trainModel();
}
 
Example #3
Source File: CameraStream.java    From tutorials with MIT License 5 votes vote down vote up
public void start(Stage stage) throws Exception {
    OpenCV.loadShared();
    capture=  new VideoCapture(0); // The number is the ID of the camera
    ImageView imageView = new ImageView();
    HBox hbox = new HBox(imageView);
    Scene scene = new Scene(hbox);
    stage.setScene(scene);
    stage.show();
    new AnimationTimer(){
        @Override
        public void handle(long l) {
            imageView.setImage(getCapture());
        }
    }.start();
}
 
Example #4
Source File: FaceDetectionController.java    From ExoVisix with MIT License 4 votes vote down vote up
protected void init()
{
	this.capture = new VideoCapture();
	
	
	this.faceCascade = new CascadeClassifier();
	this.absoluteFaceSize = 0;
}
 
Example #5
Source File: Application.java    From opencv-object-detection with MIT License 4 votes vote down vote up
public static void main(String[] args)
{
    System.loadLibrary("opencv_java340");
    DeepNeuralNetworkProcessor processor = new DeepNeuralNetworkProcessor();
    List<DnnObject> detectObject = new ArrayList<>();
    VideoCapture capturre = new VideoCapture(0);
    while (true)
    {
       Mat frame = new Mat();
       capturre.read(frame);
       detectObject = processor.getObjectsInFrame(frame, false);
       for (DnnObject obj: detectObject)
       {
           Imgproc.rectangle(frame,obj.getLeftBottom(),obj.getRightTop(),new Scalar(255,0,0),1);
       }
       Imgcodecs.imwrite("DetectedObject.jpg",frame);
    }

}
 
Example #6
Source File: Webcam.java    From ResCan with GNU General Public License v2.0 4 votes vote down vote up
public static void main(final String args[]) {

		System.out.println("Hello, OpenCV");
		// Load the native library.
		System.loadLibrary("opencv_java411");

		listAllVoices();
		System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");
		VoiceManager voiceManager = VoiceManager.getInstance();
		voice = voiceManager.getVoice("kevin16");
		voice.allocate();

		camera = new VideoCapture(0);

		if (!camera.isOpened()) {
			System.out.println("Camera Error");
			}
		else {
			System.out.println("Camera OK?");
		}


		while (camera.isOpened()) {
			Mat frame = new Mat();



			// camera.grab();
			// System.out.println("Frame Grabbed");
			// camera.retrieve(frame);
			// System.out.println("Frame Decoded");

			camera.read(frame);
			Core.flip(frame, frame, -1);

			/*
			 * No difference camera.release();
			 */

			// System.out.println("Captured Frame Width " + frame.width());

			doMagic(frame);
			showResult(toBufferedImage(frame));

			/*
			 * try { Thread.sleep(10); } catch (InterruptedException e) { //
			 * TODO Auto-generated catch block e.printStackTrace(); }
			 */
		}
	}