繁体   English   中英

将Camera类与Flex Mobile Framework和Android一起使用

[英]Using the Camera class with Flex Mobile Framework and Android

我喜欢这么多人试图使用zxing actionscript库为我的Flex Mobile应用程序实现条形码扫描程序。 我的问题是,我只是想让相机在实际设备上正确显示。 使用网络摄像头在桌面上运行应用程序可以很好地显示视频供稿。 以下是我在Galaxy Nexus和Nexus 7上的相似之处。

在银河系中

我一直在主要处理这个例子,但也从其他网站那里得到了建议: http//www.remotesynthesis.com/post.cfm/adding-a-qr-code-reader-in-flex-on-安卓

一切都为视频对象产生相同的古怪饲料。 有谁知道我能做些什么来纠正这个?

这是我当前形式的代码,只是试图在这一点上得到一个清晰的图片(还没有条形码垃圾):

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);
                }
            }

        }
    }

尝试在app.xml中设置<renderMode>direct</renderMode> ,这解决了我的问题,我也在使用Galaxy Nexus。 关心乔科

我不明白确切的问题,但尝试添加以下链接中列出的权限:

zxing条码扫描器自动对焦读取第二个qr码的问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM