Log in or register to post comments

Streaming from Tablet to PC

April 3, 2012 - 8:23am #1

Hey,

I want to stream the camera display (video + ar) to PC with .Net sockets, over local WiFi network.

To do that i plan to send screen captured images over the socket, at a fps (currently only one capture by second).

I'm developing a android app in a Samsung Tab 10.1, UNITY 3.5 and vuforia sdk 1.5.10.

My first approach was to capture screen with:

http://technology.blurst.com/unity-jpg-encoding-javascript/

It works but at full screen (1280x760) the performance is not good (screen capture freezes my app) and my app crashes.

I also tested Application.captureScreenshot() but it doesn't worked for me.

The second approach is to use the same script but take only a centered small part of screen :

"import System.IO;

// increment our filename
private var count:int = 0;
private var encoder:JPGEncoder;
private var texture:Texture2D;

private var textStyle:GUIStyle;
private var res:float;

/**
* Take the screen buffer and spit out a JPG
*/
function ScreenshotEncode()
{
Profiler.BeginSample("ScreenCapture");

// wait for graphics to render
yield WaitForEndOfFrame();

//var width = Screen.width;
//var height = Screen.height;

var width = 320;
var height = 240;

// create a texture to pass to encoding
texture = new Texture2D (width, height, TextureFormat.RGB24, false);

// put buffer into texture
texture.ReadPixels(centerRectangle(Rect(0.0, 0.0, width, width)), 0.0, 0.0);
//texture.Resize(256,256);
texture.Apply();

// split the process up--ReadPixels() and the GetPixels() call inside of the encoder are both pretty heavy
yield;

// create our encoder for this texture
encoder = new JPGEncoder(texture, 75.0);

// encoder is threaded; wait for it to finish
while(!encoder.isDone)
yield;

File.WriteAllBytes("/sdcard/screenShot" + count + ".jpg", encoder.GetBytes());

count++;

Profiler.EndSample();
}

function centerRectangle ( someRect : Rect ) : Rect
{
someRect.x = ( Screen.width - someRect.width ) / 2;
someRect.y = ( Screen.height - someRect.height ) / 2;

return someRect;
}"

It works but at slow rate (4 FPS) and only a small part of screen is captured, wich makes that solution not acceptable.

I have two markers and the 3d Model that is augmented has great detail and quality and the video + ar needs a lot of CPU processing.

It is possible to improve the performance of my app?

Can i have some gain of performance using "ConfigureVideoBackground" of class QCarbehaviour, setting a smaller resolution in the CameraDevice instance?

I tried Screen.SetResolution but it doesn't helped much.

Anyone knows a different way (other solution) to do this (streaming screen app capture from tablet to PC, without using usb debugging with ADB) ?

Can anyone help?

Thanks!

Streaming from Tablet to PC

August 14, 2012 - 12:35am #4

nsousa wrote:

Hey, I want to stream the camera display (video + ar) to PC with .Net sockets, over local WiFi network. To do that i plan to send screen captured images over the socket, at a fps (currently only one capture by second). I'm developing a android app in a Samsung Tab 10.1, UNITY 3.5 and vuforia sdk 1.5.10. My first approach was to capture screen with: http://technology.blurst.com/unity-jpg-encoding-javascript/ It works but at full screen (1280x760) the performance is not good (screen capture freezes my app) and my app crashes. I also tested Application.captureScreenshot() but it doesn't worked for me. The second approach is to use the same script but take only a centered small part of screen : "import System.IO; // increment our filename private var count:int = 0; private var encoder:JPGEncoder; private var texture:Texture2D; private var textStyle:GUIStyle; private var res:float; /** * Take the screen buffer and spit out a JPG */ function ScreenshotEncode() { Profiler.BeginSample("ScreenCapture"); // wait for graphics to render yield WaitForEndOfFrame(); //var width = Screen.width; //var height = Screen.height; var width = 320; var height = 240; // create a texture to pass to encoding texture = new Texture2D (width, height, TextureFormat.RGB24, false); // put buffer into texture texture.ReadPixels(centerRectangle(Rect(0.0, 0.0, width, width)), 0.0, 0.0); //texture.Resize(256,256); texture.Apply(); // split the process up--ReadPixels() and the GetPixels() call inside of the encoder are both pretty heavy yield; // create our encoder for this texture encoder = new JPGEncoder(texture, 75.0); // encoder is threaded; wait for it to finish while(!encoder.isDone) yield; File.WriteAllBytes("/sdcard/screenShot" + count + ".jpg", encoder.GetBytes()); count++; Profiler.EndSample(); } function centerRectangle ( someRect : Rect ) : Rect { someRect.x = ( Screen.width - someRect.width ) / 2; someRect.y = ( Screen.height - someRect.height ) / 2; return someRect; }" It works but at slow rate (4 FPS) and only a small part of screen is captured, wich makes that solution not acceptable. I have two markers and the 3d Model that is augmented has great detail and quality and the video + ar needs a lot of CPU processing. It is possible to improve the performance of my app? Can i have some gain of performance using "ConfigureVideoBackground" of class QCarbehaviour, setting a smaller resolution in the CameraDevice instance? I tried Screen.SetResolution but it doesn't helped much. Anyone knows a different way (other solution) to do this (streaming screen app capture from tablet to PC, without using usb debugging with ADB) ? Can anyone help? Thanks!

 

same query......Tablet pc

Re: Streaming from Tablet to PC

April 5, 2012 - 2:37am #3

It works.
I have tried it, but it wasn't on the OnGui method.
The performance problem is not solved and the screenshot image size is large (1.64 MB).

I don't really really want to take a screenshot.
I just want the camera raw texture (bytes) to send over socket.
Take the screenshot was a intermediate step for obtaining that.
The PC app will interpret the image byte data and show the image.

I think i will try:

http://ar.qualcomm.at/node/2001835

to try to solve the performance issue.

Thanks, for the reply.

Re: Streaming from Tablet to PC

April 3, 2012 - 7:49pm #2

Have you seen this thread.
http://ar.qualcomm.at/node/2001524

People have gotten CaptureScreenShot to work.

What are you seeing when you apply this method?

Log in or register to post comments