In augmented reality app,on Camera view another transparent view will be, On this transparent view, we used for drawing on camera view and saving it, can you suggest (Start and end) me how to work with this application,
thanks you, have a great day
You'll want to use a UIImagePickerController to show the camera preview. Set its showsCameraControls property to no, so none of the standard photo-taking interface is visible. Now, UIImagePickerControllers have a nice little cameraOverlayView property that you can use to place any view you want over the camera preview. Depending on what precisely you want to augment your reality with, this view could be realized in different ways. For example, if you want to overlay 3D models over the camera preview, this view could be a transparent OpenGL ES context. If you don't need any 3D assets, it can be a regular transparent UIView on which you draw some custom graphics with Quartz. It's up to you, but you want the general pattern of:
UIImagePickerController with showsCameraControls = NO
set cameraOverlayView to some transparent view to render content
This is really a huge question, and there are tons of intricacies depending on the specifics of your design. This is just a general summary.
Related
I've read few questions here on stack and I'm in a dead-end. I want to have device (iPhone/iPad) camera as a background, to one of my ViewControllers. I'm using Storyboard and UINavigationsViewController, so I'm modyfing a child ViewController. As far as I read, this means that I cannot force this "child" to start in specific orientation (first problem).
Secondly, I decided to go with UIImagePickerController, but as I got it right - you cannot rotate this component, right?
So basically my question is where to go from here, to achieve camera view on background no matter what device orientation? It surely can be done, because Vuforia i.e. has it (and they are using UIImagePickerController with EAGLView).
You have two options to do that task:
1) You can use Eaglview to render the frames of camera device in background.
2) You can use caeagllayer to do the same.
To draw on that layer you have to use drawableproperties and CaTransformationMatrix
I have an OpenGL ES 2.0 application for iPad. Is it possible to place text on the screen using a UILabel, like you can in a traditional iOS application?
I tried inserting a label, but it didn't show up. If it is possible, can someone explain the process? Should we insert the label in the viewcontroller.xib file or the mainwindow.xib file, and also where must the appropriate code be written?
As I explain in my similar answers here and here, your OpenGL ES content is hosted within a CAEAGLLayer that backs a particular UIView. This UIView behaves like any other view in the display hierarchy, so you can add UILabels and other controls on top of it or as siblings that overlay this view.
If you are using Interface Builder to lay out your UI, you should have a view that contains your OpenGL ES content somewhere in that interface. You can add the UILabel as a subview of this UIView in Interface Builder and have it show (remember to color the text appropriately so that you don't get black text on a black OpenGL ES background). You can also do this programmatically by using -addSubview: on your OpenGL ES hosting view.
In my tests, overlaying UIKit controls on OpenGL ES content only leads to a slight reduction in rendering speed (from 1-5% in my applications), so this is a viable approach.
If you want to see an example of this in action, look at the source code for my Molecules application, which uses labels and other controls overlaid on the OpenGL ES content on the iPhone.
Only do that if the labels go on top of the OpenGL content. UIKit elements sometimes do not mix well with OpenGL elements. Blending OpenGL content with transparency on top of UIKit elements is really slow. In these cases, it's better to add the label in your OpenGL code. Static text is very easy, just draw a flat object facing the camera and with a texture image of your text. Dynamic text would require more work to adjust the texture with the font to show the correct text.
To do this, add the label to to viewcontroller.xib file, not the mainwindow.xib file. The appropriate code for controlling the UILabel would go in the view controller's .h and .m files. In the standard Xcode iOS OpenGL ES Application template the main view controller's .xib file will contain one EAGLView view. The label can be added to that view, and connected to an IBOutlet in the view controller's .h file.
I want to customize new camera overlay view, so need figure out one way to put new view above self.imagePickerController.cameraOverlayView.
I have tried those ways
[self.view bringSubviewToFront:self.imagePickerController.cameraOverlayView];
[self.imagePickerController.cameraOverlayView bringSubviewToFront:self.view];
[self.view insertSubview:self.view aboveSubview:self.imagePickerController.cameraOverlayView];
But none can work.
Seem that the only way is
self.imagePickerController.showsCameraControls = NO;
Therefore build my own components like iPhone.Camera
I think the idea with the cameraOverlayView is that you use this as a base UIView for anything you'd like to overlay on the camera view. This main overlay view can be transparent, and you just need to place whatever views you want to overlay on the camera as subviews of it.
You can order these subviews however you want within the overlay to achieve the desired visual effects.
Additionally, I recommend watching the WWDC 2010 video session 421 - "Incorporating the Camera and Photo Library in your App", where they go into detail on how to manage camera overlay views. I believe that Apple's PhotoPicker sample application also shows this off.
I'm very new on iPhone development. I'm trying to draw a cross over the image obtained from camera.
I'm using a custom ViewController that inherits from UIImagePickerController.
When I star the application, I see the cross, but a few seconds after the cross disappears.
Should I use cameraOverlayView?
Thank you
UIImagePickerController is not designed to be subclassed. Do so at your own risk.
In OS 3.1, cameraOverlayView is the approved way of drawing over the camera view. Note that if you set an overlay view, the autofocus controls no longer seem to work.
EDIT: Turns out I'm just paraphrasing the docs:
Important: The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. In iPhone OS 3.1 and later, you can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.
I have a view that supports landscape and portrait viewing, with the controls all moving around when you switch from one to the other. I'm currently doing this by setting the .center of each one of my controls when the user rotates the phone. The problem is that this is tedious, and requires a lot of code, and seems to defeat the purpose of using Interface Builder in the first place.
My question is: is there a way in Interface Builder for one view to support multiple looks (one for landscape one for portrait)? If not how do other people do this with IB? Do you set up 2 views?
Edit: Just to clarify my landscape and portrait views look different, I don't want a straight transform, I actually display the data differently in landscape mode
When necessary, I add UIView objects to the view in IB which I make hidden. Give it a nice background color so you can see it, and send it all the way to the background. Then use that view's frame when you need to set the frame of an object. If you have a lot of them, you might consider using UILabel instead, so you can give it a visible name in IB.
If you're worried about memory issues, just remove all these extra UIViews in ViewDidLoad and just store their frame values in member CGRects. This only works of course if you don't have any of the views auto-resize or reposition on rotate, which you probably shouldn't anyway, in this case. I do this for resizing/repositioning for any reason, not just when the screen rotates.
I'm not 100% sure if it's possible, but have you considered using different view controllers for landscape and portrait?
The AutoSize attributes of IBOutlet objects in the Size Inspector of IB (command 3) give some pretty nice options for auto-stretching and positioning of items. You can control L/R and T/B screen positions and relative width and height. You can't get full control of the layout, but most of the basic operations are there.
The only way one view can support multiple orientations in IB is to set the autosizing mask of components to either scale and/or anchor to edges. To design a totally different layout for each orientation you need to design a portrait and landscape view separately (each in its own XIB) and switch between them programatically.