PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
ConvertROIToClipRectangle.py
Go to the documentation of this file.
1 import os
2 
3 def getInfos(currentDir):
4  for root, dirs, files in os.walk(currentDir): # Walk directory tree
5  #dirs[:] = [os.path.join(root, d) for d in dirs]
6  files = [os.path.join(root, f) for f in files]
7  for f in files:
8  if f.find(".xml") != -1:
9  os.rename( f, f+"~" )
10  destination = open( f, "w" )
11  source = open( f+"~", "r" )
12  for line in source:
13  if line.find("RegionOfInterest") != -1:
14  whitespaces = len(line) - len(line.lstrip(' '))
15  prepend = ""
16  for w in range(whitespaces):
17  prepend += " "
18  first = line.find("\"")
19  second = line.rfind("\"")
20  nums = line[first+1:second]
21  result = nums.split()
22  xorig = int(result[0])
23  yorig = int(result[1])
24  xsize = int(result[2]) - int(result[0])
25  ysize = int(result[3]) - int(result[1])
26 
27  destination.write( prepend + "ClipRectangleOrigin=\"" + str(xorig) + " " + str(yorig) + "\" \n" )
28  destination.write( prepend + "ClipRectangleSize=\"" + str(xsize) + " " + str(ysize) + "\" \n" )
29  else:
30  destination.write( line )
31  source.close()
32  destination.close()
33  os.unlink(f+"~")
34  return
35 
36 if __name__ == '__main__':
37  getInfos("C:\devel\PlusBuild-bin-x32\PlusLib\Data\ConfigFiles")
int
Definition: phidget22.h:3069