0
votes

I am having issues with using the camera on Adobe AIR mobile devices.

The performance of the camera is ok on newer phones, but on galaxy s2 for example it is impossible to use. 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. On my galaxy S3 it works around 30fps. I also tried uploading the video to the GPU on every frame using

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)

1
What do you mean by "it is impossible to use"? You ask a question, but provide next-to-no details of what the problem is.Josh
Hey Josh, i added more info.deloki
What do you need the Camera for? Is this something that could be offloaded onto CameraUI? help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/…Josh
As an afterthought, you should also avoid using Video on mobile projects (it is rendered using the CPU which is very slow on mobile)Josh
Thank you Josh for the recommendation, but i must use Camera and not CameraUI because i have to display a transparent overlay image over the camera. Is there something i can replace the Video with?deloki

1 Answers

0
votes

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):

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. 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. You can check the hardware and boost up if needed. On HTC One it works like a charm at 30.

Give it a try, I hope it helps! :)