Rotate or flip preview in Android Camera2 API - android-camera

I am trying to rotate and/or flip the preview being displayed using the Camera2 API.
I tried setting the JPEG_ORIENTATION on the previewRequestbuilder to rotate the preview but that did not have any effect.
What other methods are available to rotate the preview?
In Camera1, this was achieved via setdisplayorientation.

There is no direct control for this - for SurfaceViews and TextureViews, the correct rotation is baked in by the API. For a pure SurfaceTexture, the getTransform() call includes the correct rotation.
If you want your own custom flip or rotation, you'll need to do your own GL rendering with a SurfaceTexture and a GLSurfaceView or equivalent.

Related

Is it posibile to change the focus for Camera Module V2?

I am using the camera for reading some text and currently, my images look quite blurry
Is it possible to change the focus of the camera?
I am using
https://www.raspberrypi.org/products/camera-module-v2/
Yes, it's definitely possible, I did it many times. Sometimes in the camera box there is even a specific tool to rotate the lens included (check if you have it, I experienced that it's not always present). If you don't have a tool take thin pliers and rotate the lens, you can look here.

Transform FlutterRenderer or SurfaceTexture

Question, I am currently struggling a bit with trying to improve the orientation of the Flutter Camera plugin specifically on Android. The problem I am facing is that when I move from portrait to landscape the preview doesn't rotate correctly (the actual captured picture or recorded video is fine). The Camera plugin uses the Android Camera2 API under the hood and researching this topic a bit it seems you can correct the rotation of the preview using the transform method of the TextureView as demonstrated in the Android Camera2Basic example App (see https://github.com/googlearchive/android-Camera2Basic/blob/4cc1c3e219d8d168b7893f7a6b2b348740679e5a/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java#L740).
Problem is that in the Flutter plugin I don't have access to a TextureView, I only have access to the FlutterRenderer instance and the SurfaceTexture that is created by the FlutterRenderer using the createSurfaceTexture method.
So my question is: is it possible to rotate or transform the SurfaceTexture and if so how would I approach this? Currently I can compensate for the rotation on the Dart/Flutter side by nesting the Texture in a RotatedBox widget. This however will mess up the orientation on the iOS side (meaning I need to use the widget conditionally based on the Platform). It also puts a bit of extra overhead on people that want to directly use the Texture widget in their Apps and instead of the preconfigured widget supplied from the Camera package.
Below is a screenshot demonstrating the behaviour:

switching from one camera to other in unity ,view entering from right

I have two cameras in the same position.I want to switch from one camera to other (with a transition effect) such that second view replaces the first camera view entering from the left side moving inwards and filling the screen.. Camera fading in and fading out effects are available in unity wiki..Can anyone suggest me a technique to achieve this effect..
You can try to animate Camera.rect. Otherwise you will have to render both in a RenderTexture and combine rendered images in a small shader with a translate parameter changing from 0 to 1.
While i'm not really really sure of the application for the switching of the camera if you were to instantiate it dynamically you would be able to use lerp and other function calls to manipulate behavior and not need to use multiple cameras.
http://docs.unity3d.com/Documentation/ScriptReference/Vector3.Lerp.html
As a side note i'm sure you could reverse engineer some camera effects similar to this one in order to achieve the background(a little confused about what you want to do with that)
http://docs.unity3d.com/Documentation/Components/script-CameraMotionBlur.html

iPhone UIImagePickerController: show camera preview on top of openGl viewport

i've a question about UIImagePickerController class reference, in photo-camera mode.
I'm developing an OpenGl game. I should add to game photo-camera features: game should open a window (say for example 200x200 pixels, in the middle of screen), that display in real time a preview of photo-camera IN FRONT OF GL VIEWPORT. So photo-camera preview must be in a window of 200x200 in front of our Gl viewport that display game.
I've some questions:
- main problem is that i've difficult to open UIImagePickerController window in front of our Gl viewport (normally UIImagePickerController window covers all iPhone screen);
which is the better way to capture an image buffer periodically to perform some operations, like face detection (we have library to perform this on a bitmap image) ?
iPhone can reject such approach? It's possible to have this approach with camera (camera preview window that partially overlap an openGl viewport) ?
at the end, it's possible to avoid visualization of camera shutter? I'd like to initialize camera without opening sound and shutter visualization.
This is a screenshot:
http://www.powerwolf.it/temp/UIImagePickerController.jpg
If you want to do something more custom than what Apple intended for the UIImagePickerController, you'll need to use the AV Foundation framework instead. The camera input can be ported to a layer or view. Here is an example that will get you half way there (it is intended for frame capture). You could modify it for face detection by taking sample images using a timer. As long as you use these public APIs, it'll be accepted in the app store. There are a bunch of augmented reality applications that use similar techniques.
http://developer.apple.com/library/ios/#qa/qa2010/qa1702.html

Recreating streetview effect in my own iPhone App

My app allows you too "look" around a room in every similar manner to how you can "look" around a street when you are in streetview in the Maps application. Does anyone know of a simple way to recreate this effect?
I do have an image (like the streetview image) that I would like users to look around in.
Some ideas I have:
1) Put the image in a scroll view and let users pan and zoom. This doesn't seem like it would have the same effect as when you pan around the streetview, objects near the edges stretch to give you a "lens" type effect.
2) Apply a transform to the image before drawing it in a scroll view, and reapply the transform during scrolling. This transform would create the lens effect on the currently viewed part of the image.
3) Use open GL to create a hollow sphere and apply the image as a texture on the inside of the sphere.
doesn't seem like it would work
seems like my best option but I don't know what transform to use in quartz to create this effect. I like this though because it uses a scroll view and I don't have to recreate the panning, flicking and pinching code.
seems like overkill and too much work
Any ideas?