c# - Unity WebcamTexture 高级设置(曝光、对焦、缩放)
问题描述
我的相机源在使用 WebcamTexture 的 Unity 中工作。根据https://docs.unity3d.com/ScriptReference/WebCamTexture.html,没有更改曝光或焦点设置的功能。
只是要清楚:
- 有什么办法可以改变 WebcamTexture 的曝光?
- 如果没有,有没有其他方法可以在不使用 WebcamTexture 的情况下调整曝光?
- 如果没有,我可以在 Unity 中使用哪些广泛使用的 API/工具来获取具有这些可调整设置的摄像头供稿?
解决方案
Is there any way to change the exposure of WebcamTexture?
No. You can on Android with AndroidJavaObject
but that's a hack and can stop working each time there is Unity update. Also, it will only work on Android but not on iOS, Windows, Mac and other platforms.
If not, is there any other way to adjust the exposure without using WebcamTexture?
Again, no. You can't modify the camera settings while using WebcamTexture
.
If not, what are some widely used API/tools that I can use in Unity for getting camera feed with these adjustable settings?
The only way to be able to modify the camera settings you mentioned is to create a camera API plugin for each platform. This is not easy to do since you have to know many programming languages to get it working such as Java for Android, Objective-C for iOS and Mac, C++ for Windows and Linux and Javascript for WebGL then use C# to put them together. It's really time-consuming to make this and therefore better to use an existing plugin.
The best one out there is the NatCam plugin. This plugin can control the exposure, focus and zoom of the camera but it's not free. It's worth it.
You can set the exposure and the exposure bias as:
DeviceCamera.RearCamera.ExposureMode = ExposureMode.Locked;
NatCam.Camera.ExposureBias = NatCam.Camera.MinExposureBias;
To set the Focus Mode:
NatCam.Camera.FocusMode = FocusMode.TapToFocus | FocusMode.AutoFocus;
To zoom the camera:
NatCam.Camera.ZoomRatio = 2.0f;
You can find the complete tutorial for NatCam here.
推荐阅读
- unity3d - 可以通过 AR 应用更新 Vuforia 数据库数据吗?
- php - 从 php 文件中包含两次变量
- ios - 如何在 React Native 中更改 iOS/Android 项目文件夹
- javascript - 获取同一类的多个下拉列表的选定索引
- univocity - 使用例程的 Univocity 解析器使用 defaultNullRead 属性忽略 LongCoversion?
- netty - 当对 netty 服务器发出请求时,不会调用 ChannelRead 方法
- android - 我如何知道何时需要在 RxJava 中处理一次性用品?
- python - 如何处理 CSV 文件中引号字符中的引号字符?
- database-connection - 无法使用 Netbeans 或 ij 连接 derby 数据库的备份
- prolog - Prolog中N个相关事件的析取概率