- Home /
What is the fastest way to capture from cam?
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!
Your answer
Follow this Question
Related Questions
I need to take (save) a screenshot from a camera other than the main one. How would I do this? 0 Answers
Capturing 360 Image causes to darken the image and show ghosting and artifacts 0 Answers
upload a screenshot directly to flickr (or any other photosharing website) 1 Answer
I need to take a screenshot from a FLASH BUILD 1 Answer
how to take a screenshot and save to image gallery on Android 1 Answer