anisha3 has asked for the wisdom of the Perl Monks concerning the following question:

Hello!!!!! I have a query :How to count the objects in video???for example the video consists of worms which move frequently and i would like to know how many times it move???I have tried counting in files not videos ...can any one please guide me how should i generate the coding..the coding I pasted is for files but please tell me for videos or at least for images

open(FILE, "<file.txt") or die "Could not open file: $!"; my ($lines, $words, $chars) = (0,0,0); while (<FILE>) { $lines++; $chars += length($_); $words += scalar(split(/\s+/, $_)); } print("lines=$lines words=$words chars=$chars\n");

Replies are listed 'Best First'.
Re: Regarding Perl Counting
by atcroft (Abbot) on Feb 14, 2014 at 17:24 UTC

    The code you posted was an example of replicating the output of the wc(1) command from Unix, which counts lines, words, and characters in a file. While I have not attempted it personally, to count movements in a video I would imagine a process similar to the following:

    1. Break video into frames
    2. Reduce color pallet (possibly to a limited grayscale) to reduce the possibility of false readings due to frame-to-frame changes in lighting.
    3. Possibly reduce image size, to reduce the possibility of false readings due to changes by objects not of interest.
    4. Loop through the frames, comparing each to its successor, looking for more than pixel changes than a particular threshold that you set, to indicate that a sufficient movement has occurred.

    There are probably better ways than this, but this is what came to my mind. I hope more knowledgeable monks will share their experiences and provide the guidance you seek to help you solve your problem.

    Hope that helps.

      And FFMPEG can do all of the image manipulation for you. I do most of this for $work myself already.
Re: Regarding Perl Counting
by LanX (Saint) on Feb 14, 2014 at 18:32 UTC
Re: Regarding Perl Counting (WormScan)
by erix (Prior) on Feb 16, 2014 at 07:18 UTC
Re: Regarding Perl Counting
by karlgoethebier (Abbot) on Feb 14, 2014 at 20:28 UTC
    "...the video consists of worms which move frequently..."

    Ask Montgomery Scott. If Scotty can't help, please see this ;-)

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»