jueves, 30 de abril de 2020

librerías para Processing

C:\Program Files (x86)\processing-3.5.3\modes\java\libraries


import processing.video.*;

Capture cam;

void setup() {
  size(640, 480);

  String[] cameras = Capture.list();

  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]);
    }
 
    // The camera can be initialized directly using an
    // element from the array returned by list():
    cam = new Capture(this, cameras[0]);
    cam.start();   
  }   
}

void draw() {
  if (cam.available() == true) {
    cam.read();
  }
  image(cam, 0, 0);
  // The following does the same, and is faster when just drawing the image
  // without any additional resizing, transformations, or tint.
  //set(0, 0, cam);
}

del webinar ICAEN 30/04/2020


http://icaen.gencat.cat/.content/20_Energia/24_usos_energia/01_casa/contractacio-energia-electrica/calculadora/

el comptador digital també ens pot donar informació dels consums

la factura també


control de píxels en una imatge amb processing

Aquest post posa en pràctica els continguts del link de Daniel Shiffman

NOTES PREVIES

  1. convé que el programa es guardi. Quan fas SAVE ja crea una carpeta on posarà tots els programes que necessita
  2. per descarregar una llibreria convé fixar-se amb el Sketchbook. No canviar carpetes de lloc ni PATH perquè llavors no engengarà el programa
  3. tal com diu l'autor al link
  4. DescriptionThe image() function draws an image to the display window. Images must be in the sketch's "data" directory to load correctly. Select "Add file..." from the "Sketch" menu to add the image to the data directory, or just drag the image file onto the sketch window. Processing currently works with GIF, JPEG, and PNG images.

control de píxels en una imatge amb processing

a la ITC BT 39 es tracta les tanques electrificades. Un impuls molt i molt breu però d'alt voltatge transmet una energia a l'animal que s'acosta i toca la tanca.


per a calcular l'energia es pot seguir el formulari proposat del link.

la gràfica ens mostra dos impulsos.
https://agriculture.gouv.fr/sites/minagri/files/documents/pdf/Rapport_BCMA_AVK_FINAL.pdf

Reomplim amb PAINT i un color pur RGB


en aquesta segona gràfica veiem les escales de temps (abscises) i voltatge (ordenades).

PImage img;

void setup() {
  size(200, 200);
  img = loadImage("sunflower.jpg");
}

void draw() {
  loadPixels(); 
  // Since we are going to access the image's pixels too  
  img.loadPixels(); 
  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      int loc = x + y*width;
      
      // The functions red(), green(), and blue() pull out the 3 color components from a pixel.
      float r = red(img.pixels[loc]);
      float g = green(img.pixels[loc]);
      float b = blue(img.pixels[loc]);
      
      // Image Processing would go here
      // If we were to change the RGB values, we would do it here, 
      // before setting the pixel in the display window.
      
      // Set the display pixel to the image pixel
      pixels[loc] =  color(r,g,b);          
    }
  }
  updatePixels();
}

miércoles, 8 de abril de 2020