I have using Texture array in augmented reality but run time show error "constructor are undefined".

edited December 2015 in Library Questions

I have using Texture array in augmented reality but run time show error "constructor are undefined"-in processing3...how to slove this error

Answers

  • Answer ✓

    Which constructor? What code is causing that error?

  • "tex[0] = new Texture(this);" show constructor "Texture( )" does not exits

  • Answer ✓

    where is the Texture class defined? is it in a library? is it your own code?

  • It is libraries class

  • Answer ✓

    Which libraries class?

    This is like pulling teeth.

  • edited December 2015
    import processing.video.*;
    
    Capture cam;
    Movie[] movie=new Movie[0];
    Texture[] tex=new Texture[0];
    
    PImage prevFrame;
    int index;
    
    void setup() {
        size(1280, 720);
    
        cam = new Capture(this, 1280/2, 720/2);
        cam.start();
    
        // Use texture tex as the destination for the camera pixels.
        tex[0] = new Texture(this);
    
        movie[0]=new Movie(this,"snake.mov");
    
        for (int i=0;i<movie.length;i++) {
          movie[i].setPixelDest(tex[i]);
        }
    
        prevFrame = createImage(1280/2, 720/2, RGB);
    }
    
    void captureEvent(Capture cam) {
        cam.read();
    }
    
    void movieEvent(Movie movie) {
        movie.read();
    }
    
    void draw() {
        println("frameRate: "+frameRate);
        // background(255);
        image(cam, 0, 0,1280,720);
    
        MovieonMovementDisplay();
    
        for (int i=0;i<tex.length;i++) {
            if (tex[i].putPixelsIntoTexture()) {
                image(tex[i], 0, 0);
            }
        }
    }
    
    void MovieonMovementDisplay() {
    
        if (cam.available()) {
            prevFrame.copy(cam, 0, 0, cam.width, cam.height, 0, 0, cam.width, cam.height);
            prevFrame.updatePixels();
            cam.read();
        }
    
        loadPixels();
        cam.loadPixels();
        prevFrame.loadPixels();
    
        float totalMotion=0;
    
        for (int i = 0; i < cam.pixels.length; i ++ ) {
            color current = cam.pixels[i];
            color previous= prevFrame.pixels[i];
    
            float r1 = red(current); 
            float g1 = green(current);
            float b1 = blue(current);
            float r2 = red(previous); 
            float g2 = green(previous);
            float b2 = blue(previous);
    
            // float diff = dist(r1, g1, b1, r2, g2, b2);
            //totalMotion += diff;
    
            float diff = dist(r1, g1, b1, r2, g2, b2);
            totalMotion =totalMotion+ diff;
      }
    
      float avgMotion = ((totalMotion) / (cam.pixels.length)); 
    
      println(avgMotion+"----AvgMotion");
      println("---------");
    
      for (int i=0;i<movie.length;i++) {
          // println(movie[i].time());
      }
    
      float time0=movie[0].time();
      println("time: "+time0);
      index=int(random(movie.length));
    
      if ((avgMotion>15) && (avgMotion<30)) {
          movie[0].play();
      }
      if(movie[0].isPlaying()){
          if(time0==30.875){
              movie[0].jump(0);
          }
      }
    }
    

    this is my code, during run time show error

  • edited December 2015

    that's better, thanks.

    the class is actually processing.opengl.Texture

    which is here:

    https://github.com/processing/processing/blob/81e86df8fd964aa95d506e30259a3d8fe459e79a/core/src/processing/opengl/Texture.java

    the constructors for which are:

    public Texture(PGraphicsOpenGL pg)
    public Texture(PGraphicsOpenGL pg, int width, int height)
    public Texture(PGraphicsOpenGL pg, int width, int height, Object params)
    

    but you're passing 'this' which is resolving to your sketch.

    i changed line 17 to

    tex[0] = new Texture((PGraphicsOpenGL)g);
    

    and that got further (line 22 is now giving an error). but i'm beginning to think that code isn't meant for processing3

    (i am using a slightly older version of processing3, mind, 3.0b7)

  • Answer ✓

    yeah, setPixelDest() isn't defined on that class.

    it IS defined on the old GSMovie class, which the new one is based on, but i can't see it in the new one.

    http://gsvideo.sourceforge.net/reference/codeanticode/gsvideo/GSMovie.html

  • so how to solve that GSMovie error in latest processing version

Sign In or Register to comment.