Announcement

Collapse
No announcement yet.

Still Image every 5 metres

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Still Image every 5 metres

    Hi there!

    I have a tricky problem, not really sure how I am going to solve...but I thought I would throw it out there and see if some smart bugger can shed some light.


    I want to write a piece of software to take a still image (probably from a webcam) every 5 metres that the car travels.

    I use a wheel probe to track the movment of the car.

    I keep count of the wheel probe pulses in a hardware counter - i poll this to see how far we have gone.

    I almost need something that will send an interrupt to some software every time five meters has gone by and then either create a timestamp of that event (to go back through a video at the end and pull out the appropriate frame of that timestamp), or to simply take a single frame snapshot in realtime.

    I am not sure I have done a very good job of explaining myself.

    Any advice would be greatly appreciated.

    Cheers,

    Kiwiuser.

  • #2
    Maybe a strange question but how accurate has that 5 meters has to be?

    Because this is how i should create a solution:

    - use your GPS to get your current speed
    - calculate the time intervals at which pictures have to be taken
    - take pictures at these time intervals and save them

    all this can be done in a vb.net / c++ program 'easily'

    But for your sollution i would use the printerport as a digital input if your motherboard has one.

    Comment


    • #3
      Easy?

      Hi MNeilSM,

      Thanks for your reply - maybe I need to add some more information to my inital post.

      I am not going to use GPS, it is far two inaccurate (even with Post Processing or DGPS). But thats not really the issue I was trying to solve anyway - I have a very accruate speed and distance colection system already via a labjack U3 and a proximity sensor.

      The real issue is perhaps how to take a single still image say.....5 times a second? A video camera should be able to do this because they operate at about 30frames per second I think.

      The question is, how to write some software to pick a single frame from a video at that frequency (5 times per second - or 5Hz).

      You suggested it was reasonably easy, can you perhaps give me some more information?

      Thanks for your help.

      Kiwiuser

      Comment


      • #4
        GPS is one option, and you nixed that.

        Another would invilve knowing the circumference of the tire. The speedometers on a bicycle work this way. By knowing the sicrumerence of the tire and a wheel sensor (or calculate wheel speed from engine RPM & gear selection, if you choose), you can determine rolling distance.

        The problem is that it wouldn't be universal, as there are many different sizes fo wheel/tire combination.

        How bike speedometers get around this is have the user has select a code that matches the size of the wheels on the bicycle. It's kluugy, but it works.

        1 mile = 1609.344 meter
        At 60mph, you'd capture 95560 images per hour or about 27 frames per second. That's full motion video right there. Obviously, the faster you go, the more frequently it would click off images, but I'm sure it would get to a speed where it would overwhelm the computer.

        This would only be useful for something slow moving., obviously.

        Have you considered making the system take a picture every X second. You could calculate the X based on whatever speed you intend to go. If your vehicle has cruise control, all the better.
        Have you looked in the FAQ yet?
        How about the Wiki?



        Under normal circumstances, a signature would go here.

        Comment


        • #5
          Hi Darque,

          The problem that i am trying to solve is not when to take the photos......but how to take still images so quickly, (i.e five a second). If these cannot be taken in realtime then I need to postprocess the video somehow and pick out the frames that I want.

          I NEED to take an image every five metres - that is the project essentially.

          In relation to the timing of when to take the photo, I have already solved this problem with proximity sensor on the drive shaft - this is accurate to 25cm. So far better than GPS - and is working great.

          Cheers,

          Kiwi

          Comment


          • #6
            Wire an led to light every 5 meters, and place this led so the webcam (USB2-30fps) can see it. Make sure the led is lit for at least 1 frame. Then post process the film to get images with led on.
            Now Galileo is real. Muhahahahaha :p

            Comment


            • #7
              THinking outside the box there! Good work!

              Not sure that it will work for this particular application.

              Perhaps I can ask some more specific questions....

              1. What is the maximum frequency that you can shoot still images from a webcam? Could you take 10 stills a second? - i am guessing that the amount of time required to process each still - ya could not.

              2. Is there some simple software around that I could use to extract a frame from a video based on a timestamp?

              Comment


              • #8
                of course you can get a picture 5 times a second from a webcam. You don't have to record a video for anything like that unless you want to.

                If you intend to do this in normal sunlight then you could get at least 15 pictures a second even from a cheap webcam. The darker it gets though the lower a webcam's framerate (because their cheap sensors need more time to get a clear picture).

                Although I have never programed in visual basic or .net this should be a fairly easy job.

                I would say that 5 pictures a second at 640x480 can easily be handled by even a slow computer since you only have like ~60kB per picture(JPEG) which would make about 300kB/s at 5 pictures a second

                Comment


                • #9
                  I'm quite interested in this sort of thing (wish I had more free time to play with it)

                  An article I found that looks pretty useful, about using windows image acquisition (WIA) in .NET:
                  http://blogs.msdn.com/coding4fun/arc...31/912546.aspx
                  they don't really say how fast you can grab images, but this other article which also uses WIA, taking still images, says "After the first image is taken, images start flying so fast it is going to look like a live video feed!!", so I think there's potential for enough speed.
                  http://www.codeproject.com/useritems/WebCamService.asp
                  But don't take it from me! here's a quote from a real, live newbie:
                  Originally posted by Viscouse
                  I am learning buttloads just by searching on this forum. I've learned 2 big things so far: 1-it's been done before, and 2-if it hasn't, there is a way to do it.
                  eegeek.net

                  Comment


                  • #10
                    Interesting

                    Thanks for the links, I will follow it up!

                    One of the problems I think I will have will guarunteeing the synchronicity between my proximity sensor and the webcam.

                    The problem comes where I have to devote a certain percentage of the CPU to polling the proximity sensor to see when five metres has been travelled (i.e 100hz - 100 times per second) , and a certain percentage of time to processing the Webcam image.

                    Multithreading it gives the advantage that one process will not hold other.....but introduces timing issues between the two tasks.

                    Curious........

                    Comment


                    • #11
                      Originally posted by kiwiuser View Post
                      Thanks for the links, I will follow it up!

                      One of the problems I think I will have will guarunteeing the synchronicity between my proximity sensor and the webcam.

                      The problem comes where I have to devote a certain percentage of the CPU to polling the proximity sensor to see when five metres has been travelled (i.e 100hz - 100 times per second) , and a certain percentage of time to processing the Webcam image.

                      Multithreading it gives the advantage that one process will not hold other.....but introduces timing issues between the two tasks.

                      Curious........
                      I don't think it'll be a huge deal. In .NET, events/delegates are great for this. Just stick a polling routine in a separate thread and have it fire an event in the main program when it's time to take a picture. As long as your picture-taking delegate routine can take a picture faster than the next event is fired, you shouldn't have any problems.

                      With the USB interfacing I play with, I do exactly this sort of thing - wait for messages from the USB device in one thread, and fire events to deal with new asynchronously received data in the main thread.

                      You could probably offload some (or all) of the real polling duty depending on how you interface the hardware - for example, if you use the serial port you can probably get away with just using the built-in events that it can fire when it receives data, which would be easier and probably a lot more efficient than creating your own polling thread and rapidly polling some arbitrary hardware interface.

                      Since you seem so concerned about the timing synchronization, what kind of accuracy are you looking for here? Do you need the pictures taken like PRECISELY every 5 meters, or do you just need it pretty close? I would expect the picture taking process to be pretty fast, but "fast" is a very relative term, so it would help to know your requirements to put it in perspective.
                      But don't take it from me! here's a quote from a real, live newbie:
                      Originally posted by Viscouse
                      I am learning buttloads just by searching on this forum. I've learned 2 big things so far: 1-it's been done before, and 2-if it hasn't, there is a way to do it.
                      eegeek.net

                      Comment


                      • #12
                        You can not achieve Hard RealTime in windows, due to windows design. If these timing are critical, its time to switch to linux or RTai or RTLinux, and try JavaRT / Cposix.
                        Now Galileo is real. Muhahahahaha :p

                        Comment


                        • #13
                          The synchronisation does not have to be exact - just close enough that there is no issue. By multitthreading it should be fine - and I can always produce an exception report of any missed frames upon completion anyway I guess (although it is highly unlikely there would be any problem).

                          Another option would be to use a datalogger interface to the proximity sensor and post process the video instead.

                          Either way.....anything that keeps me the heck away from unix or any variation of unix will be a good thing!

                          Comment


                          • #14
                            i think your going to run into problems when travelling at some speed, as suggested with the timings of "At 60mph, you'd capture 95560 images per hour or about 27 frames per second"... your will not be able to "pluck" these frames from the video feed and still keep it in time. I'm sure a fancy script may do it... But this task wont be to easy unless there is a way i have not seen with multi frame separation from the video.

                            So your going to poll the sensor at least 100 times a second, if not plenty more if the lowest measurement is 25cm. Then you will need to record the video stream live to a file and run a background process to extract the frames at the timing based upon your speed.?

                            dont get me wrong, this could all work out easily... Just get the programmer feeling saying... ouch....
                            Another option if your able to would be multiple cameras, this will allow you to by pass the live video feed and have them take turns in capturing while another is in use? tho position of the pictures would be out.

                            Either way best of luck,
                            2004 Holden WL Caprice Auto GENIII
                            Base System = Raspberry Pi
                            Everything else is pending for now as switched from a Mini-ITX setup

                            Comment


                            • #15
                              Brraaaiiiiiiiiinnnnnsssss (Zombie threads suck)
                              Brrraiiiinnnnss (Check the date before posting)

                              Brains (thank you)
                              "stop with the REINSTALLS, what do you think we got some lame-o installer!!!" - mitchjs
                              RevFE
                              My Shop

                              Comment

                              Working...
                              X