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

Please help, I know it can be done.

I have 60,075 .txt files(TAB delimited) that are created from ImageJ that contains the XY coordinates and RGB tuples for each frame(60075 frames) of a video. (Macro took me days to make, 16 hours to run, and ate up 360GB)

I need the RGB tuple information from one coordinate x=384, y=377 for each frame. (this information is not always found on the same line#, which is why I need a piece of logic to find the data)

I need this data in a new file that can be loaded into a spreadsheet. So it needs to have either TAB or comma separated values. The file being created will have 60076 lines of data when completed.

Each RGB tuple file is named 00000.txt - 60075.txt

(G:\Frames as bitmap\00000.txt) <-where it sits for me

RGB tuple file example line;

0 (TAB) 0 (TAB) 113 (TAB) 0 (TAB) 255 {X Y R G B}

Desired new file example line

00000,255,255,255 or 00000 (TAB) 255 (TAB) 255 (TAB) 255

I would like to be able to adapt this based on changes to directory and coordinates desired.

Thank you for your time in advance.

My end goal is to prove the police edited an arrest video.

Still have to do statistical analysis after this to prove pixel skew.

Replies are listed 'Best First'.
Re: need logic, police edited video
by kcott (Archbishop) on Jan 02, 2014 at 06:37 UTC

    G'day AwsedreswA,

    Welcome to the monastery.

    Unfortunately, this is all rather vague. You haven't shown any code or specified what you're actually having difficulty with. You indicate no rules for converting "0 (TAB) 0 (TAB)" to "00000 (TAB)" nor for converting "113 (TAB) 0 (TAB) 255" to "255 (TAB) 255 (TAB) 255". Perhaps the guidelines in "How do I post a question effectively?" would help you express more clearly what precisely you want help with.

    Having said that, the following may be of use:

    • One of the Text::CSV family of modules is probably your best choice for handling comma/tab separated files.
    • Use sprintf to format strings.

    When you've written some code, feel free to ask specific questions regarding anything you're encountering difficulties with.

    -- Ken

Re: need logic, police edited video
by atcroft (Abbot) on Jan 02, 2014 at 09:24 UTC

    Reading your description, here is my *UNTESTED* code that I think (minus the possibility of small typos) to do what you are requesting:

    Please comment if that does indeed do so, or if your expectations differed from those I understood.

    Hope that helps.

      Had to track down one of my old professors.

      Here is what we came up with

      ##This script is for use with rgb tuple files created through ImageJ.e +xe's xy coordinate extractor ##With RGB tuple files for each frame of a video, this script will ext +ract the RGB values for one pixel location. ##Each line of the new file has file name(= frame number), x, y, R, G, + B. $out_file="C:\\perl\\scripts\\bluetime.txt"; # out_file is the output file name, created by extracting the RGB valu +es from one coordinate unlink $out_file; # erased (deletes) the output file FIRST, otherwise it will continue t +o append to it! open ($output_file,">>",$out_file) or die "Could not open output_file! +!!"; #open file for append for ($i=1;$i<=60075;$i++) # files 00000.txt thru 60075.txt { $output_name = sprintf("%05d",$i); # first field in bluetime, 5 digits $input_file = sprintf("G:\\Frames_as_RGB_Tuples\\%05d.txt",$i); + # FQ input filename open ($infile, "<",$input_file) or die "Could not open input file +$input_file!!!"; ## "<" means read from, ">>" means append to, ">" means write to! # printf("G:\\Frames_as_RGB_Tuples\\%s.txt\n", $result); #For testing while(<$infile>) # read one line from infile, put in $_ { if($_ =~ /^390\t379/) #for each line, if "390(tab)379" is on the line then... { print $output_file sprintf("%s\t%s",$output_name,$_); #write to ouput_file #5 digits of filename plus the line where coordinate was f +ound } } close $infile; } close $output_file; ## by PK Birkmeyer and Ben Gregory one fine afternoon.

      I would like if it gave me some feedback as to its progress, if anyone can help there.

      This script worked, need help with next hurdle. Posted my pseudo code on this forum here.

      http://www.perlmonks.org/?node_id=1072419

Re: need logic, police edited video
by Anonymous Monk on Jan 02, 2014 at 06:45 UTC
Re: need logic, police edited video
by Laurent_R (Canon) on Jan 02, 2014 at 07:17 UTC
    Can you please show a few sample lines of your data and tell exactly which part you need to extract?