C# 从iPhone摄像头渲染的模糊图像
我正在Unity中为iPhone开发一款基于照片的游戏,在访问设备摄像头时遇到了分辨率问题。渲染为纹理的实时图像明显是像素化的,而拍摄并保存到照片库中的照片也同样是像素化的。看起来渲染到纹理的图像的分辨率比相机/屏幕的本机分辨率低,但我不确定这是为什么。我如何解决这个问题?谢谢大家!C# 从iPhone摄像头渲染的模糊图像,c#,ios,unity3d,textures,screen-resolution,C#,Ios,Unity3d,Textures,Screen Resolution,我正在Unity中为iPhone开发一款基于照片的游戏,在访问设备摄像头时遇到了分辨率问题。渲染为纹理的实时图像明显是像素化的,而拍摄并保存到照片库中的照片也同样是像素化的。看起来渲染到纹理的图像的分辨率比相机/屏幕的本机分辨率低,但我不确定这是为什么。我如何解决这个问题?谢谢大家! using UnityEngine; using UnityEngine.UI; public class PhoneCamera : MonoBehaviour { private bool camAv
using UnityEngine;
using UnityEngine.UI;
public class PhoneCamera : MonoBehaviour
{
private bool camAvailable;
private Texture defaultBackground;
public static WebCamTexture backCam { get; set; }
public RawImage background;
public AspectRatioFitter fit;
private void Start ()
{
defaultBackground = background.texture;
WebCamDevice [] devices = WebCamTexture.devices;
if (devices.Length == 0) {
Debug.Log ("No camera detected");
camAvailable = false;
return;
}
for (int i = 0; i < devices.Length; i++) {
if (!devices [i].isFrontFacing) {
backCam = new WebCamTexture (devices [i].name, Screen.width, Screen.height);
}
}
if (backCam == null) {
Debug.Log ("Unable to find back camera");
return;
}
backCam.Play ();
background.texture = backCam;
camAvailable = true;
}
private void Update ()
{
if (!camAvailable)
return;
float ratio = (float)backCam.width / (float)backCam.height;
fit.aspectRatio = ratio;
float scaleY = backCam.videoVerticallyMirrored ? -1f : 1f;
background.rectTransform.localScale = new Vector3 (1f, scaleY, 1f);
int orient = -backCam.videoRotationAngle;
background.rectTransform.localEulerAngles = new Vector3 (0, 0, orient);
}
}
使用UnityEngine;
使用UnityEngine.UI;
公共类电话摄像机:单一行为
{
私人布尔卡姆酒店;
私人背景;
公共静态WebCamTexture backCam{get;set;}
公众形象背景;
公共方面比较合适;
私有void开始()
{
defaultBackground=background.texture;
WebCamDevice[]设备=WebCamTexture.devices;
如果(devices.Length==0){
Debug.Log(“未检测到摄像头”);
camavable=false;
返回;
}
对于(int i=0;i
屏幕的宽度和高度是多少?根据论坛帖子中的Unity开发者的说法,Unity选择了一个最接近你传递的分辨率的捕获分辨率。啊,我明白了,我把纹理分辨率设置为屏幕分辨率,但我应该把它设置为相机分辨率。现在质地更脆了。