Web-cam motion detection Java program


#1

I am currently working on a final year project in my school. It has to do with making a motion detector with a webcam. After many failed attempts I decided to go online to get some help. I found some code for the class that would help do what I want for my project, but it didn’t have any tutorial on how to understand the code. The code wasn’t so perfectly commented. There is a method in the code that is of concern to me. It is the process method. Can anyone tell me how to create the objects that would serve as parameters for the method cos I don’t know the fully qualified name of the Buffer class. And again I also need to fully understand the rest of the method. Here is the URL of the code.

http://www.java2s.com/Code/Java/2D-Graphics-GUI/AmotiondetectionalgoritmforusewiththeJavaMediaFrameworkAPIJMF.htm

Please endeavor to check it out. I really need this for my project unless . . . Please reply as soon as possible. Thanks.


#2

I have tested the code and it works fine. The process method is where motion detection is monitored. check this link http://www.darnok.org/programming/motion-detection/


#3

Thanks men for the link. I downloaded the source code. It compiled successfully, but when I plugged my web-cam to my computer and ran the ‘TestMotionDetection’ class with the main method the visual display did not show any sign of motion detection. Have you tried the program with a USB web-cam?

I really need some help here(as soon as possible) cos I have to defend the project in a week plus. Thanks


#4

Yeah I tested it with my laptop webcam and also a usb webcam. I later replaced the effect in this code with the effect from the link in your first posting.


#5

Sorry I just remembered that one of the effects they used did not work. Take note of the digital clock on the screen, it on runs when motion is detected and stops when no motion is detected. That is the work of “TimeStampEffect class” Also add the class from the link in your first posting to the package of this example.

There’s an object Codec codec[] = {new MotionDetectionEffect(),new TimeStampEffect()};
Replace new MotionDetectionEffect() with the class name of effect from your first posting and see what happens

Enjoy


#6

Thanks soooooo much. It worked. There were weird red and orange outlines on objects that moved over the viewing area of my web-cam. How did you figure out the problem? That must have been some good thinking.

I just couldn’t believe that all that source code from the link you posted could have a problem. I taught the problem was from my computer(that maybe I was missing a driver or something), cos I’ve done some pretty messed up stuff with it.

If you could give me a break down of what is going on the various source files I would really appreciate. I want to understand it, not just for my project, but cos I love programming.

I don’t mean to be dumping the work that I should be doing on you, but you know how hard it is to come about a good standard JMF ebook.

If you like you could check out a program that I wrote. The link to it is below:
http://www.4shared.com/file/pzcvpwZC/MasterProjectiles.html


#7

Some JMF books for you
http://www.ziddu.com/download/13564376/JMF.zip.html


#8

Thanks men. I have searched so many times for a good JMF book. I hope you continue to be at codenigeria.


#9

Hey, there. I’ve gotten to a road block with my project. I am supposed to save an image to the computer when motion detection happens. How can I do that? Thanks. I’ve made the GUI with JRadioButtons to turn on and to turn off the motion detector. I also created a JCheckBox that would enable or disenabale an alarm sound. By using a JFlieChooser I was able to make it possible to change the directory where motion detection images will be saved. If you give me your email address I could send you my code.


#10

[email protected]


#11

about not being able to upload files on codenigeria, there is an “Attach a file” link beneath the textarea into which you type ur comments.


#12

Attached is a file that contains sample codes.

Enjoy


#13

Thanks. I’ll try it out and give you the feedback.


#14

please, i need d right import statement that includes d classes JPEGEncoder,JPEGCodec, and JPEGEncodeParam in my program code.thanks.


#15

Attached is a zipped file of my code(and the executable jar file) at its present state. Run the MotionDetectionApp jar file, and see how you could input the image snapping functionality when motion detection occurs, cos I couldn’t apply the advice you gave. Thanks


#16

Try using an IDE like Netbeans. It will help you with automatic imports and also help you understand Java packages faster.

"com. sun. image. codec. jpeg. JPEGCodec;" "com. sun. image. codec. jpeg. JPEGEncodeParam;" "com. sun. image. codec. jpeg. JPEGImageEncoder;"

Pls remove the extra space between the dots


#17

Attached is an updated code for u


#18

thanks 4 all ur help 4rm d very beginning.i got ur message late, so yesterday afternoon i came up wit an idea 2 get d job done.I was able 2 do d image saving by using the ImageIO class.I tink this way is easier and shorter. If u want i could send a zipped file of my final source code and jar file. That’s d least i could do.


#19

For anyone who is interested here is source code and executable jar file in a zipped file for the completely functional webcam(both USB and in-built) motion detector program. You must have the java runtime environment and jmf installed on your computer. Once extracted, the jar file and the folder within the zipped file must be in the same directory. Hope someone finds this useful.


#20

How can I make it save only the very first image of the motion?