zhangao0086 / dkcamera Goto Github PK
View Code? Open in Web Editor NEWA light weight & simple & easy camera for iOS by Swift.
License: MIT License
A light weight & simple & easy camera for iOS by Swift.
License: MIT License
There are situations where the values saved to gpsMetadata[(kCGImagePropertyGPSLatitude)]
gpsMetadata[(kCGImagePropertyGPSLongitude)]
can be negative in value and therefore the location of the photo is wrong. I have fixed it by doing this :
let longitude = location.coordinate.longitude
let latitude = location.coordinate.latitude
let altitudeRef = Int(location.altitude < 0.0 ? 1 : 0)
let latitudeRef = latitude < 0.0 ? "S" : "N"
let longitudeRef = longitude < 0.0 ? "W" : "E"
// GPS metadata
gpsMetadata[(kCGImagePropertyGPSLatitude)] = abs(latitude)
gpsMetadata[(kCGImagePropertyGPSLongitude)] = abs(longitude)
I will submit a pull request for you to look at. I am hoping to move away from my own custom fork of this. This camera library is great by the way
Expect a pull request early next week.
https://github.com/zhangao0086/DKCamera#easy-to-use
let camera = DKCamera()
camera.didCancel = { () in // not didCancelled
print("didCancelled") // not println
self.dismissViewControllerAnimated(true, completion: nil)
}
camera.didFinishCapturingImage = {(image: UIImage) in
print("didFinishCapturingImage") // not println
self.dismissViewControllerAnimated(true, completion: nil)
self.imageView?.image = image // totally bogus?
}
self.presentViewController(camera, animated: true, completion: nil)
I am getting a warning in my project saying "interfaceOrientation was deprecated in iOS 8.0"
This warning is appearing in DKCamera.
I am currently unsure how to fix it, do you have any idea?
在代码里有看到didFinishCapturingVideo的代码,但是DKCamera并不支持视频录制。
if the user does not authorize the camera access and then reopens it, the app crashes
How can we use the onFaceDetction?
let dkCAM = DKCamera()
error is ('DKCamera' initializer is inaccessible due to 'internal' protection level)
Got this error in my firebase crashlytics report -
Crashed: DKCamera_CaptureSession_Queue
0 DKCamera 0xb904 $s8DKCameraAAC12captureImage33_C20F7E3C6CBBF8D643BCFD75C4606AFCLLyyySo7UIImageCSg_SDys11AnyHashableVypGSgs5Error_pSgtcF + 688
1 DKCamera 0xb44c $s8DKCameraAAC11takePictureyyFyycfU_ + 96
2 DKCamera 0x644c $sIeg_IeyB_TR + 28
3 libdispatch.dylib 0x2320 _dispatch_call_block_and_release + 32
4 libdispatch.dylib 0x3eac _dispatch_client_callout + 20
5 libdispatch.dylib 0xb534 _dispatch_lane_serial_drain + 668
6 libdispatch.dylib 0xc0a4 _dispatch_lane_invoke + 384
7 libdispatch.dylib 0x16cdc _dispatch_workloop_worker_thread + 648
8 libsystem_pthread.dylib 0xddc _pthread_wqthread + 288
9 libsystem_pthread.dylib 0xb7c start_wqthread + 8
Below is the complete stack trace -
# Crashlytics - Stack trace
# Application: XXXXXXXXXXXXX
# Platform: apple
# Version: X.X
# Issue: 738711ca2cdf94375b7a5cc6aeff47b2
# Session: 03229e56f3564cb99ef0bfe4901ce218_DNE_0_v2
# Date: Tue May 30 2023 21:04:17 GMT+0430
com.apple.main-thread
0 libsystem_kernel.dylib 0xc84 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x13b54 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x13e2c mach_msg_overwrite + 540
3 libsystem_kernel.dylib 0x11c8 mach_msg + 24
4 CoreFoundation 0x79114 __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x7a340 __CFRunLoopRun + 1208
6 CoreFoundation 0x7f4dc CFRunLoopRunSpecific + 612
7 GraphicsServices 0x135c GSEventRunModal + 164
8 UIKitCore 0x39d37c -[UIApplication _run] + 888
9 UIKitCore 0x39cfe0 UIApplicationMain + 340
10 libswiftUIKit.dylib 0x350b0 UIApplicationMain(_:_:_:_:) + 104
11 AFM Driver 0x6874 main + 4332791924 (RejectTripVC.swift:4332791924)
12 ??? 0x1bb444dec (Missing)
Thread
0 libsystem_kernel.dylib 0x118c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0xe28 _pthread_wqthread + 364
2 libsystem_pthread.dylib 0xb7c start_wqthread + 8
Thread
0 libsystem_kernel.dylib 0x118c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0xe28 _pthread_wqthread + 364
2 libsystem_pthread.dylib 0xb7c start_wqthread + 8
Thread
0 libsystem_kernel.dylib 0x118c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0xe28 _pthread_wqthread + 364
2 libsystem_pthread.dylib 0xb7c start_wqthread + 8
com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0xc84 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x13b54 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x13e2c mach_msg_overwrite + 540
3 libsystem_kernel.dylib 0x11c8 mach_msg + 24
4 CoreFoundation 0x79114 __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x7a340 __CFRunLoopRun + 1208
6 CoreFoundation 0x7f4dc CFRunLoopRunSpecific + 612
7 Foundation 0x420c4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8 Foundation 0x41fac -[NSRunLoop(NSRunLoop) runUntilDate:] + 64
9 UIKitCore 0x4cfdac -[UIEventFetcher threadMain] + 416
10 Foundation 0x5b634 __NSThread__start__ + 716
11 libsystem_pthread.dylib 0x16b8 _pthread_start + 148
12 libsystem_pthread.dylib 0xb88 thread_start + 8
Thread
0 libsystem_pthread.dylib 0xb74 start_wqthread + 254
Thread
0 libsystem_kernel.dylib 0x118c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0xe28 _pthread_wqthread + 364
2 libsystem_pthread.dylib 0xb7c start_wqthread + 8
com.google.firebase.crashlytics.MachExceptionServer
0 FirebaseCrashlytics 0x1eea8 FIRCLSProcessRecordAllThreads + 184
1 FirebaseCrashlytics 0x1f288 FIRCLSProcessRecordAllThreads + 1176
2 FirebaseCrashlytics 0x164dc FIRCLSHandler + 48
3 FirebaseCrashlytics 0x18c9c FIRCLSMachExceptionServer + 688
4 libsystem_pthread.dylib 0x16b8 _pthread_start + 148
5 libsystem_pthread.dylib 0xb88 thread_start + 8
com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0xc84 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x13b54 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x13e2c mach_msg_overwrite + 540
3 libsystem_kernel.dylib 0x11c8 mach_msg + 24
4 CoreFoundation 0x79114 __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x7a340 __CFRunLoopRun + 1208
6 CoreFoundation 0x7f4dc CFRunLoopRunSpecific + 612
7 CFNetwork 0x2587e0 _CFURLStorageSessionDisableCache + 60900
8 Foundation 0x5b634 __NSThread__start__ + 716
9 libsystem_pthread.dylib 0x16b8 _pthread_start + 148
10 libsystem_pthread.dylib 0xb88 thread_start + 8
Crashed: DKCamera_CaptureSession_Queue
0 DKCamera 0xb904 $s8DKCameraAAC12captureImage33_C20F7E3C6CBBF8D643BCFD75C4606AFCLLyyySo7UIImageCSg_SDys11AnyHashableVypGSgs5Error_pSgtcF + 688
1 DKCamera 0xb44c $s8DKCameraAAC11takePictureyyFyycfU_ + 96
2 DKCamera 0x644c $sIeg_IeyB_TR + 28
3 libdispatch.dylib 0x2320 _dispatch_call_block_and_release + 32
4 libdispatch.dylib 0x3eac _dispatch_client_callout + 20
5 libdispatch.dylib 0xb534 _dispatch_lane_serial_drain + 668
6 libdispatch.dylib 0xc0a4 _dispatch_lane_invoke + 384
7 libdispatch.dylib 0x16cdc _dispatch_workloop_worker_thread + 648
8 libsystem_pthread.dylib 0xddc _pthread_wqthread + 288
9 libsystem_pthread.dylib 0xb7c start_wqthread + 8
Thread
0 libsystem_kernel.dylib 0x118c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0xe28 _pthread_wqthread + 364
2 libsystem_pthread.dylib 0xb7c start_wqthread + 8
com.apple.CoreMotion.MotionThread
0 libsystem_kernel.dylib 0xc84 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x13b54 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x13e2c mach_msg_overwrite + 540
3 libsystem_kernel.dylib 0x11c8 mach_msg + 24
4 CoreFoundation 0x79114 __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x7a340 __CFRunLoopRun + 1208
6 CoreFoundation 0x7f4dc CFRunLoopRunSpecific + 612
7 CoreFoundation 0xc1f84 CFRunLoopRun + 64
8 CoreMotion 0x136e8 CLMotionActivity::isTypeInVehicle(CLMotionActivity::Type) + 23144
9 libsystem_pthread.dylib 0x16b8 _pthread_start + 148
10 libsystem_pthread.dylib 0xb88 thread_start + 8
I am using this library as part of my iOS app.
previously I used ALCameraViewController. But not only was it bloated but i had alot of random app crashes.
After substituting it with DKCamera my crash statistics went to 0!
in version 1.5 I have not had 1 crash yet, it has been out in store for 3 days.
this is my app:
https://itunes.apple.com/us/app/ocr-scan-text-from-camera/id1163617952
please update to swift 5.0
Hi, you have a great camera! I'm facing an issue, sometimes I catch errors while using the camera: DKCameraError: (Error: Cannot Record).
It occurs randomly, I did not find any system. It occurs in class DKCameraPhotoCapturer in both functions photoOutput.
Search on the Internet did not give any results of this error, what can it be? Why this error occurs? Have you any ideas?
Our application crashed with the following backtrace:
Thread : Crashed: com.apple.root.default-qos
0 DKCamera 0x8f4d18 DKCamera.(takePicture(DKCamera) -> () -> ()).(closure #1) (DKCamera.swift)
1 DKCamera 0x8f4be0 DKCamera.(takePicture(DKCamera) -> () -> ()).(closure #1) (DKCamera.swift:279)
2 libdispatch.dylib 0x384dced7 _dispatch_call_block_and_release + 10
3 libdispatch.dylib 0x384e8871 _dispatch_root_queue_drain + 1572
4 libdispatch.dylib 0x384e824b _dispatch_worker_thread3 + 94
5 libsystem_pthread.dylib 0x38671e29 _pthread_wqthread + 1024
6 libsystem_pthread.dylib 0x38671a18 start_wqthread + 8
That looks like
connection.videoOrientation = self.currentOrientation.toAVCaptureVideoOrientation()
I don't understand why that could crash. Is it possible that currentOrientation or toAVCaptureVideoOrientation() could be nil?
Cannot override 'photoOutput' which has been marked unavailable
'jpegPhotoDataRepresentation(forJPEGSampleBuffer:previewPhotoSampleBuffer:)' is unavailable in Mac Catalyst
'fileDataRepresentation(withReplacementMetadata:replacementEmbeddedThumbnailPhotoFormat:replacementEmbeddedThumbnailPixelBuffer:replacementDepthData:)' is unavailable in Mac Catalyst
Crashed: DKCamera_CaptureSession_Queue
0 DKCamera 0xe644 DKCamera.captureImage(_:) + 816 (DKCamera.swift:816)
1 DKCamera 0x12f38 partial apply for closure #1 in DKCamera.takePicture() + 721 (DKCamera.swift:721)
2 DKCamera 0x8830 thunk for @escaping @callee_guaranteed () -> () + 4338927664 (:4338927664)
3 libdispatch.dylib 0x2914 _dispatch_call_block_and_release + 32
4 libdispatch.dylib 0x4660 _dispatch_client_callout + 20
5 libdispatch.dylib 0xbde4 _dispatch_lane_serial_drain + 672
6 libdispatch.dylib 0xc958 _dispatch_lane_invoke + 392
7 libdispatch.dylib 0x171a8 _dispatch_workloop_worker_thread + 656
8 libsystem_pthread.dylib 0x10f4 _pthread_wqthread + 288
9 libsystem_pthread.dylib 0xe94 start_wqthread + 8
I just tested this, by commenting out the line below in takePicture():
self.stillImageOutput = nil // Just taking only one image.
and do not dismiss the view controller in didFinishCapturingImage(), it actually supports taking multiple photos!
It is a nice feature. Can you add this as an official feature, so others do not need to change the code directly?
I cannot override the takePicture() or make a new function for this, because stillImageOutput
is fileprivate
. Making it non-private will work as well.
We're quite fond of DKCamera - but we would like to move some of the buttons around. The easy way would be to subclass it and customize positions by overriding setupUI - but the buttons and that method are all private.
We could just copy the file and tweak stuff to our liking - but that's so icky.
So... how do you feel about unprivatizing just about everything to make subclassing easy?
When trying to run the latest version after use cocoapods I receive compiler errors with the DKCamera.swift file
Hello. I faced a crash that is caused by force unwrap of frontInput variable in setupCurrentDevice() function.
To reproduce this crash you need to forbid access to a camera, close current camera VC and then just try to open camera again.
Thank you.
We want to take pictures using API sometimes.
diff --git a/DKCamera/DKCamera.swift b/DKCamera/DKCamera.swift
index 3d09cc9..beab288 100644
--- a/DKCamera/DKCamera.swift
+++ b/DKCamera/DKCamera.swift
@@ -262,7 +262,7 @@ public class DKCamera: UIViewController {
self.didCancel?()
}
- internal func takePicture() {
+ public func takePicture() {
let authStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo)
if authStatus == .Denied {
return
Hello.
When i get an UIImage from didFinishCapturingImage it looks ok, but UIImageOrientation parameter is wrong...
I use UIImage.fixOrientation() from stackoverflow to fix this.
Its looks like a bad solution.. Do you know whats the reason?
Thank you.
Recently I received this crash from app on production:
Device
Stack trace
Crashed: DKCamera_CaptureSession_Queue
0 DKCamera 0x1022c7bf4 DKCamera.captureImage(_:) + 768 (DKCamera.swift:768)
1 DKCamera 0x1022cee90 partial apply for closure #1 in DKCamera.takePicture() + 721 (DKCamera.swift:721)
2 DKCamera 0x1022bf428 thunk for @escaping @callee_guaranteed () -> () + 4326470696 (:4326470696)
3 libdispatch.dylib 0x190ac56c8 _dispatch_call_block_and_release + 24
4 libdispatch.dylib 0x190ac6484 _dispatch_client_callout + 16
5 libdispatch.dylib 0x190a6dbd0 _dispatch_lane_serial_drain$VARIANT$mp + 592
6 libdispatch.dylib 0x190a6e718 _dispatch_lane_invoke$VARIANT$mp + 432
7 libdispatch.dylib 0x190a76eb8 _dispatch_workloop_worker_thread + 600
8 libsystem_pthread.dylib 0x190ca90dc _pthread_wqthread + 312
9 libsystem_pthread.dylib 0x190cabcec start_wqthread + 4
Any idea what can cause it or how can it be fixed?
Thanks
Hello, when changing the device orientation on iPad with camera active, the image behind gets rotated too. On iPhone it works as expected
This happens rarely on initialization - no idea why.
Crashed: com.apple.main-thread
EXC_BREAKPOINT 0x000000010088d2d8
Thread : Crashed: com.apple.main-thread
0 DKCamera 0x10088d2d8 DKCamera.initialOriginalOrientationForOrientation() -> () (DKCamera.swift:497)
1 DKCamera 0x10089161c DKCamera.(viewWillAppear(DKCamera) -> (Bool) -> ()).(closure #1) (DKCamera.swift:113)
2 Foundation 0x1842f0334 NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 16
3 Foundation 0x184243100 -[NSBlockOperation main] + 96
4 Foundation 0x184233348 -[__NSOperationInternal _start:] + 604
5 Foundation 0x1842f2728 __NSOQSchedule_f + 224
6 libdispatch.dylib 0x18339d5f0 _dispatch_client_callout + 16
7 libdispatch.dylib 0x1833a2cf8 _dispatch_main_queue_callback_4CF + 1844
8 CoreFoundation 0x183900bb0 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 12
9 CoreFoundation 0x1838fea18 __CFRunLoopRun + 1628
10 CoreFoundation 0x18382d680 CFRunLoopRunSpecific + 384
11 GraphicsServices 0x184d3c088 GSEventRunModal + 180
12 UIKit 0x1886a4d90 UIApplicationMain + 204
13 Bolt 0x10011ebc0 main (AppDelegate.swift:18)
14 libdispatch.dylib 0x1833ce8b8 (Missing)
Hi
The crash was produced when "take photo" button was tapped several times. Try tapping the button continually until the application will crash. If it won't, try with front-facing camera.
In my case it was produced on several phones: iPhone 8 with iOS 12.1.2 and iPhone 5c with iOS 10.2
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (54) must be equal to the number of items contained in that section before the update (52), plus or minus the number of items inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).'
How i can make with the DKCamera a customcameraview in the Cocoapod library are not accurately defined.
The second question that i have was, can i record videos with this camera ?
Thank you for your Help :)
Hi @zhangao0086 ,
its great work but I'm facing an issue in camera capture. Its not opening camera view in fullscreen mode and image captured on iPad are also not in full screen. do we have any solution or workaround for that ?
I've added an overlay that covers the whole screen (ios):
cameraOverlayView = myView
cameraOverlayView.frame = self.view.frame
There are a couple of buttons on the overlay, and they work fine. But when I click on any other location on the screen, the click passes through to the focus view - bypassing the buttons (take picture, flash, reverse).
(the buttons I'm adding on on the bottom left and on the right side of the screen)
I am using XCode 9.4.1 and Swift 4.1 and getting error on project compilation
Issue
Type 'UIView' has no member 'AnimationOptions'
DKCamera.swift -> Line 793
Solutions tried
I then downgraded the pod version to 1.5.3 but it still shows the same error.
We got a very odd crash with a DKCamera stacktrace. This claims that the flashMode is not supported. It was on a 5c - but I don't know anything more about it, and I have not yet reproduced it. This has only happened one time. Looks like all the action was in the main thread. Honestly, I don't see how this was possible.
Fatal Exception: NSInvalidArgumentException
*** -[AVCaptureVideoDevice setFlashMode:] - the passed flashMode 0 is not supported by the device. Use -isFlashModeSupported: to discover valid flash modes.
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x20bc62eb __exceptionPreprocess
1 libobjc.A.dylib 0x20392dff objc_exception_throw
2 AVFoundation 0x261529d3 -[AVCaptureFigVideoDevice setFlashMode:]
3 DKCamera 0x9a03cc DKCamera.updateFlashMode() -> () (DKCamera.swift:427)
4 DKCamera 0x99ab30 DKCamera.flashMode.setter (DKCamera.swift:54)
5 DKCamera 0x99fdcc DKCamera.setupCurrentDevice() -> () (DKCamera.swift:396)
6 DKCamera 0x99e8dc @objc DKCamera.switchCamera() -> () (DKCamera.swift)
7 UIKit 0x24d95771 -[UIApplication sendAction:to:from:forEvent:]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.