Loading a jpeg really fast

E

E. Naubauer

Richard said:
There's also a java program to display images from Axis
cameras on sourceforge,

Richard

Would you mind sending me the url (if you have it) ?
Maybe I can learn a few things from it. tx
 
E

E. Naubauer

Ok, it still doesn't work really good.
I pasted the essential parts of the code into a small demo, added a
frame to it for display and it runs just as bad as the complete thing.
The delay between movement and drawing ia about five seconds, getting
worse with the time. If you have the time to check it out for a sec and
find something problematic, please let me know. Otherwise I will have to
port the whole thing to C. Thanks in any case.


import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.InputStream;
import java.net.*;
import java.awt.*;
import java.awt.image.*;

import javax.imageio.ImageIO;
public class Test
{

private static HttpURLConnection hurlconnection = null;
private static DataInputStream datainstream = null;
private static String serialNumber = null;
private static boolean connected = false;
private static BufferedImage image = null;

public static void main(String[] args) throws Exception
{

URL streamurl = new
URL("http://192.168.1.51/axis-cgi/mjpg/video.cgi?resolution=352x288&compression=100&showlength=1&fps=10");
hurlconnection = (HttpURLConnection)streamurl.openConnection();
hurlconnection.setReadTimeout(10000);
InputStream instream = hurlconnection.getInputStream();

connected = true;
BufferedInputStream bis = new BufferedInputStream(instream);
datainstream = new DataInputStream(bis);

Frame frm = new Frame();
frm.setSize(200,200);
frm.setVisible(true);

//decodiere stream
if(connected)
{
Image i;
while(!Thread.currentThread().isInterrupted())
{
image = null;
i = null;

String header;
int k = 0;

while(image == null)
{

k = 0;
do
{
header = datainstream.readLine();
}
while(++k < 3);

datainstream.readByte();
int j = (new Integer(header.substring("Content-Length:
".length()))).intValue();
datainstream.readByte();
byte abyte1[] = new byte[j + 2];
datainstream.readFully(abyte1, 0, j + 2);
datainstream.readLine();

ByteArrayInputStream bin = new ByteArrayInputStream (abyte1);
image = ImageIO.read ( bin );

} //end while image==null

long before = System.currentTimeMillis();
Graphics2D g2 = (Graphics2D)frm.getGraphics();
frm.getGraphics().drawImage(image,0,0,null);
long after = System.currentTimeMillis();
System.out.println("Duration: " +(after-before));

//Thread.currentThread().sleep(100);
}
}
}
}
 
S

slippymississippi

Let me get this straight. Unless you can download two images
simultaneously in under 200ms, you will not receive your degree. WTH
kind of college are you going to?

:)
 
R

Richard Wheeldon

E. Naubauer said:
Would you mind sending me the url (if you have it) ?
Maybe I can learn a few things from it. tx

Sorry. If I had it, I'd have posted it. Try a search
for axis on sf.net,

Richard
 
Joined
Oct 30, 2008
Messages
1
Reaction score
0
Hi !

Just wanted to know what approach you used in the end, I'm working on the Axis java applet currently and would appreciate any feedback and ideas you have.

Best regards Carl-Emil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top