Ignore:
Timestamp:
Mar 18, 2009 8:32:37 AM (15 years ago)
Author:
raasch
Message:

further updates for dvr output, bugfix in advec_particles concerning particle boundary condition

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/process_dvr_output

    r261 r262  
    1212
    1313
    14     # variable declarations + default values
     14    # Variable declarations + default values
    1515 camera=false
    1616 create_sequence_output=false
    1717 data_catalog=`pwd`
     18 dvrp_output=rtsp
    1819 file_identifier=all_streams
    1920 groundplate=false
     21 palm_run_identifier=""
    2022 topography=false
    2123
     
    2325
    2426
    25     # read shellscript options
    26  while  getopts  :d:f:s option
     27    # Read shellscript options
     28 while  getopts  :d:f:ls option
    2729 do
    2830   case  $option  in
    2931       (d)   data_catalog=$OPTARG;;
    3032       (f)   file_identifier=$OPTARG;;
     33       (l)   dvrp_output=local;;
    3134       (s)   create_sequence_output=true;;
    3235       (\?)  printf "\n  +++ unknown option $OPTARG \n"
    33              printf "\n      allowed option are -d and -f \n"
     36             printf "\n      allowed option are -d, -f, -l, -s \n"
    3437             exit;;
    3538   esac
     
    3740
    3841
    39     # change to the given directory
    40  cd $data_catalog
    41 
    42 
    43     # find out the number of streams
    44  (( i = 0 ))
    45  while true
    46  do
    47     (( i = i + 1 ))
    48     if (( i < 10 ))
    49     then
    50        cstream=0$i
     42    # Find out the PALM run identifier
     43 if [[ -f CPU_MEASURES ]]
     44 then
     45    palm_run_identifier=`head -1  CPU_MEASURES`
     46 fi
     47
     48    # Process the streaming server output
     49 if [[ $dvrp_output = rtsp ]]
     50 then
     51
     52       # Change to the given directory
     53    cd $data_catalog
     54
     55
     56       # Find out the number of streams
     57    (( i = 0 ))
     58    while true
     59    do
     60       (( i = i + 1 ))
     61       if (( i < 10 ))
     62       then
     63          cstream=0$i
     64       else
     65          cstream=$i
     66       fi
     67
     68       if [[ $(ls -1 *.* | grep -c $cstream) = 0 ]]
     69       then
     70          (( i = i - 1 ))
     71          break
     72       fi
     73
     74          # find out the stream name
     75       streamname[$i]=`ls -1 ${cstream}_*-ge.dvrs | cut -f1 -d"-"`
     76
     77          # get addres
     78       adr[$i]=`grep ADR= ${streamname[$i]}.dvrs | grep '*' | cut -f2 -d"="`
     79
     80          # get maxbytes
     81       maxbytes[$i]=`head -1 ${streamname[$i]}.max`
     82
     83          # get number of frames
     84       frames[$i]=`tail -1 ${streamname[$i]}.max`
     85
     86    done
     87
     88    nstream=$i
     89    nscenes=$nstream
     90
     91
     92       # Check, if there are files containing the camera data, the ground plate
     93       # and topography data.
     94       # Check the first stream only, because all streams have the same files.
     95    if [[ -f ${streamname[1]}_camera.max ]]
     96    then
     97       camera=true
     98       adr_camera=`grep ADR= ${streamname[1]}.dvrs | grep 'camera' | cut -f2 -d"="`
     99       maxbytes_camera=`head -1 ${streamname[1]}_camera.max`
     100       (( nscenes = nscenes + 1 ))
     101    fi
     102    if [[ -f ${streamname[1]}_groundplate.max ]]
     103    then
     104       groundplate=true
     105       adr_groundplate=`echo $adr_camera | sed "s/camera/groundplate/g"`
     106       maxbytes_groundplate=`head -1 ${streamname[1]}_groundplate.max`
     107       (( nscenes = nscenes + 1 ))
     108    fi
     109    if [[ -f ${streamname[1]}_topography.max ]]
     110    then
     111       topography=true
     112       adr_topography=`echo $adr_camera | sed "s/camera/topography/g"`
     113       maxbytes_topography=`head -1 ${streamname[1]}_topography.max`
     114       (( nscenes = nscenes + 1 ))
     115    fi
     116
     117
     118
     119       # Start with writing the dvrs file for the combined streams
     120    dvr_file=${file_identifier}_streaming.dvrs
     121
     122    echo  "SCENES=$nscenes"  >  $dvr_file
     123
     124       # First, add the static scenes
     125    if [[ $camera = true ]]
     126    then
     127       echo  "MED=TCP"                    >>  $dvr_file
     128       echo  "ADR=$adr_camera"            >>  $dvr_file
     129       echo  "MAXBYTES=$maxbytes_camera"  >>  $dvr_file
     130       echo  "FRAMES=1"                   >>  $dvr_file
     131       echo  "FRAMES_P_SEC=0"             >>  $dvr_file
     132       echo  "SCENEEND"                   >>  $dvr_file
     133    fi
     134
     135    if [[ $groundplate = true ]]
     136    then
     137       echo  "MED=TCP"                         >>  $dvr_file
     138       echo  "ADR=$adr_groundplate"            >>  $dvr_file
     139       echo  "MAXBYTES=$maxbytes_groundplate"  >>  $dvr_file
     140       echo  "FRAMES=1"                        >>  $dvr_file
     141       echo  "FRAMES_P_SEC=0"                  >>  $dvr_file
     142       echo  "SCENEEND"                        >>  $dvr_file
     143    fi
     144
     145    if [[ $topography = true ]]
     146    then
     147       echo  "MED=TCP"                        >>  $dvr_file
     148       echo  "ADR=$adr_topography"            >>  $dvr_file
     149       echo  "MAXBYTES=$maxbytes_topography"  >>  $dvr_file
     150       echo  "FRAMES=1"                       >>  $dvr_file
     151       echo  "FRAMES_P_SEC=0"                 >>  $dvr_file
     152       echo  "SCENEEND"                       >>  $dvr_file
     153    fi
     154
     155
     156       # Now add the streams
     157    (( i = 0 ))
     158    while (( i < nstream ))
     159    do
     160
     161       (( i = i + 1 ))
     162
     163       echo  "MED=TCP"                   >>  $dvr_file
     164       echo  "ADR=${adr[$i]}"            >>  $dvr_file
     165       echo  "MAXBYTES=${maxbytes[$i]}"  >>  $dvr_file
     166       echo  "FRAMES=${frames[$i]}"      >>  $dvr_file
     167       echo  "FRAMES_P_SEC=25"           >>  $dvr_file
     168       echo  "SCENEEND"                  >>  $dvr_file
     169
     170    done
     171
     172
     173       # Change path to the current file identifier
     174    sed  "s/DATA_DVR/${file_identifier}_dvr/g"  $dvr_file > tmp_file
     175    mv  tmp_file  $dvr_file
     176
     177
     178       # If there is a dvr configuration file, set the BASEDIR to the parent
     179       # directory of the above given path
     180    if [[ -f .dvrserver.config ]]
     181    then
     182       old_path=`grep  BASEDIR  .dvrserver.config`
     183       sed  "s&${old_path}&BASEDIR=..&g"  .dvrserver.config  >  .dvrserver.config.new
     184       mv  .dvrserver.config.new  .dvrserver.config
     185    fi
     186
     187
     188       # Create the html file for the combined streames
     189    cp  01_*-ge.html  tmp.html
     190    replace=$(echo `grep src= tmp.html`)
     191    sed "s&${replace}&src=\"${file_identifier}_streaming.dvrs\"&g" tmp.html > tmp1.html
     192    if [[ "$palm_run_identifier" = "" ]]
     193    then
     194       cp  tmp1.html  ${file_identifier}_streaming.html
    51195    else
    52        cstream=$i
    53     fi
    54 
    55     if [[ $(ls -1 *.* | grep -c $cstream) = 0 ]]
    56     then
    57        (( i = i - 1 ))
    58        break
    59     fi
    60 
    61        # find out the stream name
    62     streamname[$i]=`ls -1 ${cstream}_*-ge.dvrs | cut -f1 -d"-"`
    63 
    64        # get addres
    65     adr[$i]=`grep ADR= ${streamname[$i]}.dvrs | grep '*' | cut -f2 -d"="`
    66 
    67        # get maxbytes
    68     maxbytes[$i]=`head -1 ${streamname[$i]}.max`
    69 
    70        # get number of frames
    71     frames[$i]=`tail -1 ${streamname[$i]}.max`
    72 
    73  done
    74 
    75  nstream=$i
    76  nscenes=$nstream
    77 
    78 
    79     # Check, if there are files containing the camera data, the ground plate
    80     # and topography data.
    81     # Check the first stream only, because all streams have the same files.
    82  if [[ -f ${streamname[1]}_camera.max ]]
    83  then
    84     camera=true
    85     adr_camera=`grep ADR= ${streamname[1]}.dvrs | grep 'camera' | cut -f2 -d"="`
    86     maxbytes_camera=`head -1 ${streamname[1]}_camera.max`
    87     (( nscenes = nscenes + 1 ))
     196       sed "s&DATA_DVR/${streamname[1]}/\*\*\*\*\*.dvr (DVR 3D Streaming)&DVR 3D streaming generated by $palm_run_identifier&g"  tmp1.html  >  ${file_identifier}_streaming.html
     197    fi
     198    rm  tmp.html  tmp1.html
     199
     200
     201       # Informative messages
     202    printf "\n\n  *** processing dvr stream output:"
     203    printf "\n      number of detected streams = $nstream"
     204    printf "\n      stream names:"
     205
     206    (( i = 0 ))
     207    while (( i < nstream ))
     208    do
     209
     210       (( i = i + 1 ))
     211       printf " ${streamname[$i]}"
     212
     213    done
     214    printf "\n"
     215
     216
     217 else
     218
     219       # This is the branch for local output (dvrp_output=local).
     220       # Find out the number of streams.
     221    (( i = 0 ))
     222    while true
     223    do
     224
     225       (( i = i + 1 ))
     226       if (( i < 10 ))
     227       then
     228          cstream=0$i
     229       else
     230          cstream=$i
     231       fi
     232
     233       if [[ $(ls -1 *.* | grep -c ${cstream}_) = 0 ]]
     234       then
     235          (( i = i - 1 ))
     236          break
     237       fi
     238
     239          # find out the stream name
     240       streamname[$i]=`ls -1 ${cstream}_*.camera.dvr | cut -f1 -d"."`
     241
     242    done
     243
     244       # Exit, if there are no streams.
     245    [[ $i = 0 ]]  &&  exit
     246
     247    nstream=$i
     248
     249    mkdir -p  ${data_catalog}/sequence_data
     250
     251
     252       # First, merge static scenes into one file
     253    if [[ -f ${streamname[1]}.camera.dvr ]]
     254    then
     255       cat  ${streamname[1]}.camera.dvr  >>  ${data_catalog}/sequence_data/static_scenes.dvr
     256    fi
     257
     258    if [[ -f ${streamname[1]}.groundplate.dvr ]]
     259    then
     260       cat  ${streamname[1]}.groundplate.dvr  >>  ${data_catalog}/sequence_data/static_scenes.dvr
     261    fi
     262
     263    if [[ -f ${streamname[1]}.topography.dvr ]]
     264    then
     265       cat  ${streamname[1]}.topography.dvr  >>  ${data_catalog}/sequence_data/static_scenes.dvr
     266    fi
     267
     268
     269       # Find out the number of frames
     270    frames[1]=`grep sequence ${streamname[1]}_00000.html | cut -f2 -d";" | cut -f1 -d'"' | cut -f2 -d"-"`
     271
     272
     273       # Now, merge the data, frame by frame
     274    (( j = 0 ))
     275    while (( j < ${frames[1]} ))
     276    do
     277
     278       nframe=`printf "%05d" $j`
     279
     280       (( i = 0 ))
     281       while (( i < nstream ))
     282       do
     283          (( i = i + 1 ))
     284          cat  ${streamname[$i]}_$nframe.dvr  >>  ${data_catalog}/sequence_data/$nframe.dvr
     285       done
     286
     287       (( j = j + 1 ))
     288
     289    done
     290
     291
     292       # Create the html file to be used for the sequence mode
     293    cp  ${streamname[1]}_00000.html  tmp1.html
     294    sed  "s&${streamname[1]}_camera.dvr&sequence_data/static_scenes.dvr&g"  tmp1.html  >  tmp2.html
     295    sed  "s&${streamname[1]}_&sequence_data/&g"  tmp2.html  >  tmp3.html
     296    if [[ "$palm_run_identifier" = "" ]]
     297    then
     298       cp  tmp3.html  ${file_identifier}_sequence.html
     299    else
     300       sed "s&sequence_data/%05d.dvr (DVR 3D Sequence)&DVR 3D sequence generated by $palm_run_identifier&g"  tmp3.html  >  ${file_identifier}_sequence.html
     301    fi
     302    rm  tmp1.html  tmp2.html  tmp3.html
     303    mv  ${file_identifier}_sequence.html  ${data_catalog}
     304
     305
     306       # Informative messages
     307    printf "\n\n  *** processing dvr local output (using dvrp_output=local):"
     308    printf "\n      number of detected streams = $nstream"
     309    printf "\n      stream names:"
     310
     311    (( i = 0 ))
     312    while (( i < nstream ))
     313    do
     314
     315       (( i = i + 1 ))
     316       printf " ${streamname[$i]}"
     317
     318    done
     319    printf "\n"
     320
    88321 fi
    89  if [[ -f ${streamname[1]}_groundplate.max ]]
    90  then
    91     groundplate=true
    92     adr_groundplate=`echo $adr_camera | sed "s/camera/groundplate/g"`
    93     maxbytes_groundplate=`head -1 ${streamname[1]}_groundplate.max`
    94     (( nscenes = nscenes + 1 ))
    95  fi
    96  if [[ -f ${streamname[1]}_topography.max ]]
    97  then
    98     topography=true
    99     adr_topography=`echo $adr_camera | sed "s/camera/topography/g"`
    100     maxbytes_topography=`head -1 ${streamname[1]}_topography.max`
    101     (( nscenes = nscenes + 1 ))
    102  fi
    103 
    104 
    105 
    106     # start with writing the dvrs file for the combined streams
    107  dvr_file=${file_identifier}_streaming.dvrs
    108 
    109  echo  "SCENES=$nscenes"  >  $dvr_file
    110 
    111     # first, add the static scenes
    112  if [[ $camera = true ]]
    113  then
    114     echo  "MED=TCP"                    >>  $dvr_file
    115     echo  "ADR=$adr_camera"            >>  $dvr_file
    116     echo  "MAXBYTES=$maxbytes_camera"  >>  $dvr_file
    117     echo  "FRAMES=1"                   >>  $dvr_file
    118     echo  "FRAMES_P_SEC=0"             >>  $dvr_file
    119     echo  "SCENEEND"                   >>  $dvr_file
    120  fi
    121 
    122  if [[ $groundplate = true ]]
    123  then
    124     echo  "MED=TCP"                         >>  $dvr_file
    125     echo  "ADR=$adr_groundplate"            >>  $dvr_file
    126     echo  "MAXBYTES=$maxbytes_groundplate"  >>  $dvr_file
    127     echo  "FRAMES=1"                        >>  $dvr_file
    128     echo  "FRAMES_P_SEC=0"                  >>  $dvr_file
    129     echo  "SCENEEND"                        >>  $dvr_file
    130  fi
    131 
    132  if [[ $topography = true ]]
    133  then
    134     echo  "MED=TCP"                        >>  $dvr_file
    135     echo  "ADR=$adr_topography"            >>  $dvr_file
    136     echo  "MAXBYTES=$maxbytes_topography"  >>  $dvr_file
    137     echo  "FRAMES=1"                       >>  $dvr_file
    138     echo  "FRAMES_P_SEC=0"                 >>  $dvr_file
    139     echo  "SCENEEND"                       >>  $dvr_file
    140  fi
    141 
    142 
    143      # now add the streams
    144  (( i = 0 ))
    145  while (( i < nstream ))
    146  do
    147 
    148     (( i = i + 1 ))
    149 
    150     echo  "MED=TCP"                   >>  $dvr_file
    151     echo  "ADR=${adr[$i]}"            >>  $dvr_file
    152     echo  "MAXBYTES=${maxbytes[$i]}"  >>  $dvr_file
    153     echo  "FRAMES=${frames[$i]}"      >>  $dvr_file
    154     echo  "FRAMES_P_SEC=25"           >>  $dvr_file
    155     echo  "SCENEEND"                  >>  $dvr_file
    156 
    157  done
    158 
    159 
    160     # change path to the current file identifier
    161  sed  "s/DATA_DVR/${file_identifier}_dvr/g"  $dvr_file > tmp_file
    162  mv  tmp_file  $dvr_file
    163 
    164 
    165     # if there is a dvr configuration file, set the BASEDIR to the parent
    166     # directory of the above given path
    167  if [[ -f .dvrserver.config ]]
    168  then
    169     old_path=`grep  BASEDIR  .dvrserver.config`
    170     sed  "s&${old_path}&BASEDIR=..&g"  .dvrserver.config  >  .dvrserver.config.new
    171     mv  .dvrserver.config.new  .dvrserver.config
    172  fi
    173 
    174 
    175     # create the html file for the combined streames
    176  cp  01_*-ge.html  tmp.html
    177  replace=$(echo `grep src= tmp.html`)
    178  sed "s&${replace}&src=\"${file_identifier}_streaming.dvrs\"&g" tmp.html > ${file_identifier}_streaming.html
    179  rm tmp.html
    180 
    181 
    182     # informative messages
    183  printf "\n\n  *** processing local dvr stream output:"
    184  printf "\n      number of detected streams = $nstream"
    185  printf "\n      stream names:"
    186 
    187  (( i = 0 ))
    188  while (( i < nstream ))
    189  do
    190 
    191     (( i = i + 1 ))
    192     printf " ${streamname[$i]}"
    193 
    194  done
    195  printf "\n"
    196 
    197 
    198     # create output for viewing dvr data in sequence mode
     322
     323
     324    # Create output for viewing dvr data in sequence mode
    199325 if [[ $create_sequence_output = true ]]
    200326 then
     
    202328    mkdir  sequence_data
    203329
    204        # first, merge static scenes into one file
     330       # First, merge static scenes into one file
    205331    if [[ $camera = true ]]
    206332    then
     
    219345
    220346
    221        # now, merge the data, frame by frame
     347       # Now, merge the data, frame by frame
    222348    (( j = 0 ))
    223349    while (( j < ${frames[1]} ))
     
    238364
    239365
    240        # create the html file to be used for the sequence mode
     366       # Create the html file to be used for the sequence mode
    241367    cp  ${streamname[1]}.html  tmp1.html
    242368    sed  "s/camera.dvr/static_scenes.dvr/g"  tmp1.html  >  tmp2.html
    243     sed  "s&${streamname[1]}&sequence_data&g"  tmp2.html  >  ${file_identifier}_sequence.html
    244     rm  tmp1.html  tmp2.html
     369    sed  "s&${streamname[1]}&sequence_data&g"  tmp2.html  >  tmp3.html
     370    if [[ "$palm_run_identifier" = "" ]]
     371    then
     372       cp  tmp3.html  ${file_identifier}_sequence.html
     373    else
     374       sed "s&DATA_DVR/sequence_data/\*\*\*\*\*.dvr (DVR 3D Sequence)&DVR 3D sequence generated by $palm_run_identifier&g"  tmp3.html  >  ${file_identifier}_sequence.html
     375    fi
     376    rm  tmp1.html  tmp2.html  tmp3.html
    245377
    246378    printf "      data for using sequence mode generated"
     
    250382
    251383
    252     # change back to directory from where script has been called
    253  cd - > /dev/null
     384    # Change back to directory from where script has been called
     385 cd - > /dev/null  2>&1
Note: See TracChangeset for help on using the changeset viewer.