Тёмный

iOS Programming 27: Custom Camera View & Taking Photos 

99CentsAppDevelopment
Подписаться 8 тыс.
Просмотров 42 тыс.
50% 1

www.99centsappd...
In this tutorial we look at how to create a custom camera view using AVCaptureSession. This will allow us to display a live camera preview in our view controller, and then take a photo/video with your device's camera and display it in realtime in a UIImageView.
Be sure to like and subscribe, and visit our website (and like us on Facebook) to get access to more great content!
www.99centsappd...
/ 99centsappdevelopment

Опубликовано:

 

19 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 39   
@lipslidemyrail
@lipslidemyrail 9 лет назад
Any chance you could do something like this in Swift? 99CentsAppDevelopment
@navderm
@navderm 9 лет назад
One of the best tutorial for a piece of code !! Amazing work ! :)
@abdoulyousseffouattara9056
@abdoulyousseffouattara9056 9 лет назад
Your video was very helpful for me! Nice job!!
@cragworks
@cragworks 10 лет назад
I found an error with this tutorial, that I'm sure others will have too. The outputted image you captured is not the same resolution as the camera feed shows. Even though it looks like you took a square sized picture, the output is still a normal portrait image that is stretched, no matter what you set the UIImage to be in storyboard. The way around it is to crop the outputted image programmatically using code. You can view the code at my github. Username is cragworks. Titled: customcamera_cropped_image_4by3_output
@amansinghbhandari5853
@amansinghbhandari5853 7 лет назад
That's because camera's and image's resolution is different.
@sebleonTV
@sebleonTV 8 лет назад
code from video: gist.github.com/sebleon/228c091002a95dcf8898
@timcropper-williams6909
@timcropper-williams6909 9 лет назад
This worked great, thanks for the tutorial! DO you have any guidance on doing exactly the same thing but to capture a video instead? Thanks
@LMPGames
@LMPGames 9 лет назад
Could not get this code to work for my in Xcode 6. The way the camera is tied to the UIView did not work for me, it kept showing up on the wrong place. I had to use this instead: AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:cSession]; [previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill]; previewLayer.frame = self.cameraFrame.bounds; [self.cameraFrame.layer addSublayer:previewLayer]; UIView *view = [self cameraFrame]; CALayer *rootLayer = [view layer]; [rootLayer setMasksToBounds:YES]; CGRect frame = self.cameraFrame.bounds; [previewLayer setFrame:frame]; [rootLayer insertSublayer:previewLayer atIndex:0]; pretty much the same except .bounds instead of .frame for the CGRect object.
@jhwj9617
@jhwj9617 8 лет назад
+Laughing Man Productions² Had the same problem. This worked for me :D
@Danielleal04
@Danielleal04 4 года назад
I love this tutorial, however, AVPStillImageOutput is depreciated for iOS 10+. So, now it is AVCapturePhotoOutput.
@PaulKasp91
@PaulKasp91 10 лет назад
Custom Camera View part 2: Adding Front/Rear camera switch ???
@dreamerPsp
@dreamerPsp 8 лет назад
Modifying "[rootLayer insertSublayer:previewLayer atIndex:0]" to "[rootLayer addSublayer:previewLayer]" worked for me
@johnsim3722
@johnsim3722 7 лет назад
+1. Made the sample code work, thank you!
@MrCoolstorybro97
@MrCoolstorybro97 10 лет назад
Can you please show us how to link the photo library and possibly add effects to the image too?
@tuanphamvan4600
@tuanphamvan4600 10 лет назад
This is great tutorial
@nykwhitebread
@nykwhitebread 9 лет назад
thanks for your sharing! Can this project be implemented in solely swift?
@dsmeier
@dsmeier 10 лет назад
Great tutorial! How would I capture a still image in a different viewcontroller from where the avcapturesession occurs ?
@MoeenAhmadAppDeveloper
@MoeenAhmadAppDeveloper 9 лет назад
When I am trying to get front facing camera my image stuck out I know exact why I am setting indexat 0 when I change it to below or above my problems solve but I am nt able to get my graphic image inside by button which is in cam view. What I suppose to do now any suggestions.
@Rene86
@Rene86 10 лет назад
Hi Jack, Thanks for the nice video, i Think ive done everything right but when i run the app on my iPhone i only see a black screen with the green battery percentage. Any idea what im doing wrong? Cheers Xcode highlights the line with the &error in green in xcode, not sure what this means.
@Chadow_fint
@Chadow_fint 8 лет назад
+R. Hendriksen mb u turned on some breakpoint and thats why app pauses
@kaz04271
@kaz04271 10 лет назад
So basically this is a custom way to use the phone's camera instead of using UIImagePickerController?
@talhahussain1875
@talhahussain1875 4 года назад
am trying to built the same in macos, how should i proceed?
@taylorgreen6243
@taylorgreen6243 10 лет назад
I would really love to know how to save the photos to the Photo Library..
@MrDingdongdich
@MrDingdongdich 9 лет назад
I don't know if this is still relevant to you, but if you are programming with swift, check out the UIImageWriteToSavedPhotoAlbum method
@dmaratb
@dmaratb 9 лет назад
excellent
@manimegalaia313
@manimegalaia313 7 лет назад
i want this coding for ios app in c# using xamarin and visual studio
@maigiang7685
@maigiang7685 7 лет назад
Thank you so much :)
@MrRao8
@MrRao8 10 лет назад
How can I switch to the front facing camera?
@DarksteelPenguin
@DarksteelPenguin 9 лет назад
Instead of using DefaultDevice, get AVCaptureDevice.devices() and in this list, get the device with (device.position == AVCaptureDevicePosition.Front) (Sorry if it is not what you expected, I'm using swift, I don't know how to do that in ObjectiveC)
@russellwarwick
@russellwarwick 9 лет назад
use this method - (AVCaptureDevice *)frontCamera { NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; for (AVCaptureDevice *device in devices) { if ([device position] == AVCaptureDevicePositionFront) { return device; } } return nil; } and then change the AVCaptureDevice *inPutdevice ...... to AVCaptureDevice *inPutdevice = [self frontCamera]; hope this helps :)
@sammas9554
@sammas9554 10 лет назад
always the best
@marleynicolson8203
@marleynicolson8203 9 лет назад
why is there no swift tutorials
@jiyilun
@jiyilun 9 лет назад
how can i get raw file with this ?
@Match1220
@Match1220 9 лет назад
Hello, i follow your turtorial to make a camera app, but i got a crack when i run the app,why should be that?Hope can solve it,Thanks database[2136:597344] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key camera.'
@sanarezgui5911
@sanarezgui5911 8 лет назад
would you please send me code? Thx.
@techgeek4176
@techgeek4176 8 лет назад
i dont know
@gpupdateforcesoftwareanl2580
@gpupdateforcesoftwareanl2580 9 лет назад
don't work is Xcode 7
@johnglenna
@johnglenna 9 лет назад
How do you switch to your frontcamera?
@timcropper-williams6909
@timcropper-williams6909 9 лет назад
+SpeSefick This just worked for me: stackoverflow.com/questions/10795327/set-front-facing-camera-in-xcode
Далее
Apple iOS Development: Understanding AV Foundation
27:14
iOS Swift 1: Creating a Hello World App
17:41
Просмотров 328 тыс.
iOS Dev Job Interview - Must Know Topics
2:27:40
Просмотров 83 тыс.
How to Do 90% of What Plugins Do (With Just Vim)
1:14:03
Просмотров 895 тыс.
Learning Swift #6 - Making a Drawing App
24:08
Просмотров 72 тыс.
SwiftUI Masterclass: Build To Do List App
2:42:49
Просмотров 126 тыс.
Linux from Scratch
2:35:42
Просмотров 174 тыс.