📷
iOS Camera Simulator
iCimulator允许我们在iOS模拟器上使用相机功能!
2019年10月23日:添加了新的模式“Mac相机模式”!
→点击此处获取详细信息!
支持AVFoundation 和 UIImagePickerController!
🎈
安装CocoaPods
您可以使用CocoaPods安装iCimulator
,方法是在您的Podfile
中添加它
pod 'iCimulator'
Carthage
创建一个包含框架的Cartfile
并运行carthage update
。按照说明将$(SRCROOT)/Carthage/Build/iOS/iCimulator.framework
添加到iOS项目中。
github "YuigaWada/iCimulator"
手动
- 下载并将
iCimulator
添加到您的项目中。 - 恭喜!
🍏 - 图片或视频 -
用法只需5步!
- 准备演示数据。(图片/视频)
- 安装
iCimulator
。 - 将
iCimulator.swift
和iCimulator.plist
复制到您的项目。 - 设置
iCimulator.plist
,其中描述了使用什么样的模拟数据。 - 将
iCimulator.swift
和iCimulator.plist
链接到您的项目。
您可以从 template
文件夹中复制 iCimulator.swift
和 iCimulator.plist
。
**所有使用相机功能的项目都必须完成这5步。**
iCimulator.plist
键 | 值 | 备注 |
---|---|---|
类型 | 图片 | 可以设置图片作为模拟 |
视频 | 可以设置视频作为模拟 | |
Mac-Camera | 点击这里获取详细信息! | |
参数 | ... | 在这里写下您模拟数据的路径 |
iCimulator.swift
//
// ** iCimulator.swift **
//
// MIT License
//
// Copyright (c) 2019 YuigaWada
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
#if targetEnvironment(simulator)
import iCimulator
//AVFoundation
public typealias AVCaptureDevice = FakeCaptureDevice
public typealias AVCaptureSession = FakeCaptureSession
public typealias AVCaptureVideoPreviewLayer = FakePreviewLayer
public typealias AVCapturePhotoOutput = FakeCapturePhotoOutput
public typealias AVCapturePhotoCaptureDelegate = FakeCapturePhotoCaptureDelegate
public typealias AVCapturePhoto = FakeCapturePhoto
public typealias AVCaptureDeviceInput = FakeCaptureDeviceInput
public typealias AVCaptureMovieFileOutput = FakeCaptureMovieFileOutput
public typealias AVCaptureFileOutput = FakeCaptureFileOutput
public typealias AVCaptureFileOutputRecordingDelegate = FakeCaptureFileOutputRecordingDelegate
public typealias AVCaptureConnection = FakeCaptureConnection
public typealias AVCapturePhotoSettings = FakeCapturePhotoSettings
public typealias AVCaptureResolvedPhotoSettings = FakeCaptureResolvedPhotoSettings
//For supporting iOS 10.
public typealias AVCaptureStillImageOutput = FakeCaptureStillImageOutput
public typealias CMSampleBuffer = FakeCMSampleBuffer
//UIImagePickerController
public typealias UIImagePickerController = FakeImagePickerController
public typealias UIImagePickerControllerDelegate = FakeImagePickerControllerDelegate
#endif
🍎 - Mac 相机 -
用法您可以使用MacBook的相机来模拟相机功能!!
首先,您需要在MacBook上启动一个相机服务器。
打开 streaming_server
并启动 streaming_server/server.py
!
检查您的 iCimulator.plist
后,您可以在iOS模拟器中看到您的MacBook相机。
依赖项
- Python 3.7.3
- Numpy
- opencv-python
选项
您可以使用这些选项来使用 streaming_server/server.py
.
___________________________________________________________________________
██╗ ██████╗██╗███╗ ███╗██╗ ██╗██╗ █████╗ ████████╗ ██████╗ ██████╗
██║██╔════╝██║████╗ ████║██║ ██║██║ ██╔══██╗╚══██╔══╝██╔═══██╗██╔══██╗
██║██║ ██║██╔████╔██║██║ ██║██║ ███████║ ██║ ██║ ██║██████╔╝
██║██║ ██║██║╚██╔╝██║██║ ██║██║ ██╔══██║ ██║ ██║ ██║██╔══██╗
██║╚██████╗██║██║ ╚═╝ ██║╚██████╔╝███████╗██║ ██║ ██║ ╚██████╔╝██║ ██║
╚═╝ ╚═════╝╚═╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
by Yuiga Wada.
___________________________________________________________________________
-v / -verbose / --verbose : turn on Verbose Mode.
-h / -help / --help : show help.
-c / -camera / --camera : enable you to show the captured frame on another window.
示例
CameraKit
Fusuma
📒
待办- typealias对象的Class →相互可交换
- 准备Carthage
- 准备CocoaPods
- 创建日语版README
贡献
感谢您对 iCimulator 的贡献,有关更多信息,请查看 LICENSE
文件。
其他
Yuiga Wada - 网站 Twitter - @YuigaWada
在 MIT 许可下分发。更多详细信息请参阅 LICENSE
。