Package com.googlecode.javacv

Examples of com.googlecode.javacv.OpenCVFrameGrabber


//                }
            }
            try {
                videoToProject = new FFmpegFrameGrabber(virtualSettings.projectorVideoFile);
            } catch (Throwable t) {
                videoToProject = new OpenCVFrameGrabber(virtualSettings.projectorVideoFile);
            }
            if (videoToProject != null) {
                videoToProject.setColorMode(ColorMode.BGR);
                if (imageToProject != null) {
                    videoToProject.setImageWidth (imageToProject.width());
View Full Code Here


   * sends an email to the user with the video and the frame with a face in it
   *
   */

  public static void startSurveillance() {
    OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0); // 1 for next
                                // camera
    movieNum = 1;
    try {

      // start getting images from the webcam
      grabber.start();
      /*
       * this loop is so that the camera is given time to adjust to
       * lighting to get a good first frame for the motion detection.
       */
      warmup(grabber);
      IplImage firstFrame = grabber.grab();
      // send the first frame to the motionDetect Constructor
      MotionDetect detector = new MotionDetect(firstFrame);
      IplImage currFrame;

      while (true) {
        currFrame = grabber.grab();
        if (currFrame != null) {
          if (detector.Detect(currFrame)) {
            /*
             * hand over control of webcam to the record video
             * method to capture the frames for the 30 second movie
             */
            grabber.stop();
            recordVideo();
            // take control back of the webcam
            grabber.start();
            warmup(grabber);
            IplImage newbackground = grabber.grab();
            detector.setBackground(newbackground);
          }
        }
      }
    } catch (Exception e) {
View Full Code Here

      throws com.googlecode.javacv.FrameGrabber.Exception,
      com.googlecode.javacv.FrameRecorder.Exception {
    int frameRate = 10;

    // get the camera, 0 is default camera
    OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0);
    grabber.setFrameRate(frameRate);
    grabber.start();
    int numOfFrames = 0;
    int maxFramesIn10Seconds = 100;
    IplImage currFrame = grabber.grab();
    int height = currFrame.height();
    int width = currFrame.width();
    try {
      while (numOfFrames < maxFramesIn10Seconds) {
        if (currFrame != null) {
          String i = "" + numOfFrames;
          if (numOfFrames < 10) {
            i = "00" + numOfFrames;
          } else if (numOfFrames < 100) {
            i = "0" + numOfFrames;
          }
          String FileName = i + ".jpg";
          cvSaveImage(FileName, currFrame);
          numOfFrames++;

        }
        currFrame = grabber.grab();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    grabber.stop();
    /*
     * construct the MakeCheckSend object which is a facade for making the
     * video from the jpg images, checking for a frame with a face in it and
     * then, in a new thread, sending the video and the frame via email to
     * the user .
View Full Code Here

   * Just displays the camera view on the screen for 10 seconds so the user
   * can set up the camera position to capture the area they want
   */
  public static void show() {

    OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0); // 1 for next
    CanvasFrame canvas = new CanvasFrame("You have 10 seconds to position the camera then 10 seconds to leave the room");
    try {
      IplImage currFrame;
      grabber.start();
      long now = System.currentTimeMillis();
      // for 10 seconds
      while (System.currentTimeMillis() - now < 10000) {
        currFrame = grabber.grab();
        if (currFrame != null) {
          // 90_degrees_steps_anti_clockwise
          cvFlip(currFrame, currFrame, 1);// l-r =
          // show image on window
          canvas.showImage(currFrame);
        }
      }
      grabber.stop();
    } catch (Exception e) {
      e.printStackTrace();
    }
    canvas.dispose();

View Full Code Here

public class Track {

  public static void main(String[] args) throws Exception {
    CanvasFrame frame = new CanvasFrame("Track");
   
    OpenCVFrameGrabber grabber = OpenCVFrameGrabber.createDefault("../track/Balcony4_Vis.mpg");
    grabber.start();
    BackgroundSubtractorMOG backsub = new BackgroundSubtractorMOG();
    CvMemStorage storage = CvMemStorage.create();
   
    while(true) {
      IplImage img = grabber.grab();
      IplImage fgmask = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 1);
      backsub.apply(img, fgmask, 0.01);
     
      CvSeq contours = new CvSeq();
      cvFindContours(fgmask, storage, contours, Loader.sizeof(CvContour.class), CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
View Full Code Here

    protected String detectionXmlFile;
    protected CanvasFrame canvasFrame;

    public CameraDetection() {
        OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0);
        try {
            grabber.start();
            IplImage frame = grabber.grab();
            canvasFrame = new CanvasFrame("Camera Detecção");
            canvasFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            canvasFrame.setCanvasSize(frame.width(), frame.height());
           
            CvMemStorage storage = CvMemStorage.create();

            while(detectionXmlFile==null || detectionXmlFile.isEmpty()) {
                chooseXmlDetectionFile();
            }
           
            int detectionCount = 0;
           
            CvSeq faces = null;

            while (canvasFrame.isVisible() && (frame = grabber.grab()) != null) {
                cvSmooth(frame, frame, CV_GAUSSIAN, 9, 9, 2, 2);
               
                detectionCount++;
                if (detectionCount > 5) {
                    detectionCount=0;
View Full Code Here

TOP

Related Classes of com.googlecode.javacv.OpenCVFrameGrabber

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.