简体   繁体   English

Adobe AIR相机速度慢

[英]Adobe AIR camera slow

I am having issues with using the camera on Adobe AIR mobile devices . 我在Adobe AIR移动设备上使用相机时遇到问题。

The performance of the camera is ok on newer phones, but on galaxy s2 for example it is impossible to use. 在较新的手机上,相机的性能还可以,但是例如在galaxy s2上是无法使用的。 I am using the camera like this: 我正在使用像这样的相机

 _camera = Camera.getCamera("0");
    if (_camera != null)
    {

//      _video = new Video();
        _video = new Video(_camera.width, _camera.height);
//      _video.width = _cameraHeight;
        _video.width = _cameraHeight;
        _video.height = Starling.current.nativeStage.fullScreenWidth;
        _camera.addEventListener(ActivityEvent.ACTIVITY, onCameraActivity);
        _camera.setMode( _video.width,_video.height, 30 );
        _video.attachCamera(_camera);
        _videoContainer.addChild(_video);
    }

Does anyone have any recommendations? 有人有什么建议吗?

EDIT: The problem is that the framerate drops to around 1 on Galaxy S2 and the app crashes. 编辑:问题是Galaxy S2上的帧率下降到1左右,并且应用程序崩溃了。 On my galaxy S3 it works around 30fps. 在我的银河S3上,它的速度约为30fps。 I also tried uploading the video to the GPU on every frame using 我还尝试使用以下方法在每一帧上将视频上传到GPU

flash.display3D.textures.Texture(image.texture.base).uploadFromBitmapData(bmd);

it gets better on my galaxy s3 then, fps is around 50-60, but on galaxy s2 still terrible and unusable(around 1 fps) 那么在我的星系s3上它会变得更好,fps约为50-60,但在galaxy s2上仍然很糟糕且无法使用(约1 fps)

If you are actually using Starling, this is what I've used before (project about half an year old, don't know if things changed that much): 如果您实际上使用的是Starling,这是我以前使用过的(项目已有大约半年的时间,不知道事情是否发生了太大变化):

camera = Camera.getCamera();
camera.setLoopback(false);
camera.setMode(640, 640, 15);
var cropping:Rectangle = new Rectangle(0, 0, getLowerPowerOfTwo(camera.width), getLowerPowerOfTwo(camera.height));
webcamVideo = new WebcamVideo(  camera, 
                                new Rectangle(
                                    (camera.width - cropping.width) * .5,
                                    (camera.height - cropping.height) * .5,
                                    cropping.width,
                                    cropping.height),
                                false,
                                 WebcamVideo.DRAW_BITMAPDATA|WebcamVideo.UPLOAD_FROM_BITMAPDATA);

The frame rate is set to 15, but if you try you can see that the result is not that bad. 帧频设置为15,但如果尝试尝试,结果可能还不错。 And I've set it to 15, because of the fact that I was testing on an old HTC Sensation (3 years old), S2 and another one old that I forgot. 我将其设置为15,因为我正在测试一个旧的HTC Sensation(3岁),S2和另一个我忘了的旧相机。 You can check the hardware and boost up if needed. 您可以检查硬件并根据需要增强功能。 On HTC One it works like a charm at 30. 在HTC One上,它像30岁时一样具有魅力。

Give it a try, I hope it helps! 试试看,希望对您有所帮助! :) :)

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

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