DOES A PICTURE REALLY SAY A THOUSAND WORDS?
I took a look at a picture, a picture of a young beautiful dark african lady on my laptop and decided, what if i see how the computer translates this simple picture into text. What would the computer say about this lady? I had to go about it.
I delved into the Java API and was told, just read the image binary file, buffer the input stream and then write it out in another buffered output stream. Pronto. I checked the java tutorials and was told the same story. Just do that and you'll be fine. So i tried it and am giving you the result.
If you love chinese games, you really might be interested in Mahjong. There is also one for PocketPCs.
package examples;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.*;
public class Google {
BufferedInputStream bin;
BufferedOutputStream bout;
public void doingThis() throws FileNotFoundException, IOException{
try{
//create the input stream
bin = new BufferedInputStream(new
FileInputStream("amelipassport.jpg"));
//create the output stream
bout = new BufferedOutputStream(new
FileOutputStream("pix2words.txt"));
//now there's this int type that i'll use to read the
//bytes coming from the buffered input stream
int c;
//we'll keep reading the stream and writing to output
//until we each end of file, eof
while((c = bin.read()) != -1){
bout.write(c);
}
}
finally{
//at the end of everything, close all streams
if (bin != null){ bin.close();}
if (bout != null) {bout.close();}
}
}
//now this is the class loader
public static void main(String[] args) throws FileNotFoundException, IOException{
Google blogger = new Google();
blogger.doingThis();
}
}
I had the honor of asking the unholy question: What would the computer say? Now these are a few lines of my result.
ÿØÿþ WANG2ÿà JFIF x x ÿÛ C
(1#%(:3=<9387@H\N@DWE78PmQW_bghg>Mqypdx\egcÿÛ C//cB8BccccccccccccccccccccccccccccccccccccccccccccccccccÿÀ :! ÿÄ ÿÄ µ } !1AQa"q2‘¡#B±ÁRÑð$3br‚
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡&circ
;‰Š’“”•–—˜™š¢£
¤¥¦§¨©ª²³´µ¶·¸
¹ºÂÃÄÅÆÇÈÉÊÒÓ
ÔÕÖרÙÚáâ&atild
I really don't know what the computer said. I can see WANG2 and then after...Gibber-gibber-gabber-dash? Or something like that?There must be a way to understand this gibber language. Yes, there is, i have to decode the gibberish stuff. Going back to ask the API.“Hey, API, you told me some half truth. Now, wise man, how do i translate this gibber?”
I've already written a solution. It's a breeze away.And for those who cannot do without being mobile, here's something you might like, Mundu for Mobiles.
No comments:
Post a Comment