I am working on creating a simple HTTP server as part of a Java server. One component of this Java server is to capture images live from a webcam. Currently I am writing the images out to disk, and serving them through Apache.
What I want to do in the end though is write the JPEG to memory in a List of JPEG objects and then have a HTTPHandler that will serve the appropriate image when requested.
I don't see any clear way to do this. Anyone have any ideas?
Here is how I am getting the images, using LTI CIVIL as the capture library - This is saving them to disk - I want to store them in memory:
try
{
String fileName = "image" + System.currentTimeMillis() + ".jpg";
FileOutputStream os = new FileOutputStream(FILE_PATH + fileName);
final JPEGImageEncoder jpeg = JPEGCodec.createJPEGEncoder(os);
jpeg.encode(AWTImageConverter.toBufferedImage(image));
os.close();
log.info("Got image as filename: " + fileName);
}
catch (Exception e)
{
log.error("An error occured", e);
}