- Home /
How do I send a screenshot to another application?
Hi, I want to pass the screen of my unity program to another application.
This other application uses OpenCV, so I thought I can create a separate camera device, stream to this device via unity and then capture the image from this camera with OpenCV.
I know how to open a camera loopback device and get the input from the camera to OpenCV. My problem is, getting the image from Unity to the device.
My code at this moment basically looks like this:
Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);
// Read screen contents into the texture
tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
tex.Apply();
// Encode texture into PNG
byte[] bytes = tex.EncodeToPNG();
// This is the camera device I want to write to
String fileName = "/dev/video1";
File.WriteAllBytes(fileName, bytes);
This is not working as it throws an IO exception at the writing to the device.
P.S.: I'm working under Archlinux
Your answer
Follow this Question
Related Questions
Use OpenCV with in-game camera to detect road lanes 0 Answers
I need to take (save) a screenshot from a camera other than the main one. How would I do this? 0 Answers
Cant find where the screenshots are saved or if they are even taken 1 Answer
Saving Texture at Run time and Reusing it 0 Answers
Rendering screenshot using multiple cameras and one rendertexture 0 Answers