Esempio n. 1
0
    public void SendImageCallFromScript()
    {
        if (nettyinited)
        {
            if (is_waiting)
            {
                txt.text = "Waiting for result";
                return;
            }
            //SetTextureFromUnity(Frame.CameraImage.Texture.GetNativeTexturePtr());
            // "using" will automaticly release the memory of the object
            using (GoogleARCore.CameraImageBytes image = Frame.CameraImage.AcquireCameraImageBytes())
            {
                if (!image.IsAvailable)
                {
                    txt.text = "Image Not available.";
                    return;
                }

                // Move raw data into managed buffer.
                int    bufferSize    = image.YRowStride * image.Height;
                byte[] s_ImageBuffer = new byte[bufferSize];

                // Move raw data into managed buffer.
                System.Runtime.InteropServices.Marshal.Copy(image.Y, s_ImageBuffer, 0, bufferSize);
                initCameraPose.RecordCureentPoseWhenSentImage();

                AR_SendImageNetty(s_ImageBuffer, bufferSize);
                txt.text   = "Sent image " + bufferSize;
                is_waiting = true;
            }
        }
    }
Esempio n. 2
0
    public void SendImage()
    {
        counter = counter + 1;
        if (manager_inited && counter % interval == 0)
        {
            counter = 0;

            //SetTextureFromUnity(Frame.CameraImage.Texture.GetNativeTexturePtr());
            // "using" will automaticly release the memory of the object
            using (GoogleARCore.CameraImageBytes image = Frame.CameraImage.AcquireCameraImageBytes())
            {
                if (!image.IsAvailable)
                {
                    debug_txt.text = "Image Not available.";
                    return;
                }

                // Move raw data into managed buffer.
                int    bufferSize    = image.YRowStride * image.Height;
                byte[] s_ImageBuffer = new byte[bufferSize];

                // Move raw data into managed buffer.
                System.Runtime.InteropServices.Marshal.Copy(image.Y, s_ImageBuffer, 0, bufferSize);

                Quaternion q_camera = ArCoreFirstViewCamera.transform.localRotation;
                Vector3    p_camera = ArCoreFirstViewCamera.transform.localPosition;

                save_key = save_key + 1;
                SaveData_SavePose(p_camera.x, p_camera.y, p_camera.z, q_camera.w, q_camera.x, q_camera.y, q_camera.z, true, save_key);
                SaveData_SaveImage(s_ImageBuffer, bufferSize, save_key);
                SavePointCloud(save_key);
                debug_txt.text = "Saved image " + save_key;
            }
        }
    }
Esempio n. 3
0
    public void SendImage()
    {
        if (nettyinited)
        {
            //SetTextureFromUnity(Frame.CameraImage.Texture.GetNativeTexturePtr());
            // "using" will automaticly release the memory of the object
            using (GoogleARCore.CameraImageBytes image = Frame.CameraImage.AcquireCameraImageBytes())
            {
                if (!image.IsAvailable)
                {
                    txt.text = "Image Not available.";
                    return;
                }

                // Move raw data into managed buffer.
                int    bufferSize    = image.YRowStride * image.Height;
                byte[] s_ImageBuffer = new byte[bufferSize];

                // Move raw data into managed buffer.
                System.Runtime.InteropServices.Marshal.Copy(image.Y, s_ImageBuffer, 0, bufferSize);
                initCameraPose.RecordCureentPoseWhenSentImage();

                AR_SendImageNetty(s_ImageBuffer, bufferSize);
                txt.text = "Sent image " + bufferSize;
            }
        }
        else
        {
            SetTextureFromUnity(Frame.CameraImage.Texture.GetNativeTexturePtr());
            txt.text = "Init Netty " + ip[0] + "." + ip[1] + "." + ip[2] + "." + ip[3] + ":" + ip[4];
            AR_InitNetty();
            AR_SetNettyParameters(ip[0], ip[1], ip[2], ip[3], ip[4], focus, map_id, device_type);
            txt.text    = "Init Done";
            nettyinited = true;
        }
    }