Use Processing 2.1.1 with Asus Xtion Camera

Hi , how do I make this Processing code work with Asus Xtion Camera ? When I used this code , my webcam on my pc is being used instead. how do i modify it so that it uses the Asus Xtion Camera instead of my webcam?

import gab.opencv.*;
import processing.video.*;
import java.awt.*;

Capture video;
OpenCV opencv;

void setup() {
  size(640, 480);
  video = new Capture(this, 640/2, 480/2);
  opencv = new OpenCV(this, 640/2, 480/2);
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);  

  video.start();
}

void draw() {
  scale(2);
  opencv.loadImage(video);

  image(video, 0, 0 );

  noFill();
  stroke(0, 255, 0);
  strokeWeight(3);
  Rectangle[] faces = opencv.detect();
  println(faces.length);

  for (int i = 0; i < faces.length; i++) {
    println(faces[i].x + "," + faces[i].y);
    rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
  }
}

void captureEvent(Capture c) {
  c.read();
}

Thanks in advance.

Answers

  • Hello, manaXmizery!!! I hope, the discussion here can help you.

    Shotrly, you can print a list of cameras, which Processing detecs, like this:

    import processing.video.Capture;
    
    void setup() {
      String[] cameras = Capture.list();
      println("Available cameras:");
      for (int i = 0; i < cameras.length; i++) {
        println(cameras[i]);
      }
    }
    

    And then, use the one you need:

    cam1 = new Capture(this, cameras[0]);
    cam1.start();
    
Sign In or Register to comment.