1

enter image description hereI have to show an image in camera view while user open camera in my app. That will will act like an object somewhere just like pokemon go. I n pokemon go object is moving but not in my case.

I just have to show an image when usr open camera but if user move iPhone left or right then it will not move with device it will stay at the same place. Please help me how can I do this i am in a big hurry.

Surilan
  • 73
  • 1
  • 11
Mashhadi
  • 2,904
  • 3
  • 43
  • 80

1 Answers1

0

Seems you need to customize Camera using AVFoundation framework.

  1. Create your own and customized CameraViewController(Like UIIMagePickerController) and add capture button(and other as per your requirement) by using the AVFoundation framework.
  2. Add a UIImageView like an object with your desired frame and add it to the created CameraViewController,Hide the image view initially/take a default picture for the first time.
  3. When user taps on capture button you’ve created earlier,Ask AVFoundation APIs to capture image and assign the image produced by AVFoundation classes to your image view,un-hide it(as per your need).

There you go,Every time user taps capture image button,Your image view will be updated with the last captured image,will not be updated according to the user movement.

References that could help you on Camera Customization

Apple Developer

Camera with Custom View

https://stackoverflow.com/questions/27824481/creating-custom-camera-with-square-view-on-ios

http://www.xmcgraw.com/learn-how-to-create-a-custom-camera-on-ios/

Happy to help.

Community
  • 1
  • 1
Naresh Reddy M
  • 1,016
  • 1
  • 9
  • 26
  • capturing is not required. in fact user should get a sense like this object is in real world not on camera. Just like Pokemon go – Mashhadi Nov 30 '16 at 12:23
  • Could you please add a screenshot if possible? – Naresh Reddy M Nov 30 '16 at 12:26
  • Image added. in this image there is a virtual pokemon. – Mashhadi Nov 30 '16 at 12:39
  • Yes,as you said,For that image view rather than setting an image from camera,setting a static transparent image with shadow would be sufficient enough? Otherwise try adding a camera over lay for UIIMagePickerViewController without any camera customisation – Naresh Reddy M Nov 30 '16 at 12:58
  • in fact if i move device left or right this image will not move with device this will remain at its space. This gives a real time look. – Mashhadi Nov 30 '16 at 13:00
  • Check my last comment,that might help – Naresh Reddy M Nov 30 '16 at 13:01
  • But Naresh it will stick on screen forever, wherever i go with camera. I want same experience like pokemon go. if you move your camera from that location then it will not stick on your camera it gives a look like it is placed physically on the floor. – Mashhadi Nov 30 '16 at 13:15
  • How about handling the image view's frame based on accelerometer or any other sensor values?Could that help you? – Naresh Reddy M Dec 02 '16 at 04:34