Пример #1
0
    //handler for http request, draws cameras
    void HandleCameraDownload(AsyncOperation op)
    {
        UnityWebRequestAsyncOperation aop = (UnityWebRequestAsyncOperation)op;

        try
        {
            string result = aop.webRequest.downloadHandler.text;

            if (result.Length == 0)
            {
                Debug.Log("Empty file");
            }
            else
            {
                Debug.Log("Cameras dowloaded");

                // WriteCaptureCamsToFile();

                List <CameraItem> reconstructionCams = new CameraItem().ParseCameras(result, photoCount);
                if (reconstructionCams != null)
                {
                    /* reconstructionCams = reconstructionCams.OrderBy(o => o.imageID).ToList();
                     *
                     * for (int i = 0; i < photoCount; i++)
                     * {
                     *
                     *   captureCameras[i].imageID = reconstructionCams[i].imageID;
                     * }*/

                    WriteCaptureCamsToFile();

                    ProcessReconstructionView p = new ProcessReconstructionView();
                    p.DrawReconstructionView(reconstructionCams, captureCameras, cameraTransform);



                    DownloadReconstruction();
                }
            }
        }
        catch (ArgumentException e)
        {
            Debug.Log("Something wrong with cameras");
            Debug.Log("Please restart");
        }
    }
Пример #2
0
    //handler for http request
    void HandleGetTransformation(AsyncOperation op)
    {
        Debug.Log("Downloading cameras");
        UnityWebRequestAsyncOperation aop = (UnityWebRequestAsyncOperation)op;

        try
        {
            if (aop.webRequest.downloadHandler.text.Length == 0)
            {
                Debug.Log("Something wrong with cameras and transform");
            }
            else
            {
                CalculatedTransform result = JsonUtility.FromJson <CalculatedTransform>(aop.webRequest.downloadHandler.text);
                result.initialize();
                //Debug.Log(aop.webRequest.downloadHandler.text);

                //DownloadCameras();

                WriteCaptureCamsToFile();
                Debug.Log("Transformation and cameras dowloaded");
                ProcessReconstructionView p = new ProcessReconstructionView();
                //p.DrawCameras(result.cameras, result.camrotation, result.rot, captureCameras);
                p.DrawTransformedColmapCams(result.XHx, result.XHy, result.XHz, result.cameras.Count / 3, result.cameras);

                Debug.Log("Cameras drawn");

                cameraTransform = result;

                DownloadModel();
            }
        }
        catch (ArgumentException e)
        {
            Debug.Log("Something wrong with cameras and transform");
            Debug.Log("Please restart");
        }
    }