简体   繁体   English

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

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

I like so many others is trying to implement a barcode scanner for my Flex Mobile app using the zxing actionscript library. 我喜欢这么多人试图使用zxing actionscript库为我的Flex Mobile应用程序实现条形码扫描程序。 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. 以下是我在Galaxy Nexus和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 我一直在主要处理这个例子,但也从其他网站那里得到了建议: http//www.remotesynthesis.com/post.cfm/adding-a-qr-code-reader-in-flex-on-安卓

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

        }
    }

Try to set <renderMode>direct</renderMode> in your app.xml, that solved the problem for me and I'm also using the Galaxy Nexus. 尝试在app.xml中设置<renderMode>direct</renderMode> ,这解决了我的问题,我也在使用Galaxy Nexus。 Regards Joko 关心乔科

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 zxing条码扫描器自动对焦读取第二个qr码的问题

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

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