Copy link to clipboard
Copied
I'm trying to rotate a camera feed so it's the correct orientation. It's using the front facing camera on an android phone.
public function setupCamera(param1:int, param2:int) : void
{
this.camera = Camera.getCamera("1");
this.camera.addEventListener(StatusEvent.STATUS,this.camStatusHandler);
this.camera.setMode(param1,param2,stage.frameRate);
this.video = new Video(param1,param2);
this.video.rotation = 90;
this.video.scaleX = -1;
this.video.x = this.video_placement.x + this.video_placement.width;
this.video.y = this.video_placement.y;
this.video.attachCamera(this.camera);
addChildAt(this.video,0);
}
Copy link to clipboard
Copied
First of all, you can get rid of all those 'this.' in your code. AS3 doesn't have scope issues like as2 did. I have not had to use this for years aside from one or two edge cases.
Also you should set your camera frame rate to something like 24 or 30 - stage frame rate which is typically 60 is too much for cam.
Anyway, does the code you use there not work? It's not rotating?
What I do for camera control (and I pretty much make photo booths for a living) is to make a video object like you did, attach the camera - and then not put video on stage. Leave it sit in memory and then image it, in an update loop, into a bitmap that is on stage.
This way you can easily rotate it, flip it, add overlays, etc.
simple example:
cam = Camera.getCamera();
cam.setMode(1280, 865, 24);
theVideo = new Video(1280, 865);
camData = new BitmapData(1280, 865);
camBMP = new Bitmap(camData);
theVideo.attachCamera(cam);
addChild(camBMP);
camTimer = new Timer(1000 / 24); //24 fps cam update
camTimer.addEventListener(TimerEvent.TIMER, camUpdate);
camTimer.start();
private function camUpdate(e:TimerEvent):void
{
camBMP.draw(theVideo, null, null, null, null, true);
}
Copy link to clipboard
Copied
Thank you for the response.
I removed all the ".this" and it broke it completely. No more camera feed.
As for the issues, yes, it just doesn't rotate.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now