处理2.03中的GSvideo错误

时间:2015-03-31 15:27:37

标签: opencv processing video-recording

我正在处理一个Processing项目,但当我尝试使用GSvideo库记录草图时,我收到此错误:

  

此草图使用的库未正确安装。

     
    

GSVideo版本:1.0.0     库依赖于不可用的本机代码。     或者仅在草图作为64位应用程序运行时才能正常工作。

  

在我的项目中,我使用HSV空间颜色和OpenCV for Processing库跟踪对象,我想记录草图,以便稍后我可以显示我的工作。这是我的代码:

 /**
 * HSVColorTracking
 * Greg Borenstein
 * https://github.com/atduskgreg/opencv-processing-book/blob/master/code/hsv_color_tracking/HSVColorTracking/HSVColorTracking.pde
 *
 * Modified by Jordi Tost @jorditost (color selection)
 * University of Applied Sciences Potsdam, 2014
 * 
 * Modified by Luz Alejandra Magre
 * Universidad Tecnológica de Bolívar, 2015
 */

import gab.opencv.*;
import processing.video.*;
import codeanticode.gsvideo.*;
import java.awt.Rectangle;

GSCapture video;
OpenCV opencv;
GSMovieMaker mm;

int fps = 30;
PImage src, colorFilteredImage;
ArrayList<Contour> contours;

// <1> Set the range of Hue values for our filter
int rangeLow = 20;
int rangeHigh = 35;

void setup() {

  frameRate(fps);

  String[] cameras = GSCapture.list();
size(2*opencv.width, opencv.height, P2D);
  if (cameras.length == 0)
  {
    println("There are no cameras available for capture.");
    exit();
  } 
  else {
    println("Available cameras:");
    for (int i = 0; i < cameras.length; i++) {
      println(cameras[i]);
    }

    video = new GSCapture(this, 640, 480, cameras[0]);
    video.start();
    opencv = new OpenCV(this, video.width, video.height);

    contours = new ArrayList<Contour>();
    mm = new GSMovieMaker(this, width, height, "Test.ogg", GSMovieMaker.THEORA, GSMovieMaker.BEST, fps);
    mm.setQueueSize(50, 10);

    mm.start();
  }
}

void draw() {



  // Read last captured frame
  if (video.available()) {
    video.read();
  }

  // <2> Load the new frame of our movie in to OpenCV
  opencv.loadImage(video);

  // Tell OpenCV to use color information
  opencv.useColor();
  src = opencv.getSnapshot();

  // <3> Tell OpenCV to work in HSV color space.
  opencv.useColor(HSB);

  // <4> Copy the Hue channel of our image into 
  //     the gray channel, which we process.
  opencv.setGray(opencv.getH().clone());

  // <5> Filter the image based on the range of 
  //     hue values that match the object we want to track.
  opencv.inRange(rangeLow, rangeHigh);

  // <6> Get the processed image for reference.
  colorFilteredImage = opencv.getSnapshot();

  ///////////////////////////////////////////
  // We could process our image here!
  // See ImageFiltering.pde
  ///////////////////////////////////////////

  // <7> Find contours in our range image.
  //     Passing 'true' sorts them by descending area.
  contours = opencv.findContours(true, true);

  // <8> Display background images
  image(src, 0, 0);
  image(colorFilteredImage, src.width, 0);

  // <9> Check to make sure we've found any contours
  if (contours.size() > 0) {
    // <9> Get the first contour, which will be the largest one
    Contour biggestContour = contours.get(0);

    // <10> Find the bounding box of the largest contour,
    //      and hence our object.
    Rectangle r = biggestContour.getBoundingBox();

    // <11> Draw the bounding box of our object
    noFill(); 
    strokeWeight(2); 
    stroke(255, 0, 0);
    rect(r.x, r.y, r.width, r.height);

    // <12> Draw a dot in the middle of the bounding box, on the object.
    noStroke(); 
    fill(255, 0, 0);
    ellipse(r.x + r.width/2, r.y + r.height/2, 30, 30);
    text(r.x + r.width/2, 50, 50);
    text(r.y + r.height/2, 50, 80);
  }
  loadPixels();
  mm.addFrame(pixels);
  saveFrame("frame-######.png");
}

void mousePressed() {

  color c = get(mouseX, mouseY);
  println("r: " + red(c) + " g: " + green(c) + " b: " + blue(c));

  int hue = int(map(hue(c), 0, 255, 0, 180));
  println("hue to detect: " + hue);

  rangeLow = hue - 5;
  rangeHigh = hue + 5;
}

void keyPressed() {
  if (key == ' ') {
    // Finish the movie if space bar is pressed
    mm.finish();

    // Quit running the sketch once the file is written
    exit();
  }
}

我真的很感激这方面的帮助。

0 个答案:

没有答案