public static List <MetaioCamera> getCameraList()
        {
            List <MetaioCamera> ret = new List <MetaioCamera>();

            uint   length = 0;
            IntPtr pbList = listCamerasInternal(out length);

            try
            {
                if (pbList == IntPtr.Zero || length == 0)
                {
                    Debug.LogError("listCamerasInternal failed");
                    return(ret);
                }

                byte[] pbAsBytes = new byte[length];
                Marshal.Copy(pbList, pbAsBytes, 0, (int)length);

                metaio.unitycommunication.ListCamerasProtocol pb = metaio.unitycommunication.ListCamerasProtocol.ParseFrom(pbAsBytes);

                for (int i = 0; i < pb.CamerasCount; ++i)
                {
                    ret.Add(MetaioCamera.FromPB((metaio.unitycommunication.Camera)pb.CamerasList[i]));
                }
            }
            finally
            {
                freeReturnedMemory(pbList);
            }

            return(ret);
        }
        public static Vector2di startCamera(MetaioCamera camera)
        {
            metaio.unitycommunication.StartCameraProtocol protocol = metaio.unitycommunication.StartCameraProtocol.CreateBuilder().SetCamera(camera.ToPB()).Build();

            using (MemoryStream stream = new MemoryStream())
            {
                protocol.WriteTo(stream);

                byte[]   buf         = stream.ToArray();
                GCHandle arrayHandle = GCHandle.Alloc(buf, GCHandleType.Pinned);
                try
                {
                    usingCamera     = true;
                    requestedCamera = camera.Clone();
                    Vector2di ret;
                    checked
                    {
                        IntPtr ptr = arrayHandle.AddrOfPinnedObject();
                        ret = parseUInt64ToVector2diUnsigned(startCameraInternal(ptr, (uint)buf.LongLength));
                    }
                    metaioCamera.updateCameraProjectionMatrix();
                    return(ret);
                }
                finally
                {
                    arrayHandle.Free();
                }
            }
        }
Exemple #3
0
 public static MetaioCamera FromPB(metaio.unitycommunication.Camera cam)
 {
     MetaioCamera ret = new MetaioCamera();
     ret.downsample = cam.Downsample;
     ret.facing = (int)cam.Facing;
     ret.flip = (uint)cam.Flip;
     ret.fps = new Vector2d(cam.Fps.X, cam.Fps.Y);
     ret.friendlyName = cam.FriendlyName;
     ret.index = cam.Index;
     ret.resolution = new Vector2di(cam.Resolution.X, cam.Resolution.Y);
     ret.yuvPipeline = cam.YuvPipeline;
     return ret;
 }
        public static MetaioCamera FromPB(metaio.unitycommunication.Camera cam)
        {
            MetaioCamera ret = new MetaioCamera();

            ret.downsample   = cam.Downsample;
            ret.facing       = (Facing)cam.Facing;
            ret.flip         = (uint)cam.Flip;
            ret.fps          = new Vector2d(cam.Fps.X, cam.Fps.Y);
            ret.friendlyName = cam.FriendlyName;
            ret.index        = cam.Index;
            ret.resolution   = new Vector2di(cam.Resolution.X, cam.Resolution.Y);
            ret.yuvPipeline  = cam.YuvPipeline;
            return(ret);
        }
Exemple #5
0
        public static Vector2di startCamera(MetaioCamera camera)
        {
            metaio.unitycommunication.StartCameraProtocol protocol = metaio.unitycommunication.StartCameraProtocol.CreateBuilder().SetCamera(camera.ToPB()).Build();

            using(MemoryStream stream = new MemoryStream())
            {
            protocol.WriteTo(stream);

            byte[] buf = stream.ToArray();
            GCHandle arrayHandle = GCHandle.Alloc(buf, GCHandleType.Pinned);
            try
            {
                Vector2di ret;
                checked
                {
                    IntPtr ptr = arrayHandle.AddrOfPinnedObject();
                    ret = parseUInt64ToVector2diUnsigned(startCameraInternal(ptr, (uint)buf.LongLength));
                }
                metaioCamera.updateCameraProjectionMatrix();
                return ret;
            }
            finally
            {
                arrayHandle.Free();
            }
            }
        }