Quantcast
Channel: Latest Questions by Lunaria
Viewing all articles
Browse latest Browse all 24

What is the fastest way to capture from cam?

$
0
0
Hello, developers! My project is to connect Oculus and webcam by Unity and Arduino. When Oculus moves, webcam which is connected with Arduino/Servo motor moves synchronously and each specific frames, the image which webcam shows is saved in my local folder. The problem begins here. I used the way to capture as Texture2D to png void TakeSnapshot(WebCamTexture tex) { Texture2D snap = new Texture2D(tex.width, tex.height, TextureFormat.RGB565, false); snap.SetPixels(tex.GetPixels()); snap.Apply(); bool isMoved = OVRCameraRig.isMoved; System.IO.File.WriteAllBytes(_SavePath + "Image" + ".png", snap.EncodeToPNG()); byte[] bmpz = snap.EncodeToPNG (); System.IO.MemoryStream ms = new System.IO.MemoryStream (bmpz); ms.Seek (0, System.IO.SeekOrigin.Begin); Image _bmp = Bitmap.FromStream (ms); _bmp.Save (_SavePath + "Image.bmp", ImageFormat.Bmp); ms.Close (); ++_CaptureCounter; } Unity checks Oculus' position by every frame. But, when screenshot captured, it takes some frames(about 3~4 frames?). And during absent frames, Unity doesn't know about those frames, so motor moves dramatically. I think the way to capture screenshot take too much time. So I searched about faster way, but there isn't. Is there faster way? (about less than 2frames?) Or should I change my workspace laptop to desktop? Thanks for reading!

Viewing all articles
Browse latest Browse all 24

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>