Using zxing for Bar Codes. Not Found exception.


hello:

 

i'm trying scan upca, upce, or code128 barcodes on air mobile application.  have followed couple examples try on right path:

 

http://cookbooks.adobe.com/post_how_do_i_add_a_qr_code_reader_to_my_flex_mobile_ap-19074.h tml

http://forums.adobe.com/thread/890506

 

i'm using image size of 320 x 240.  set camera quality 100.  has gotten work correctly?

 

thank you,

  -eric bloms

 

 

import com.google.zxing.barcodeformat;                               import com.google.zxing.binarybitmap;                               import com.google.zxing.bufferedimageluminancesource;                               import com.google.zxing.decodehinttype;                               import com.google.zxing.result;                               import com.google.zxing.client.result.parsedresult;                               import com.google.zxing.client.result.resultparser;                               import com.google.zxing.common.globalhistogrambinarizer;                               import com.google.zxing.common.flexdatatypes.hashtable;                               import com.google.zxing.qrcode.qrcodereader;                               import mx.core.uicomponent;                               import spark.events.viewnavigatorevent;                                  private var camera:camera;                               private var cameravideo:movieclip;                               private var videodisplay:video=new video(320, 240);                               private var qrreader:qrcodereader;                               private var bmd:bitmapdata;                               private var camerastarted:boolean = false;                               private var detectchange:timer;                                  protected function view1_viewactivatehandler(event:viewnavigatorevent):void                               {                                         qrreader = new qrcodereader();                                         if(!camerastarted)                                         {                                                   if(camera.issupported)                                                   {                                                             camera = camera.getcamera();                                                             camera.setquality(0, 100);                                                             camera.setmode(320, 240, 8, false);                                                                videodisplay.attachcamera(camera);                                                             videodisplay.width = camera.width;                                                             videodisplay.height = camera.height;                                                             videodisplay.x = 0;                                                             videodisplay.y = 0;                                                             videodisplay.cacheasbitmap = true;                                                             //videodisplay.rotation=90;                                                             sv.addchild(videodisplay);                                                                var uic:uicomponent = new uicomponent();                                                             uic.graphics.linestyle(3,0xff0000);                                                             uic.graphics.drawrect(0,0,260,180);                                                             uic.horizontalcenter = uic.verticalcenter = 0;                                                             uic.width = videodisplay.width;                                                             uic.height = videodisplay.height;                                                             sv.addchild(uic);                                                                camerastarted = true;                                                             timerexample();                                                   }                                                   else                                                   {                                                             scanlabel.text = "error: no camera found.";                                                   }                                         }                               }                                  public function timerexample():void                               {                                         detectchange=new timer(1888);                                         detectchange.addeventlistener(timerevent.timer, decodesnapshot);                                         detectchange.start();                               }                                  private function focuscamera():void                               {                                         camera = camera.getcamera();                                         camera.setquality(0, 100);                                         camera.setmode(320, 240, 8, false);                                         camera.setloopback(false);                                         videodisplay.attachcamera(camera);                               }                                  protected function scanbutton_clickhandler(event:mouseevent):void                               {                                         decodesnapshot(null);                               }                                  private function decodesnapshot(event:timerevent):void                               {                                         scanlabel.text = "checking...";                                         bmd = new bitmapdata(320, 240);                                         bmd.draw(videodisplay, null, null, null, null, true);                                         videodisplay.cacheasbitmap = true;                                         videodisplay.cacheasbitmapmatrix = new matrix;                                         decodebitmapdata(bmd, 320, 240);                                         bmd.dispose();                                         bmd = null;                                         system.gc();                               }                                  public function decodebitmapdata(bmpd:bitmapdata, width:int, height:int):void                               {                                         var lsource:bufferedimageluminancesource=new bufferedimageluminancesource(bmpd);                                         var bitmap:binarybitmap=new binarybitmap(new globalhistogrambinarizer(lsource));                                            var ht:hashtable=null;                                         ht=this.getallhints();                                            var res:result=null;                                         try {                                                   res=qrreader.decode(bitmap, ht);                                         }                                         catch (event:error) {                                                   scanlabel.text = event.name + " - " +event.message + " - " + event.getstacktrace();                                                   trace(event.name + " - " +event.message + " - " + event.getstacktrace());                                         }                                            if (res == null) {                                                   videodisplay.clear();                                                   scanlabel.text="nothing decoded";                                         }                                         else {                                                   var parsedresult:parsedresult = resultparser.parseresult(res);                                                   scanlabel.text=parsedresult.getdisplayresult();                                                   sv.removechild(videodisplay);                                                   camerastarted = false;                                         }                               }                                  public function getallhints():hashtable                               {                                         var ht:hashtable = new hashtable();                                         //ht.add(decodehinttype.possible_formats, barcodeformat.qr_code);                                         ht.add(decodehinttype.possible_formats,barcodeformat.upc_e);                                         ht.add(decodehinttype.possible_formats,barcodeformat.upc_a);                                         ht.add(decodehinttype.possible_formats,barcodeformat.code_128);                                         ht.add(decodehinttype.try_harder, true);                                            return ht;                               }  

i have made changes display bitmap data on screen after capturing , there whitespace on bottom , right side of image.  i'm experimenting how can rid of white space now.



More discussions in AIR Development


adobe

Comments

Popular posts from this blog

Falang and too many redirects - Joomla! Forum - community, help and support

Infinite loop detected in JErrorInfinite loop detected in JError - Joomla! Forum - community, help and support

logged out from joomla! - Joomla! Forum - community, help and support