Apr 29, 2011

Fantastic i divertit exemple en Processing



Segueix l'enllaç:

Geotagging photos




En geoetiquetar les fotografies, magatzamem en la informació EXIF de cada fotografia les coordenades geogràfiques del lloc on es va fer la foto (s'ha acabat allò de, on caram varem fer aquesta foto).

Des del 2009 jo geoetiqueto totes les meves fotografies.

Actualment uso el i-gotU GT-600 (Pàgina oficial de i-gotU) de 37 g de pès.


El podeu comprar, per exemple a PIXmania per uns 60€  (busqueu i-gotu).

Aquest aparell funciona enregistrant les coodenades GPS i l'hora cada 30s (aquest interval es configurable). L'unic que hem de fer per geoetiquetar les fotografies es executar el software del i-gotU que simplement enparella les fotografies amb les coodenades GPS donada la hora en que es va fer la fotografia.

Amb aquest GPS jo he magatzemat les dades de una setmana sense problemes (Aquest es l'avantatge de la desconnexió automàtica quan no et mous).


Finalment la parella ideal per organitzar les fotografies geoetiquetades (per mi) es el Google Picasa.








Apr 14, 2011

BarCode reading and writing with Processing



Mira aquest enllaç, però si el compiles tu, tindràs una verssió mes actualitzada.


// http://code.google.com/p/zxing/wiki/GettingStarted
// http://blog.makezine.com/archive/2011/03/codebox-use-qr-codes-in-processing.html
// http://code.google.com/p/zxing/wiki/DeveloperNotes
// http://zxing.org/w/docs/javadoc/index.html
// http://code.google.com/p/zxing/source/browse/trunk#trunk%2Fcore%2Fsrc
// http://zxing.org/w/docs/javadoc/com/google/zxing/client/j2se/package-frame.html
// http://code.google.com/p/zxing/source/browse/trunk#trunk%2Fjavase%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fclient%2Fj2se
// http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java




import com.google.zxing.*;
import java.awt.image.BufferedImage;


int SIZE = 400;


//com.google.zxing.Writer writer = new com.google.zxing.qrcode.QRCodeWriter(); 
//http://zxing.org/w/docs/javadoc/index.html
//com.google.zxing.Reader reader = new com.google.zxing.qrcode.QRCodeReader();
MultiFormatWriter writer = new MultiFormatWriter();
MultiFormatReader reader = new MultiFormatReader();
BitMatrix QRBitMatrix = new BitMatrix(SIZE, SIZE);
BarcodeFormat format = BarcodeFormat.QR_CODE;
// QR_CODE
// DATA_MATRIX
// UPC_E
// UPC_A
// EAN_8
// EAN_13
// CODE_128
// CODE_39       ATENCIÓ    Només Numèric
// ITF






void setup(){
size(SIZE, SIZE);


PImage img = new PImage(SIZE, SIZE);
String codi = "Hola";//println(codi.length());


img = codificaBarCcode(codi, format, SIZE, SIZE);


image(img, 0, 0);
img.save(savePath("data\\QR.jpg"));


println(decodificaBarCode(img));
}






PImage codificaBarCcode(String codi, BarcodeFormat format, int ample, int alt){
color negre = color(0), blanc = color(255);
PImage img = new PImage(ample, alt);
Hashtable hints = new Hashtable(1);
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");

try {
QRBitMatrix = writer.encode(codi, format, ample, alt, hints);
} catch (Exception e) {println(e.toString());}

int width = QRBitMatrix.getWidth();
int height = QRBitMatrix.getHeight();

for (int y = 0; y < height; y++) {
int offset = y * width;
for (int x = 0; x < width; x++) {
if(QRBitMatrix.get(x, y)) img.set(x, y, negre); else img.set(x, y, blanc);
}
}
return(img);
}




String decodificaBarCode(PImage img){
String retorn = "";
Result result = null;

try {
LuminanceSource source = new BufferedImageLuminanceSource((BufferedImage)img.getImage());
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
result = reader.decode(bitmap);
retorn = result.getText();
if (retorn != null) {
//println(result.getText());
ResultPoint[] points = result.getResultPoints();

for (int i = 0; i < points.length; i++) {
fill(#ff8c00);
ellipse(points[i].getX(), points[i].getY(), 20,20);
}
}
} catch (Exception e) {println(e.toString());}

return(retorn);
}