Reputation: 89
I like so many others is trying to implement a barcode scanner for my Flex Mobile app using the zxing actionscript library. My issue is that I'm having a heck of a time just getting the camera to display properly on the actual device. Running the app on the desktop with a webcam shows the video feed just fine. Below is what i get on my Galaxy Nexus and similar on the Nexus 7.
I've been primarily working off of this example but have taken suggestions from other sites as well: http://www.remotesynthesis.com/post.cfm/adding-a-qr-code-reader-in-flex-on-android
Everything produces the same wacky feed to the Video Object. Anybody know what I could do to correct this?
Here's my code in its current form which is just trying to get a clear picture at this point (no barcode junk yet):
scanner2.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:bs="com.expologic.barcodescanner"
title="Scanner" creationComplete="init(event)">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.core.UIComponent;
import com.expologic.barcodescanner.BarcodeScanner;
private var bs:BarcodeScanner;
private function init(e:Event):void {
bs = new BarcodeScanner();
bs.horizontalCenter = 0;
bs.verticalCenter = 0;
bs.height = 480;
bs.width = 640;
addElement(bs);
//To add a target to the center of the screen
var uic:UIComponent = new UIComponent();
this.addElement(uic);
uic.width = uic.height = 275;
uic.graphics.lineStyle(3,0xFF0000);
uic.graphics.drawRect(0,0,275,275);
uic.horizontalCenter = uic.verticalCenter = 0;
}
]]>
</fx:Script>
</s:View>
BarcodeScanner.as
package com.expologic.barcodescanner
{
import flash.events.Event;
import flash.media.Camera;
import flash.media.Video;
import spark.core.SpriteVisualElement;
public class BarcodeScanner extends SpriteVisualElement
{
private var _video:Video;
public function BarcodeScanner()
{
this.height = 480;
this.width = 640;
addEventListener(Event.ADDED_TO_STAGE, _addToStage);
}
private function _addToStage(e:Event):void {
_setupCamera();
}
private function _setupCamera():void
{
if(!_video)
{
_video = new Video(640, 480);
addChild(_video);
}
if(Camera.isSupported)
{
var cam:Camera = Camera.getCamera();
cam.setQuality(0, 100);
cam.setMode(640, 480, 30, false);
_video.attachCamera(cam);
}
}
}
}
Upvotes: 1
Views: 2808
Reputation: 46
Try to set <renderMode>direct</renderMode>
in your app.xml, that solved the problem for me and I'm also using the Galaxy Nexus.
Regards
Joko
Upvotes: 3
Reputation: 3316
I am not understand the exact issue, but Try to add permissions listed in the below link:
zxing barcode scanner autofocus issue on reading second qr code
Upvotes: 1