Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotate RAW CAMERA (not just the video) in air for android

I'm using the Flex Hero Pre-release 4.5 and this is a Flex Mobile application for android.

I have a situation where the raw camera is being displayed on the screen and its being transmitted in a netstream. Apparently right now in AIR for android if you’re simply using the raw camera in portrait it doesnt actually shoot the camera in portrait...it’s 90 degrees in the wrong direction. So, here’s a code snippet where i rotated the video and it looks great on the phone. however, i need to attach the cam to a netstream and send it...but it sends sideways video, and i dont really want to adjust it on the far end. and I can’t attach a video to a netstream...Anyone have any ideas what I could do rather than just waiting for an AIR update for this?

//i know i have width and height mixed up, its because im rotating it in a second and i dont want it to be stretched
                                nearVideo = new Video(near_video.height,near_video.width);

var m:Matrix = new Matrix();
//rotate here
m.rotate(Math.PI/2); 
this.nearVideo.transform.matrix = m;
//repositioning it so it looks like its fitting in the container correctly
nearVideo.x=near_video.width;
nearVideo.y=(near_video.height-near_video.height);

if (Camera.isSupported)
{
nearCam = Camera.getCamera();
}

nearCam.setMode(near_video.height,near_video.width,10);
nearVideo.attachCamera(nearCam);
near_video.addChild(nearVideo);

//now its all great on screen...but when this comes up

sendStream.attachCamera(nearCam);

//i’m sending sideways video... 

edit: I know i could tell the far end to just rotate the video object its using to display the sideways camera. but for many reasons that's not the a solution i want to accept. Hopefully adobe will just fix this soon. But until then im just curious if maybe someone knows how i can rotate the camera and attach it to the netstream.

like image 923
brybam Avatar asked Apr 25 '11 03:04

brybam


2 Answers

Well, To me it's looking like the only real solution other than rotate the video on the far end is to just get adobe to fix the camera. So, if you found this page because you were frustrated with the camera on android not being able to rotate correctly in portrait please vote up the bug here and lets get them to fix it:

http://bugs.adobe.com/jira/browse/SDK-30317

like image 117
brybam Avatar answered Sep 24 '22 19:09

brybam


Sadly, you can't intercept the camera stream to modify it before sending it off to the server, this is a bug that hopefully adobe will fix in the next version of Air. If there is no tickets open for it, you should open one.

However, not all is lost! What the camera class does with NetStream is essentially just sending the video bytes that you camera captures and of course there's a quality changing algorithm depending on bandwidth. You could try to do the same thing yourself, however the quality changing algorithm would be a bit harder to implement, but not impossible.

Essentially, since you're displaying the camera video somewhere (Video class maybe?), you could take that bitmap data, convert it to a ByteArray and send it over the NetStream using send. Of course, the server (or other client) would need to know what to do with it.

No guarantees if this would work well as I've never tried, but this is what I would do. Another way of doing it would be to 'tell' the media server (I'm assuming you're using one) that you're currently in landscape mode (just have a boolean flag) and then server can do the transform for you and send it off to the other person.

Either way, it won't be easy. Good luck.

like image 23
J_A_X Avatar answered Sep 24 '22 19:09

J_A_X