项目作者: YuigaWada

项目描述 :
Simulate camera functions on iOS Simulator with images, videos, or your MacBook Camera.
高级语言: Swift
项目地址: git://github.com/YuigaWada/iCimulator.git
创建时间: 2019-10-19T21:58:48Z
项目社区:https://github.com/YuigaWada/iCimulator

开源协议:MIT License

下载


License
Swift Version
CocoaPods Compatible
Carthage compatible


iOS Camera Simulator 📷

iCimulator allows us to use camera functions on iOS Simulator!

2019-Oct-23: A new mode ‘Mac Camera Mode’ is added!

→Click here for details!


Support for AVFoundation & UIImagePickerController !

Installation 🎈

CocoaPods

You can use CocoaPods to install iCimulator by adding it to your Podfile:

  1. pod 'iCimulator'

Carthage

Create a Cartfile that lists the framework and run carthage update. Follow the instructions to add $(SRCROOT)/Carthage/Build/iOS/iCimulator.framework to an iOS project.

  1. github "YuigaWada/iCimulator"

Manually

  1. Download and drop iCimulator in your project.
  2. Congratulations!



Usage🍏 - Image or Video -

Just 5 steps!

  1. Prepare your mock data. (image/video)
  2. Install iCimulator.
  3. Copy iCimulator.swift and iCimulator.plist to your project.
  4. Set up iCimulator.plist , which is described what kind of mock data is used.
  5. Link iCimulator.swift and iCimulator.plist to your project.

You can copy iCimulator.swift and iCimulator.plist from template folder.






**This 5-Steps MUST BE DONE on all projects which use camera functions.**



iCimulator.plist

Key Value Notes
Type Image You can set an image as a mock
Video You can set a video as a mock
Mac-Camera Click here for details!
Argument Write here path of your mock data




iCimulator.swift

  1. //
  2. // ** iCimulator.swift **
  3. //
  4. // MIT License
  5. //
  6. // Copyright (c) 2019 YuigaWada
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining a copy
  9. // of this software and associated documentation files (the "Software"), to deal
  10. // in the Software without restriction, including without limitation the rights
  11. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. // copies of the Software, and to permit persons to whom the Software is
  13. // furnished to do so, subject to the following conditions:
  14. //
  15. // The above copyright notice and this permission notice shall be included in all
  16. // copies or substantial portions of the Software.
  17. //
  18. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. // SOFTWARE.
  25. //
  26. #if targetEnvironment(simulator)
  27. import iCimulator
  28. //AVFoundation
  29. public typealias AVCaptureDevice = FakeCaptureDevice
  30. public typealias AVCaptureSession = FakeCaptureSession
  31. public typealias AVCaptureVideoPreviewLayer = FakePreviewLayer
  32. public typealias AVCapturePhotoOutput = FakeCapturePhotoOutput
  33. public typealias AVCapturePhotoCaptureDelegate = FakeCapturePhotoCaptureDelegate
  34. public typealias AVCapturePhoto = FakeCapturePhoto
  35. public typealias AVCaptureDeviceInput = FakeCaptureDeviceInput
  36. public typealias AVCaptureMovieFileOutput = FakeCaptureMovieFileOutput
  37. public typealias AVCaptureFileOutput = FakeCaptureFileOutput
  38. public typealias AVCaptureFileOutputRecordingDelegate = FakeCaptureFileOutputRecordingDelegate
  39. public typealias AVCaptureConnection = FakeCaptureConnection
  40. public typealias AVCapturePhotoSettings = FakeCapturePhotoSettings
  41. public typealias AVCaptureResolvedPhotoSettings = FakeCaptureResolvedPhotoSettings
  42. //For supporting iOS 10.
  43. public typealias AVCaptureStillImageOutput = FakeCaptureStillImageOutput
  44. public typealias CMSampleBuffer = FakeCMSampleBuffer
  45. //UIImagePickerController
  46. public typealias UIImagePickerController = FakeImagePickerController
  47. public typealias UIImagePickerControllerDelegate = FakeImagePickerControllerDelegate
  48. #endif



Usage🍎 - Mac Camera -

You can use your macbook camera to simulate camera functions!!

First, you need to launch a camera-server on your MacBook.

Open streaming_server and launch streaming_server/server.py!


After checking your iCimulator.plist, you can see that your MacBook Camera is displayed on iOS Simulator 😊

Dependencies

  • Python 3.7.3
  • Numpy
  • opencv-python
  • Pillow
  • Pandas

Options

You can use these options in using streaming_server/server.py.

  1. ___________________________________________________________________________
  2. ██╗ ██████╗██╗███╗ ███╗██╗ ██╗██╗ █████╗ ████████╗ ██████╗ ██████╗
  3. ██║██╔════╝██║████╗ ████║██║ ██║██║ ██╔══██╗╚══██╔══╝██╔═══██╗██╔══██╗
  4. ██║██║ ██║██╔████╔██║██║ ██║██║ ███████║ ██║ ██║ ██║██████╔╝
  5. ██║██║ ██║██║╚██╔╝██║██║ ██║██║ ██╔══██║ ██║ ██║ ██║██╔══██╗
  6. ██║╚██████╗██║██║ ╚═╝ ██║╚██████╔╝███████╗██║ ██║ ██║ ╚██████╔╝██║ ██║
  7. ╚═╝ ╚═════╝╚═╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
  8. by Yuiga Wada.
  9. ___________________________________________________________________________
  10. -v / -verbose / --verbose : turn on Verbose Mode.
  11. -h / -help / --help : show help.
  12. -c / -camera / --camera : enable you to show the captured frame on another window.
  13. `



Demo

CameraKit



Fusuma



Todo📒

  • typealias対象のClass →互いに可換化
  • Carthageの準備
  • CocoaPodsの準備
  • 日本語版READMEの作成

Contribute

We would love you for the contribution to iCimulator, check the LICENSE file for more info.

Others

Yuiga Wada - WebSite
Twitter - @YuigaWada

Distributed under the MIT license. See LICENSE for more information.

https://github.com/YuigaWada/iCimulator