Пример #1
0
        // Start is called before the first frame update
        void Start()
        {
            socket = new VirtualCVWebSocket();
            socket.Initialize();

            left       = this.gameObject.transform.GetChild(0).gameObject;
            leftCamera = left.GetComponent <Camera>();

            if (VirtualCVSettings.GetParam().useStereoCamera)
            {
                right       = this.gameObject.transform.GetChild(1).gameObject;
                rightCamera = right.GetComponent <Camera>();

                float ipd = VirtualCVSettings.GetParam().ipd;
                left.transform.localPosition.Set(0, -ipd / 2, 0);
                right.transform.localPosition.Set(0, ipd / 2, 0);
            }
            else
            {
                left.transform.localPosition.Set(0, 0, 0);
            }

            string pythonScript = VirtualCVSettings.GetParam().python_script;

            PythonExecutor.getInstance().ExecutePython(pythonScript);
        }
Пример #2
0
        void SetCamera()
        {
            cam = GetComponent <Camera>();

            cam.fieldOfView           = VirtualCVSettings.GetParam().fov;
            cam.usePhysicalProperties = VirtualCVSettings.GetParam().usePhysicalCamera;
            cam.focalLength           = VirtualCVSettings.GetParam().focal_length;

            VirtualCVLog.Log($"Camera info : {name} - {cam.fieldOfView} - {cam.usePhysicalProperties} - {cam.focalLength}");
        }
Пример #3
0
 void SetTexture()
 {
     // 640x480
     textureWidth  = VirtualCVSettings.GetParam().textureWidth;
     textureHeight = VirtualCVSettings.GetParam().textureHeight;
     if (textureWidth > 0 && textureHeight > 0)
     {
         cam.targetTexture.texelSize.Set(textureWidth, textureHeight);
         cameraImage = new Texture2D(textureWidth, textureHeight, TextureFormat.RGB24, false);
     }
 }
Пример #4
0
        /// <summary>
        /// Execute python script
        /// </summary>
        /// <param name="scriptFile">python script file name, default is opencv.py</param>
        public void ExecutePython(string pythonScriptFile)
        {
            VirtualCVLog.Log("Execute python script : " + pythonScriptFile);

            string useStereo = VirtualCVSettings.GetParam().useStereoCamera ? "stereo" : "";

            pythonProcess.StartInfo.FileName               = pythonExe;
            pythonProcess.StartInfo.WorkingDirectory       = pythonScriptPath;
            pythonProcess.StartInfo.Arguments              = $"{pythonScriptFile} {useStereo}";
            pythonProcess.StartInfo.UseShellExecute        = false;
            pythonProcess.StartInfo.RedirectStandardOutput = true;
            pythonProcess.StartInfo.CreateNoWindow         = true;

            pythonProcess.Start();
        }
Пример #5
0
        void Start()
        {
            VirtualCVLog.Log("VirtualCVCamera starts");

            bool useStereo = VirtualCVSettings.GetParam().useStereoCamera;

            isRightCamera = (name == "VirtualCVCameraRight");
            if (isRightCamera && !useStereo)
            {
                return;
            }

            SetCamera();
            SetTexture();

            screenshotPath = Path.Combine(Application.dataPath, "..", "Screenshot");
            Directory.CreateDirectory(screenshotPath);

            int port = isRightCamera ? rightCameraPort : leftCameraPort;

            ffmpegExecutor = new FFMPEGExecutor(port);
            ffmpegExecutor.Initialze();
            ffmpegExecutor.ExecuteFFMPEG();
        }