Browse Source

RGBCamTexture

胡佳骏 1 year ago
parent
commit
46104766d8
1 changed files with 5 additions and 3 deletions
  1. 5 3
      Samples~/SDK/XRRGBCamera.cs

+ 5 - 3
Samples~/SDK/XRRGBCamera.cs

@@ -15,6 +15,7 @@ public class XRRGBCamera : SingletonMono<XRRGBCamera>
     public static XRRGBCamera Instance;
     public Texture CaptureImage;
     public WebCamTexture RGBCamTexture;
+    public bool isAuto = true;
     private void Awake()
     {
         Instance = this;
@@ -31,12 +32,13 @@ public class XRRGBCamera : SingletonMono<XRRGBCamera>
             cameraManager.frameReceived += OnCameraFrameReceived;
         }
         // 获取可用的摄像头设备
-        playCamera();
+        if(isAuto)
+        playCamera(1280,720);
     }
 
     public ARCameraManager cameraManager;
     private Material cameraBackgroundMaterial;
-    public void playCamera()
+    public void playCamera(int w, int h)
     {
         if (isARCamrea)
         {
@@ -57,7 +59,7 @@ public class XRRGBCamera : SingletonMono<XRRGBCamera>
             }
 
             // 使用第一个可用的摄像头设备(你可以根据需要选择其他设备)
-            RGBCamTexture = new WebCamTexture(devices[0].name, 1280, 720, 30);
+            RGBCamTexture = new WebCamTexture(devices[0].name, w, h, 30);
             Debug.Log("开启摄像头" + devices[0].name);
             // 开始摄像头捕捉
             RGBCamTexture.Play();