domingo, 3 de agosto de 2014

First Project with OpenCV: single code for web-cam capture.

Well, today I want to share you a simple code that let us to show a single frame from web-cam. The simple code uses OpenCV, and Java code... I have configured NetBeans for uses the OpenCV library.

 import org.opencv.core.Core;  
 import org.opencv.core.Mat;  
 import org.opencv.highgui.Highgui;  
 import org.opencv.highgui.VideoCapture;  
  * @author aldajo  
 public class SingleCameraCapture {  
   public static void main(String[] args) {  
     VideoCapture camera = new VideoCapture(1);  
     Mat framevideo = new Mat();;;  
     Highgui.imwrite("image.png", framevideo);  

The value in VideoCapture construct and method correspond to the number of the camera device in your computer. If you have only a web-cam, the value is 0.

I used the above code , and I have the following capture (my camera is a logitech c920):

No hay comentarios:

Publicar un comentario