|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--se.lth.cs.jpeg.JPEGMotionDetector
Motion detector for JPEG encoded images. Decodes images internally and computes the difference from the last image.
A sampling distance of N means that only every Nth pixel, in both X and Y dimensions, is inspected in images. In other words, only one out of totally N*N pixels is inspected. Larger N means lower execution time and lower precision.
The JPEG decoding algorithm is tuned to only decode to the necessary resolution; higher sampling distance means that the image is decoded to lower resolution, which takes less time.
The motion detection algorithm works by computing the difference
between two images. The "centre of gravity" in the
difference image gives a rough idea of where in the image something
is happening. After a comparison, the coordinates of this point
can be retrieved using getMotionX()
and
getMotionY()
. However, note that these coordinates
only make sense if something is actually moving.
(Implementation note: to make the algorithm focus on a few large differences (motion) rather than many small ones (noise), all elements in the difference image are squared before computing the centre of gravity. This modification amplifies large differences.)
Constructor Summary | |
JPEGMotionDetector(int width,
int height,
int samplingDistance)
Create a motion detector with a given sampling distance. |
Method Summary | |
int |
compareToPrevious(byte[] image)
Returns the image difference between the given image and the previous one, in the range of 0 (no difference) to 255 (completely different). |
void |
finalize()
Finalizer. |
int |
getMotionX()
|
int |
getMotionY()
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JPEGMotionDetector(int width, int height, int samplingDistance)
width
- Image width in pixelsheight
- Image height in pixelssamplingDistance
- Sampling distance. The only legal values
are 1, 2, 4, and 8.Method Detail |
public int compareToPrevious(byte[] image)
Returns the image difference between the given image and the previous one, in the range of 0 (no difference) to 255 (completely different).
On the first call, there is no previous image to compare to (of course). This method then returns zero.
This method also determines the point of interest (POI), which is
the point in the image where the largest differences occur.
After calling this method, the POI can be determined using methods
getMotionX()
and getMotionY()
.
image
- The image in JPEG encoded form.java.lang.IndexOutOfBoundsException
- If the size of the image differs
from that given in constructorjava.lang.IllegalArgumentException
- If the image is not correctly JPEG
encodedpublic void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
public int getMotionX()
public int getMotionY()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |