{"id":11325,"date":"2015-05-25T09:34:49","date_gmt":"2015-05-25T13:34:49","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=11325"},"modified":"2018-10-25T15:23:08","modified_gmt":"2018-10-25T19:23:08","slug":"camera-and-photos-on-ios","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/05\/25\/camera-and-photos-on-ios\/","title":{"rendered":"Camera and Photos on iOS"},"content":{"rendered":"<p><a href=\"http:\/\/www.objc.io\/issue-21\/how-your-camera-works.html\">Daniel Eggert<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.objc.io\/issue-21\/how-your-camera-works.html\">\n<p>On the iPhone, we can only adjust the ISO and the shutter speed. We can hence trade noise (affected by the ISO) against motion blur\/sharpness while maintaining the same level of exposure.<\/p>\n<p>That explains why photos at night often look worse than those taken during the day: At night there&rsquo;s a lot less light. In order to still have an acceptable shutter speed, the auto exposure will bump up the ISO, probably to the maximum of what the camera allows. And even that may not be enough to achieve enough light, so the auto exposure will also lower the shutter speed. This combination results in more noise in the image, and the image being blurred.<\/p>\n<\/blockquote>\n<p><a href=\"http:\/\/www.objc.io\/issue-21\/camera-capture-on-ios.html\">Matteo Caldari<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.objc.io\/issue-21\/camera-capture-on-ios.html\"><p>The <code>AVCaptureSessionPresetPhoto<\/code> selects the best configuration for the capture of a photo, i.e. it enables the maximum ISO and exposure duration ranges; the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Autofocus#Phase_detection\">phase detection<\/a> autofocus; and a full resolution, JPEG-compressed still image output.<\/p>\n<p>However, if you need more control, the <code>AVCaptureDeviceFormat<\/code> class describes the parameters applicable to the device, such as still image resolution, video preview resolution, the type of autofocus system, ISO, and exposure duration limits. Every device supports a set of formats, listed in the <code>AVCaptureDevice.formats<\/code> property, and the proper format can be set as the  <code>activeFormat<\/code> of the <code>AVCaptureDevice<\/code> (note that you cannot modify a format).<\/p>\n<p>[&#8230;]<\/p>\n<p>New in iOS 8 is the option to move the lens to a position from <code>0.0<\/code>, focusing near objects, to <code>1.0<\/code>, focusing far objects (although that doesn&rsquo;t mean &ldquo;infinity&rdquo;).<\/p>\n<p>[&#8230;]<\/p>\n<p>An interesting feature also introduced in iOS 8 is &ldquo;bracketed capture,&rdquo; which means taking several photos in succession with different exposure settings. This can be useful when taking a picture in mixed light, for example, by configuring three different exposures with biases at &#8722;1, 0, +1, and then merging them with an HDR algorithm.<\/p>\n<\/blockquote>\n<p><a href=\"http:\/\/www.objc.io\/issue-21\/the-photos-framework.html\">Saniul Ahmed<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.objc.io\/issue-21\/the-photos-framework.html\"><p><code>PHAsset<\/code>&rsquo;s <code>representsBurst<\/code> property is <code>true<\/code> for assets that are representative of a burst photo sequence (multiple photos taken while the user holds down the shutter). It will also have a <code>burstIdentifier<\/code> value which can then be used to fetch the rest of the assets in that burst sequence via <code>fetchAssetsWithBurstIdentifier(...)<\/code>.<\/p>\n<p>The user can flag assets within a burst sequence; additionally, the system uses various heuristics to mark potential user picks automatically. This metadata is accessible via <code>PHAsset<\/code>&rsquo;s <code>burstSelectionTypes<\/code> property. This property is a bitmask with three defined constants: <code>.UserPick<\/code> for assets marked manually by the user, <code>.AutoPick<\/code> for potential user picks, and <code>.None<\/code> for unmarked assets.<\/p>\n<p>[&#8230;]<\/p>\n<p>First, you need to register a change observer (conforming to the <code>PHPhotoLibraryChangeObserver<\/code> protocol) with the shared <code>PHPhotoLibrary<\/code> object using the <code>registerChangeObserver(...)<\/code> method. The change observer&rsquo;s <code>photoLibraryDidChange(...)<\/code> method will be called whenever another app or the user makes a change in the photo library <strong>that affects any assets or collections that you fetched prior to the change<\/strong>. The method has a single parameter of type <code>PHChange<\/code>, which you can use to find out if the changes are related to any of the fetched objects that you are interested in.<\/p>\n<\/blockquote>\n<p><a href=\"http:\/\/www.objc.io\/issue-21\/photo-extensions.html\">Sam Davies<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.objc.io\/issue-21\/photo-extensions.html\"><p>A user can chain incompatible photo edits together &mdash; if the adjustment data is not understood by the current extension, the pre-rendered image will be used as input. For example, you can crop an image using the system crop tool before using your custom Photo Editing extension. Once you have saved the edited image, the associated adjustment data will only contain details of the most recent edit. You could store adjustment data from the previous, incompatible edit in your output adjustment data, allowing you to implement a revert function for just your phase of the filter chain. The revert function provided by the Photos app will remove all the edits, returning the photo to its original state.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Daniel Eggert: On the iPhone, we can only adjust the ISO and the shutter speed. We can hence trade noise (affected by the ISO) against motion blur\/sharpness while maintaining the same level of exposure. That explains why photos at night often look worse than those taken during the day: At night there&rsquo;s a lot less [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2018-10-25T19:23:10Z","apple_news_api_id":"df6665af-ff10-4b12-8097-34ce7338b73b","apple_news_api_modified_at":"2018-10-25T19:23:12Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/A32Zlr_8QSxKAlzTOczi3Ow","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[273,152,566,905,1748,1142,31,904,85,153,1203,71,901],"class_list":["post-11325","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-avfoundation","tag-camera","tag-color","tag-extensions","tag-high-dynamic-range-hdr","tag-icloud-photo-library","tag-ios","tag-ios-8","tag-iphone","tag-photography","tag-photokit","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=11325"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11325\/revisions"}],"predecessor-version":[{"id":11326,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11325\/revisions\/11326"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=11325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=11325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=11325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}