Java screen streaming - java

I'm trying to stream a part of my Screen to another Computer using Java. I've already tried to use a robot to make Screenshots in an interval controlled by a timer, which worked well. But the Streaming doesn't work well with ImageIO and an Image Stream. There's just a too low Framerate. I've already searched around, but all I could find where similar problems.
My Questions are:
Is there a library to compress the images created from the robot?
Has anyone done something like this before?
Am I doing this completely wrong and there is a better way?

You are trying todo what VNC does. See
https://de.wikipedia.org/wiki/Virtual_Network_Computing you may look into a VNC implementation for actual code. The compression is not that easy. Since it needs to be fast (relatime) and offer a good compression ratio over slow networks.

Related

Java - Image Processing Package

I'm trying to make a maths inspired background image for my computer. What I've decided to do is a visualization of the Collatz Conjecture (video for explanation of the mathematical problem and method of visualization: https://www.youtube.com/watch?v=LqKpkdRRLZw&t=224s). Now I know that there are tons of different cool high resolution images on this very topic but half of the fun in it is making it myself.
So on to the problem. The tree structure is already implemented and took a couple of hours (I'm not a great Java programmer) so what I want to do now is create the actual image. I'm in essence looking for a simple image processing package or even some image processing software that can read information from a .txt file and will let me tell it what to do with it. I want to be able to draw lines, assign widths and colors and chose background colors etc. I had thoughts of doing the entire thing in Matlab instead so if you recommend I do it there I can do that as well. Also python is an option. But to clarify the problem isn't the actual making of the tree but rather the visualization and making a pretty image. Thanks for any help.
EDIT: I just found this (http://marvinproject.sourceforge.net/en/index.html). It seems to do what I want. Is it any good?

Screensharing via Java Applet

I am looking for an addition for our "livestream and podcast" solution, which uses a camera to film speeches in our house.
It has been requested to view the slides of our speakers directly as a image in the webbrowser instead of the video stream. We don't want/can not install software on the speakers laptop, so I thought about a Java applet, which the speaker can just run via a webbrowser.
So what I need is technically this:
[speakers laptop] -> [Screencapture every N seconds via applet on a webpage] -> [Displaying the screen of the speaker on a different webpage for the external viewers]
I know there are Java applications which do record the screen, but save the file output locally. I need something that does the same, but sends the image to the server. On the server side I thought about a websocket.js accepting and displaying the image (other suggestions are welcome).
It would be great if somebody could help me out here. Btw, I never programmed in Java, so telling me which frameworks I need won't really help me.
Thanks!!
I was recently asked to evaluate possibilities for live screen-cast via applet. Most video APIs do not support codecs that have high enough compression (e.g. JMF). Some APIs can do advanced formats (JFFMPEG, Xuggle) but also use natives. While natives are normally no problem for an app. launched (free floating) using Java Web Start or a Plug-In 2 applet, the makers of Xuggle identify 'the order of loading natives' as a problem (e.g. won't work) for both JWS and applets.
It is a pity that more than a decade into its development, Java has no reasonable API for video capture/processing that can be deployed for a wide use (applet/JWS based - for the 'general public') GUI.
Perhaps you can find a solution using Flash.
Update 1
In fact, I do not need the screen to be recorded as a video.
In fact, you mentioned much of that in your initial question, but I focused on just a few keywords before drafting a reply. My bad. :P
OK.
Getting an image is relatively easy. An applet would need to be trusted in order to get a screenshot, but once trusted, it is just a few lines of code to get the image.
Encoding the image to JPEG of particular quality/compression setting (in memory) is also doable.
Sending the image to the server would depend on the size in bytes and connection speed, but one image with a high compression, every 10 seconds, should be doable. The server would need to implement functionality to accept the image.
As far as displaying the image on the client, it seems you already have some ideas based around JS. If you can make that work that would be optimal, since it can then be viewed in browsers with no Java.
I would still recommend you deploy the app. to the 'speaker' using Java Web Start, rather than embed an applet. A JWS app. will give you less deployment & maintenance troubles, and the JWS launch is ..nicer. Further, a free floating frame launched using JWS can minimize itself (or in later JREs, become transparent), during the action of taking a screen image - thereby capturing everything on the screen except itself.
Update 2
I actually found this code here.
That is ..horrible. Not the code, the site. When I visited it I got a message saying a pop-up had been suppressed (fair enough). Then there was the irritating 'vibrating dialog' hovering in the middle of the page (and following the scroll). You click the little x to see - another tab opened with yet another floating dialog, saying some other rubbish about how "You've won.." - with sound loud enough to drown out my high volume trance/dance playlist.
Then after closing that the hell out of my FF, I go back to the original page, close the damn 'dialog', scroll down & see.. a red background to the code (shudder). That is as far as I could manage. I closed the page with the code.
Try this code instead, for a single screen-shot.
Would it be possible to use this on the client side..
Yes.
.. and receive it with javascript on the server side?
Not really. Unless you mean an IIS based server running Microsoft's JScript. JavaScript is a client side technology.
For security reasons, servers need to protect themselves. E.G. From:
Someone creating a slavebot that uploads all the 1000s of docs on the slave machine's to the site - to make it crash.
People high-jacking your server for storing and serving bestiality porn (or worse).
Because of things like that (bad people have lots of imagination), while servers can easily accept uploads, they are generally not configured by default to allow them.
.. (I don't want Java on my server ;-)
It can be done using PHP, ASP, CGI etc. It does not need Java specifically, but it does need some active involvement from the server, if only to check the size of what is being uploaded and abort if it gets too large!
..Will take a look at the link you posted, but as I said, I can't program in Java, though I can understand some of it. Thanks!
It sounds like you'll need some help getting the server-side of it ready, as well. It is trivial for someone that knows how (not me), but a potential security nightmare for the inexperienced.
Update 3
where do I add the function to send the picture?
Sorry. I've not tried to implement that - you'd want to want to encode it to JPEG before sending, to reduce the size. See this code for how to provide an adjustable compression/quality where the user can see the effect.
There are various ways to get an image to a server. E.G. sockets, HTTP, FTP.. AFAIU it would depend on how the server is accepting it. I am unfamiliar with the specific term 'websocket' or the node.js script. Can you link to what you mean?
..the old code added to pastebin, so it's readable
Smart thinking. I notice it uses sockets, it was in the back of my mind that sockets would be best for this, since they have low overhead and short wait times.

Java Remote desktop administration

I m currently working on my project of remote desktop administration. I m using robot class to capture images and send over network. It works well but bit slower.
Because all the time we need to captuure and send image its too costly. Is it possible to detect only a portion of screen which is changed and send only that portion?
Please any one guide me on this. Thank you!!!
The keyword you're looking for (in order to be able to look this up and figure the solution yourself) is dirty rectangles.
You can look into some code here.
I looked into this awhile back, and the image capture is implemented particularly inefficiently. I don't recall the specific detail, but it was pretty bad the way they did it. I felt, at the time, that the only way to do it better would be to implement it in JNI. Which you could use JNA to shortcut.
I don't know if any platform's screen capture routines will allow only changed sections to be sent, but you could implement a decent image diff; although that could get expensive too. You would really need to measure whats going on to see if it works for you.

Java robot and image comparison

I'm toying with an idea for creating a Java application to automate a process that I have to do regularly and before I start any coding I thought I would seek advice as to the best way to approach it.
Basically, the application I use has a large number of images present on the screen at any one time, and what I would like to know is if there is a way to have Java identify if any of these two images are the same. If they are, I would like to automate mouse movement and button clicks.
After a bit of reading, I'm thinking that the PixelGrabber and Robot classes might be the right way to start, but like I said, I'm looking for any information on this that can be offered.
What are your suggestions?
I believe the Robot class and a Pixel Grabber would be sufficient. If you are inclined to program the solution yourself, maybe for educational purpose, by all means please do. If you, however, don't want to reinvent the wheel, you may take a look at this project:
http://sikuli.org/
I, for example, use it to do stuff that would be hard to achieve with Selenium alone. If you still can't achieve your goal after some scripting, Sikuli provides a nice API which you can use from inside your java program.
The Robot class would be sufficient to take images and being able to inspect pixels. But it seems to make more sense, to recreate your desktop with images inside of a java application (a very simple gallery application). Then operations are simplier. An other way of realizing operations I do not see.

java image loading with effects

I wanted to load java images with some effects like we have in power point like blinds or appear in Java swing when user clicks on the image.
I have these specific questions in mind:
1.Is there a way to do this in Java?
2.Also how will this behave when the image to load is huge like 25 Mega Pixel?
3.If we are dealing with large images being switched, what mechanism should be used for incorporating images in the application?
Thanks,
Sandeep
1.Is there a way to do this in Java?
Yes, but it won't be with a single command or anything like that. Unless you find a library for this, you'll have to code it up manually.
To do animations like these I suggest you have a look at SwingWorkers.
2.Also how will this behave when the image to load is huge like 25 Mega Pixel?
25 mega pixel is quite large. It depends on your computer of course but if you code it reasonable well it should work fine.
3.If we are dealing with large images being switched, what mechanism should be used for incorporating images in the application?
Unless you really want the program to zoom into the details of the image, I suggest you shrink them immediately after loading, so your drawing-routines can work with them efficiently.
You can experiment with your target images using ImageJ. I routinely use it to manipulate images having scores of megapixels containing 8-, 16- and 32-bit data.

Categories

Resources