i have been problem with incopatible librery

import codeanticode.gsvideo.*; import processing.serial.*;

//objects PFont f; GSCapture cam; Serial myPort; PrintWriter output;

//colors color black=color(0); color white=color(255);

//variables int itr; //iteration float pixBright; float maxBright=0; int maxBrightPos=0; int prevMaxBrightPos; int cntr=1; int row; int col;

//scanner parameters float odl = 210; //distance between webcam and turning axle, [milimeter], not used yet float etap = 120; //number of phases profiling per revolution float katLaser = 25PI/180; //angle between laser and camera [radian] float katOperacji=2PI/etap; //angle between 2 profiles [radian]

//coordinates float x, y, z; //cartesian cords., [milimeter] float ro; //first of polar coordinate, [milimeter] float fi; //second of polar coordinate, [radian] float b; //distance between brightest pixel and middle of photo [pixel] float pxmmpoz = 5; //pixels per milimeter horizontally 1px=0.2mm float pxmmpion = 5; //pixels per milimeter vertically 1px=0.2mm

//================= CONFIG ===================

void setup() { size(800, 600); strokeWeight(1); smooth(); background(0);

//fonts f=createFont("Arial",16,true);

//camera conf. String[] avcams=GSCapture.list(); if (avcams.length==0){ println("There are no cameras available for capture."); textFont(f,12); fill(255,0,0); text("Camera not ready",680,32); } else{ println("Available cameras:"); for (int i = 0; i < avcams.length; i++) { println(avcams[i]); } textFont(f,12); fill(0,255,0); text("Camera ready",680,32); cam=new GSCapture(this, 640, 480,avcams[0]); cam.start(); }

//Serial (COM) conf. printArray(Serial.list()); myPort=new Serial(this, Serial.list()[0], 9600);

//output file output=createWriter("skan.asc"); //plik wynikowy *.asc

}

//============== MAIN PROGRAM =================

void draw() {

PImage zdjecie=createImage(cam.width,cam.height,RGB); cam.read(); delay(2000); for (itr=0;itr<etap;itr++) { cam.read(); zdjecie.loadPixels(); cam.loadPixels(); for (int n=0;n<zdjecie.width*zdjecie.height;n++){ zdjecie.pixels[n]=cam.pixels[n]; } zdjecie.updatePixels(); set(20,20,cam); String nazwaPliku="zdjecie-"+nf(itr+1, 3)+".png"; zdjecie.save(nazwaPliku); obroc(); delay(500); } obroc(); licz(); noLoop();

}

void licz(){ for (itr=0; itr<etap; itr++){

String nazwaPliku="zdjecie-"+nf(itr+1, 3)+".png";
PImage skan=loadImage(nazwaPliku);
String nazwaPliku2="odzw-"+nf(itr+1, 3)+".png";
PImage odwz=createImage(skan.width, skan.height, RGB);
skan.loadPixels();
odwz.loadPixels();
int currentPos;
fi=itr*katOperacji;
println(fi);

for(row=0; row<skan.height; row++){  //starting row analysis
maxBrightPos=0;
maxBright=0;
  for(col=0; col<skan.width; col++){
    currentPos = row * skan.width + col;
    pixBright=brightness(skan.pixels[currentPos]);
    if(pixBright>maxBright){
      maxBright=pixBright;
      maxBrightPos=currentPos;
    }
    odwz.pixels[currentPos]=black; //setting all pixels black
  }

  odwz.pixels[maxBrightPos]=white; //setting brightest pixel white

  b=((maxBrightPos+1-row*skan.width)-skan.width/2)/pxmmpoz;
  ro=b/sin(katLaser);
  //output.println(b + ", " + prevMaxBrightPos + ", " + maxBrightPos); //I used this for debugging

  x=ro * cos(fi);  //changing polar coords to kartesian
  y=ro * sin(fi);
  z=row/pxmmpion;

  if( (ro>=-30) && (ro<=60) ){ //printing coordinates
    output.println(x + "," + y + "," + z);
  }

}//end of row analysis

odwz.updatePixels();
odwz.save(nazwaPliku2);

} output.flush(); output.close(); }

void obroc() { //sending command to turn myPort.write('S'); delay(50); myPort.write('K'); }

this code i get on this page https://www.instructables.com/id/Lets-cook-3D-scanner-based-on-Arduino-and-Proces/ because i ve tryed to build a 3d scanner to calculate the volumen of some object

when i compile the code has a error on this line: cam=new GSCapture(this, 640, 480,avcams[0]);

on the serial monitor of prossesing this show me all the cameras but when the code arrive on this line the compilator show me this error on this line cam=new GSCapture(this, 640, 480,avcams[0]);

i dont know why

i have a prossesing version 3.3.6

Answers

  • Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leaves an empty line above and below your block of code

    You should consider checking the examples that come with the video library. In the Processing IDE, go to the menu File>>Examples and then go to libraries>>video>>capture and run any of the code there. You can see that instead of using GSCapture, you could use a Capture object. in any case, running the example would be the first step to check that your hardware is working properly in Processing.

    Kf

Sign In or Register to comment.