C++ to Java aplet, need help to understand.

S

Simon

Hi,

I have a c++ application that uses Direct X to get images from my webcam.
Now I want to stream images from my application to the internet.

I just want to make sure I understand how a java applet would, (should?),
work.

When the user load the page where the java applet is located, the applet
makes a request to my machine for an image.
The applet then displays the image at a certain location in the page.
So a java applet does not really 'stream' videos, instead it makes a request
for an image every 'x' seconds.

All the applet needs is address and port where my application is located,
(and the name of the function that will return the frame).

Sadly I have no knowledge of Java, (well a little maybe).
Where could I find some code for an applet that would make a request to my
application.
How can a java applet make a request to a win 32 c++ application?

And what would the code look like in an html page?

Many thanks in advance for any help/code.

Simon
 
A

Andrew Thompson

Simon said:
When the user load the page where the java applet is located,

Where is that? I ask because, ..
..the applet
makes a request to my machine for an image.

...you will need a server to serve the web pages
and applet. If you also use the server to serve
the images, the applet becomes quite trivial.

The question (with this approach) is.. Can you
upload the web-cam images to the server?
 
S

Simon

Where is that? I ask because, ..

Well, the way I understand it the page will have an applet section, that
section will do all the work, (where to get the image from, how to display
it and so on).
To work properly the applet will use a jar file that will be on the
server(?) the jar file would do the request to my machine.

Maybe I am wrong, I was just trying to understand how 'normal' webcams
connect to the web.
..you will need a server to serve the web pages
and applet. If you also use the server to serve
the images, the applet becomes quite trivial.

The question (with this approach) is.. Can you
upload the web-cam images to the server?

Yes, I can easily upload the images, (that might even be better).
How would I get the script to get the images every 'x' seconds and display
it?

Is it the way webcams stream to the web?

Thanks for your help.

Simon
 
C

Chris Smith

Simon said:
Yes, I can easily upload the images, (that might even be better).
How would I get the script to get the images every 'x' seconds and display
it?

Is it the way webcams stream to the web?

I think, most of the time, web-cams that stream over the web use some
kind of streaming video technology. Generally speaking, that technology
is licensed from some provider like Real.com (though hopefully, you
could find a less evil provider). Java is rarely involved.

If you wish to reinvent such a concept on your own, though, then writing
a Java (or JavaScript, or some other client-side technology) client
could be a good approach.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
R

Roedy Green

Many thanks in advance for any help/code.

I have written two webcam programs. One, NetworkCam uses repeatedly
downloaded JPGs. It is posted with source at
http://mindprod.com/products1.html

The other, websnap, hooks directly to a local webcam via JMF. The
problem with it is it supports only some webcams. It is hence not
WORA and I did not release it knowing the headaches of support would
be intolerable.

check out http://mindprod.com/jgloss/jmf.html

here are some imports you will likely need:

import javax.imageio.ImageIO;
import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.control.FormatControl;
import javax.media.control.FrameGrabbingControl;
import javax.media.control.FrameRateControl;
import javax.media.ControllerAdapter;
import javax.media.ControllerClosedEvent;
import javax.media.ControllerListener;
import javax.media.EndOfMediaEvent;
import javax.media.format.FormatChangeEvent;
import javax.media.format.JPEGFormat;
import javax.media.format.RGBFormat;
import javax.media.format.VideoFormat;
import javax.media.format.YUVFormat;
import javax.media.Format;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.MediaTimeSetEvent;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.PlugInManager;
import javax.media.PrefetchCompleteEvent;
import javax.media.RealizeCompleteEvent;
import javax.media.SizeChangeEvent;
import javax.media.StartEvent;
import javax.media.StopEvent;
import javax.media.TransitionEvent;
import javax.media.util.BufferToImage;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
 
R

Roedy Green

The question (with this approach) is.. Can you
upload the web-cam images to the server?

You have to run the server software on the machine with the webcam
hardware. You would use a server to point to the ip or DynDNS url of
the source. see http://mindprod.com/jgloss/dyndns.html

The idea of the Jpg stream is nothing goes out that is not requested
on a per-frame basis. IF the refresh rate is slow enough, this lets a
home machine act as server.
 
R

Roedy Green

I have written two webcam programs.

There is a third one I did on a contract basis. Oddly, the vendor
does not want inquiries about it from the general public and has asked
I not release their name. It was designed for multiple security
cameras in a many different locations. Not only could you view
various cameras live, you could back them up in time and look at past
history, with variable speed rewind/forward or by selecting a date and
time in the past, much like an electronic VCR.

The server maintained a database of the streams. It was designed to
render many frames a second in a continuous stream, without requesting
individual frames. At the client end, you could pan and zoom to see
detail or create thumbnails. I invented a packet protocol that sat
atop TCP/IP with a socket connection per stream and a thread to
baby-sit each socket.

Much of the work went into making it recover from various errors so
that non-computer people would not be expected to do anything
complicated to keep the system running.

The end user could program it to monitor a set of cameras,
automatically switching. It also had programmable radio buttons so
you could rapidly jump to a particular camera. You might be monitoring
hundreds of cameras, organized in a hierarchical tree..

Some cameras had hardware or software motion detect for intrusion
detection.

It remembered its state using the Preferences API so that if you shut
down and restarted it picked up where you last left it, with all the
windows open, in the same spots.

There were a ton of JButtons, each with enabled, disabled, selected,
pressed, and rollover forms. The idea behind it was to make the
program feel much like a VCR or similar home entertainment device.
We found our test subjects had no trouble at all remembering how to
work it after a short demo.

The most complicated thing was a way of creating presets I called
Constellations, that were organised in a tree. You could start from a
given constellation and modify it to create a new constellation, much
like Java classes and subclasses. You could call up the complete set
of options, cameras, button definitions etc by clicking one of the
constellations. Most people only selected a constellation, never
defined a new one.

I have often wished that the notion of constellations were something
universally available in all complex programs with many options to
allow me to define my own operating modes.
 
S

Simon


Thanks to all the replies.
I like the idea of uploading images every so often, mainly because it is
fairly easy and the traffic should be lower, (rather than each browser
making requests to the server).

But I am still not sure at the script I should use to update the image every
so often. :(

And I am still worried that it is not the preferred way of publishing
webcams on the web.
So...what is the "preferred" way of getting webcams on the web?

Simon
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top