Hi,
I am trying to write a simple java application that detects motion. The application gets its images from a webcam with the address:
http://studiocam1.disp.duke.edu/jpg/image.jpg
(you can watch the live video feed at: http://studiocam1.disp.duke.edu/view/index.shtml)
My current plan is: (I have little experience, so it may be wrong)
1. I obtain an image from the webcam at http://studiocam1.disp.duke.edu/jpg/image.jpg and store it as a BufferedImage.
2. I call getRGB() on the BufferedImage, which loads the pixel data into an int[] array)
3. One second later, I obtain a second image from the webcam (at the same address) and store that as a BufferedImage as well. I call getRGB() on the second image as well.
4. Now I have two int[] arrays. One array represents the "before" picture, one array represents the "after" picture. If I compare the two arrays, and I notice significant difference, then my program signals that "motion is detected."
5. I would also like my application display the constant sequence of images that it is reading in a window. Basically, the window would show the live video feed from the camera.
My problem is here:
- I don't know how to display the images in a continuous video-like fashion
* the only way I have ever displayed an image is by loading an ImageIcon, and then adding that ImageIcon into a JLabel, and then adding that JLabel into a JPanel, and then adding that JPanel into a JFrame
* I tried creating the illusion of video by constantly updating my ImageIcon in a while-loop. However, that produces VERY choppy and poor quality video
- I have a great degree of uncertainty. Is there a package or a class that was especially designed for dealing with video, frame-by-frame?
Help would be greatly appreciated. Thanks in advance.
I'm sorry that I have no code to show you. All the code that I have written works fine. But regarding my problem, I don't even know where to start--so I have nothing to show.