Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: Motion detection simple application

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Motion detection simple application

    I have been asked to make a simple application that uses a motion detection algorithm.
    I was able to successfully think of one, but i had a hard time getting the tools for it to work.

    My simple understanding is as follows.
    To detect motion you need to compare two frames for a change.
    Each stream of frames (Video in my case) contains of several frames that are displayed with a certain timer.
    Each frame has two dimensional array of pixels.
    Each pixel holds the data of red, green and blue color levels and of course its position.
    Color (Red, Green or Blue) data is mostly represented in an 8-bit representation ranging from 0 to 255 color level , giving a total of 256*256*256 with total possible display colors of 16777216.

    The Basic application idea is to.
    Get a video file (no camera available) (done using xuggle)
    Convert video to array of images (do not care about timing as i am not going to play it again) (problem)
    In a loop of total frames count/2 a frame [t] will be compared with a frame [t+1] for change. (not yet done)
    Get the pixels [][] data of a frame to compare. (not yet done)
    Incase of change more than 5% a new line will be wrote saying that in the frame number t+1 there was a XX% of change (This is the motion detection).


    As i am fairly new using java , right now i am stuck in the second step, I would really appreciate any help as i want to finish this tonight.

    This is my fail trial
    Detector.rar
    This is xuggler's xuggle library.
    http://www.mediafire.com/?dn9oblzbc4enjb4


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,828
    My Mood
    Hungover
    Thanks
    147
    Thanked 700 Times in 595 Posts

    Default Re: Motion detection simple application

    I'd start smaller. Write a simple program that compares two images and outputs the change percentage. Then from there you can add all the other bells and whistles.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    Junior Member
    Join Date
    Jun 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Motion detection simple application

    Quote Originally Posted by KevinWorkman View Post
    I'd start smaller. Write a simple program that compares two images and outputs the change percentage. Then from there you can add all the other bells and whistles.
    I think it will not be as hard , but i do not want to write something that will not work with the output i will be able to get from converting a video to a series of images.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,828
    My Mood
    Hungover
    Thanks
    147
    Thanked 700 Times in 595 Posts

    Default Re: Motion detection simple application

    It's really up to you, but starting with my suggested small program will make it easier to help you debug, and it's directly translatable to your actual goal. Simply saying you're stuck and then attaching a .rar file isn't really giving us a lot to help you with, which is why I'm suggesting you create an SSCCE that simply examines two hardcoded images.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  5. #5
    Junior Member
    Join Date
    Jun 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Motion detection simple application

    Thanks for the help.
    But what i meant to say is that the problem is not in the comparison part , it is in the Video to Image[] part.
    But i will try to continue the other parts of it.

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,828
    My Mood
    Hungover
    Thanks
    147
    Thanked 700 Times in 595 Posts

    Default Re: Motion detection simple application

    Ah, I see. Then go the other way: create a simple program that does ONLY that step. Even that can be broken down into more steps. Which step is giving you trouble? Connecting to a video source? Converting the video into a data structure of images? Something else?

    Identifying the specific, smallest piece you need will at least help you focus your google searches.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  7. #7
    Junior Member
    Join Date
    Jun 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Motion detection simple application

    The application has worked on a series of stored jpg images as BufferedImage [].
    Thanks for the support.

    But i kind of have some tricky questions.
    What runs first?
    In a java what i know is that the first thing runs in a class is it constructor.
    Now in the Main class which contains the public static void main (String Args[]) method.
    Does the main method run first or the constructor of this method's class, Cause i was told that the first thing to be run in a java project is the public static void main() code, so i want to be sure about that.

    Also in one project i can have more than one public static void main() method in the same main library/package but on different classes , The question is how do i know which one is supposed to run , and how do i change that manually if i want to?


    Knowing that i am using Netbeans.

    Thank you.

  8. #8
    Administrator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,848
    Thanks
    64
    Thanked 2,645 Times in 2,615 Posts

    Default Re: Motion detection simple application

    What runs first?
    Add println statements in all the places you are interested in and look at the order they are executed.

    how do i know which one is supposed to run
    You can have main() methods in all your classes. They are only used when you use the java command to start the execution of a class: java TheClassName will use the main() method in TheClassName.
    You should know which class you want to execute.

    i am using Netbeans.
    I have no idea how to configure an IDE to execute a class.

  9. #9
    Junior Member
    Join Date
    Jun 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Motion detection simple application

    Quote Originally Posted by Norm View Post
    Add println statements in all the places you are interested in and look at the order they are executed.
    Oh , ok

    Quote Originally Posted by Norm View Post
    You can have main() methods in all your classes. They are only used when you use the java command to start the execution of a class: java TheClassName will use the main() method in TheClassName.
    You should know which class you want to execute.

    I have no idea how to configure an IDE to execute a class.
    ok

Similar Threads

  1. Where to start for building a simple graphical application
    By IHeartProgramming in forum AWT / Java Swing
    Replies: 1
    Last Post: October 25th, 2012, 01:28 AM
  2. Replies: 2
    Last Post: June 13th, 2012, 03:57 PM
  3. How to write a simple automated reservation JAVA application
    By thekongss in forum Java Theory & Questions
    Replies: 3
    Last Post: November 30th, 2011, 12:31 AM
  4. Replies: 0
    Last Post: October 27th, 2011, 04:22 PM
  5. Replies: 2
    Last Post: March 23rd, 2011, 09:51 AM