Camera is being rotated 90 degree in air for android - android

In my AS3 Flex Mobile application for Android, I am using camera and it is being automatically rotated 90 degrees before I even done any video rotation by myself, it seems like it's a known bug in AIR. But I was wondering if anyone found a solution since it's really pretty important feature for mobile application developer.
I've tried to do some rotation manually in my code, but it is only fixes the view on my display, but still sends the wrong video to the receiver.
If any code is required I will add the snippets
Please let me know.

As you mentioned, this is a known bug with AIR. It is not consistent, either. On some devices, it is in the correct orientation but in some (and all iOS devices, I believe, though I haven't fully tested that), it is rotated as you are seeing. For example, it was always oriented correctly on my Nexus 4 and on my Nexus 5, but a friends Moto X is rotated incorrectly.
Unfortunately, I don't believe there is anything you can do short of having the user do a calibration (i.e. overlay a straight line and tell them to place it horizontally and click a button) and rotating the camera display and any images you take with the display.
That being said, if you are using the camera to take photos, I highly recommend using CameraUI instead, which is the native implementation.

I've faced the same issue today but i'm developping in Java, not with AIR so i don't know if it the same, for me the solution was to add this line before starting the recording.
mMediaRecorder.setOrientationHint(90);

Related

Wrong Camera Orientation with Android & Vuforia

We are developing our own Android-based hardware and we wish to use Vuforia (developed via Unity3D) for certain applications. However, we are having problems making Vuforia work well with our current camera orientation settings.
On our hardware, when the camera is placed horizontally - everything works fine. That is, when the camera is parallel to the placement of the display. However, we need to place the camera vertically, or in other words, with a 90 degree difference to the placement of the display. These are all hardware settings. Our kernel is programmed according to such settings and every other program that utilises the camera works compatibly with everything, including our IMU sensors. However, apps developed with Vuforia behave completely odd when the camera is placed vertically.
We assume the problem to be related to Vuforia's algorithms of processing raw camera data however we are not sure. Moreover, we do not know how to fix the situation. For further details, I can list:
-When "Enable Video Background" is on, the projected image is distorted and no video feed is available. The AR projection appears on a black background with distorted dimensions.
-When "Enable Video Background" is on and the device is rotated, the black background is replaced by flickering solid colors.
-When "Enable Video Background" is off, the AR projection has normal dimensions (no distortion) however it is tracked with wrong axis settings. For example, when the target moves left in real world, the projection moves up.
-When "Enable Video Background" is off and the device is rotated, the AR projection is larger compared to its appearance when the device is in it's default state.
I will be glad to provide any more information you need.
Thank you very much, have a nice day.
PS: We have found out that applications that use the camera as a main purpose (Camera apps, Barcode Scanners, etc) work fine while apps for which camera usage is an extra quality (such as some games) have the same problem as Vuforia. This make me think that apps who access the camera directly work fine whereas those who use Android API and classes fail for some reason.
First understand that every platform deals with cameras differently and that beyond this different android phone manufacturers deal with these differently as well. In my testing WITHOUT vuforia I had to transform the plane I cast the video feed onto 0,-90,90 for android/iphone and -270,-90,90 for the windows surface tablet. Past this the iPhone rear camera was mirrored, the android front camera was mirrored as well as the surface front camera. That is easy to account for, but an annoying issue is that the Google Pixel and Samsung front cameras were mirrored across the y (as were ALL iOS on the back camera), but the Nexus 6p was mirrored across the x. What I am getting at here is that there are a LOT of devices to account for with android so try more than just that one device. Vuforia so far has dealt with my pixel and 4 of my iOS devices just fine.
As for how to fix your problem:
Go into your player settings for unity and look at the orientation. There are a few options here and my application only uses portrait so I force portrait and it seems to work fine (none of the problems I had to account for with the above mentioned scenario). Vuforia previously did NOT support auto rotation so you need to make sure you have the latest version since it sounds like that is what you need. If the auto rotate is set and it is not working right you may have to account for that specific device (don't do this for all devices until after you test those devices). To account for that device use an if (or construct a case statement if you have multiple instances of this problem with different devices) and then reflect or translate as needed. Cross platform development systems (like unity) doesn't always get everything perfect since there is basically no standard. In these cases you have to directly account for them by creating a method and a case statement within that so you can cleanly and modularly manipulate all necessary devices. It is a pain, but it beats developing for all devices separately.
One more thing is make sure you check out the vuforia configuration file as it has some settings such as camera mirror and direction settings on there. These seem to be public settings so you should also be able to script to these in your case statement in the event you need to use "Flip Horizontally" for one phone, but not another.

Why does my local video stream rotate during calls?

We have a native Android webrtc-based voip app. Only in our Android app (as opposed to other platforms), the local camera stream is rotated after being in a call for a while. Usually it takes about 10 seconds. But sometimes more, even as much as a minute.
The remote will get the stream rotated as well, so it's not a rendering issue.
The stream is always rotated 90 degrees clockwise in portrait orientation, but is correct in one landscape orientation and upside down in the other landscape orientation.
After a while, the stream will be rotated back to the correct orientation again (and back to bugged after a while again).
I've tried several revisions ranging from early 8xxx to the latest (9125), all have the same problem. Apprtc demo has the problem as well. I've tested on several different phones (although only Samsung devices) and the problem exists on all of them.
I was faced with the same issue and I didn't found a right solution, but there is a workaround. I found that the reason of the rotation is cpu overuse detection, it leads to changing quality and it seems there is some bug in this functionality in android implementation. So I just added peerConnectionConstraints.optional.add(new MediaConstraints.KeyValuePair("googCpuOveruseDetection", "false"));
and it prevented this rotation.

How to detect when device is oriented upside-down in libGDX

I'm starting to develop a game for Android using libGDX.
I noticed that some sample games for this library all have fixed screen orientation. I want my game to be landscape all the time, but I want to rotate the camera 180 degrees when the device is turned upside down (most well behaved Android apps do this automatically).
I'm looking at the docs and Googling, but can't find anything about it.
Basically, I'd like to know what to add to base libGDX app. that shows libGDX logo, to just react when phone is turned upside down?
The Android docs, list this functionality in getRotation function here:
http://developer.android.com/reference/android/view/Display.html#getRotation%28%29
This allows you to get 0/180 or 90/270 for rotation and thus detect how the device is turned.
But I don't see this exposed in libGDX?
Nevermind, I just found it. You need to change:
android:screenOrientation="landscape"
to:
android:screenOrientation="sensorLandscape"
and it works automagically. Maybe libGDX devs should make this the default.

Using Camera without preview or surface in android

I was looking for a method to use the camera on android devices without a surfaceview or a preview. I found out that, it is impossible to take picture without that preview. However, I have found a tutorial which is actually working taking pictures without a preview. Here is the link: http://www.vogella.com/articles/AndroidCamera/article.html
After switching the camera in the code from front to back-facing the app didn't crashed but it gave me an error 100. So it is only working with the front cam at the moment.
I am using a Samsung Galaxy S3(4.1.2) and i will test it on a Galaxy S2 and a Galaxy S3 Mini.
Anyone a good explanation for this?
You cannot take a picture without starting preview.
While some Android devices are more flexible, and allow takePicture to be called without preview running, this is technically against the API specifications.
It won't work on a large number of devices, so please don't rely on it. That tutorial is wrong, and presumably tested only on one of the devices that allows this behavior.
If you don't want a visible preview, see this question for ways to do that in Android versions >= 3.0.
Actually the time interval of question and answer is large, but may help others.
You can try this library to take picture even from service:
https://github.com/kevalpatel2106/android-hidden-camera
It uses a feature to draw over other apps and create a fake surface. Hope it helps.

Galaxy S3 Video Recording via API "rolls" or is corrupted in Bright Light

Following the instructions from Google here exactly as it is (QUALITY_HIGH):
http://developer.android.com/guide/topics/media/camera.html#custom-camera
When doing this with a Galaxy S3 (US Version) everything seems fine in indoor lighting. But when the camera goes outside and it is bright (maybe it needs to increase the shutter speed) something strange happens. The video starts "rolling" like a bad TV signal, and the image gets to be very low quality. It almost seems like the image sensor got overloaded and messed up.
I tried recording with the normal camera application and it seems to have no problems under the same condition. But using the API as described here generates this problem. Since the S3 is pretty popular -- anyone run into this problem before?
Is there some kind of hidden setting that the main camera app uses for camera setup? I tried flattening the camera settings to take a look at what's in there and there are tons of settings but i dont know what they all do without documentation. already tried turning off anti-banding and luma-adaptation and that didnt seem to do anything.
Thanks!
I think I figured it out. Need more testing but this seems to do it. There is a hidden setting called "camera-mode" that is normally set to -1. I changed it to a 1 and suddenly it is fine and functioning like the normal camera app.. anyone know what this mode thing actually means?
Camera.Parameters lParam = prCamera.getParameters();
lParam.set("camera-mode",1);
prCamera.setParameters(lParam);
Is what did the trick if anyone else seems to run into the problem.\

Categories

Resources