Update Doors_Schedule.py
Browse files- Doors_Schedule.py +27 -31
Doors_Schedule.py
CHANGED
|
@@ -1787,38 +1787,34 @@ def mainRun(schedule, plan, searcharray):
|
|
| 1787 |
|
| 1788 |
|
| 1789 |
##### SHOULD return pretty_xml, column_xml, merged_pdf
|
| 1790 |
-
|
| 1791 |
-
|
| 1792 |
-
|
| 1793 |
-
''' not_found = []
|
| 1794 |
doc2 =fitz.open('pdf',merged_pdf)
|
| 1795 |
len_doc2 = len(doc2)
|
| 1796 |
-
print(f"number of pges of doc2 is {len_doc2} and its type is {type(doc2)}")
|
| 1797 |
-
page=doc2[0]
|
| 1798 |
-
pix = page.get_pixmap() # render page to an image
|
| 1799 |
-
pl=Image.frombytes('RGB', [pix.width,pix.height],pix.samples)
|
| 1800 |
-
img=np.array(pl)
|
| 1801 |
-
annotatedimg = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|
| 1802 |
-
|
| 1803 |
-
|
| 1804 |
list1=pd.DataFrame(columns=['content', 'id', 'subject','color'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1805 |
|
| 1806 |
-
|
| 1807 |
-
for page in doc2:
|
| 1808 |
-
# Iterate through annotations on the page
|
| 1809 |
-
for annot in page.annots():
|
| 1810 |
-
# Get the color of the annotation
|
| 1811 |
-
annot_color = annot.colors
|
| 1812 |
-
if annot_color is not None:
|
| 1813 |
-
# annot_color is a dictionary with 'stroke' and 'fill' keys
|
| 1814 |
-
stroke_color = annot_color.get('stroke') # Border color
|
| 1815 |
-
fill_color = annot_color.get('fill') # Fill color
|
| 1816 |
-
if fill_color:
|
| 1817 |
-
v='fill'
|
| 1818 |
-
# print('fill')
|
| 1819 |
-
if stroke_color:
|
| 1820 |
-
v='stroke'
|
| 1821 |
-
x,y,z=int(annot_color.get(v)[0]*255),int(annot_color.get(v)[1]*255),int(annot_color.get(v)[2]*255)
|
| 1822 |
-
list1.loc[len(list1)] =[annot.info['content'],annot.info['id'],annot.info['subject'],[x,y,z]]
|
| 1823 |
-
return annotatedimg, doc2 , list1, repeated_labels , not_found
|
| 1824 |
-
'''
|
|
|
|
| 1787 |
|
| 1788 |
|
| 1789 |
##### SHOULD return pretty_xml, column_xml, merged_pdf
|
| 1790 |
+
not_found = []
|
| 1791 |
+
annotatedimgs=[]
|
|
|
|
|
|
|
| 1792 |
doc2 =fitz.open('pdf',merged_pdf)
|
| 1793 |
len_doc2 = len(doc2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1794 |
list1=pd.DataFrame(columns=['content', 'id', 'subject','color'])
|
| 1795 |
+
print(f"number of pges of doc2 is {len_doc2} and its type is {type(doc2)}")
|
| 1796 |
+
for page in len_doc2:
|
| 1797 |
+
# page=doc2[0]
|
| 1798 |
+
pix = page.get_pixmap() # render page to an image
|
| 1799 |
+
pl=Image.frombytes('RGB', [pix.width,pix.height],pix.samples)
|
| 1800 |
+
img=np.array(pl)
|
| 1801 |
+
annotatedimg = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|
| 1802 |
+
annotatedimgs.append(annotatedimg)
|
| 1803 |
+
# Iterate through annotations on the page
|
| 1804 |
+
for annot in page.annots():
|
| 1805 |
+
# Get the color of the annotation
|
| 1806 |
+
annot_color = annot.colors
|
| 1807 |
+
if annot_color is not None:
|
| 1808 |
+
# annot_color is a dictionary with 'stroke' and 'fill' keys
|
| 1809 |
+
stroke_color = annot_color.get('stroke') # Border color
|
| 1810 |
+
fill_color = annot_color.get('fill') # Fill color
|
| 1811 |
+
if fill_color:
|
| 1812 |
+
v='fill'
|
| 1813 |
+
# print('fill')
|
| 1814 |
+
if stroke_color:
|
| 1815 |
+
v='stroke'
|
| 1816 |
+
x,y,z=int(annot_color.get(v)[0]*255),int(annot_color.get(v)[1]*255),int(annot_color.get(v)[2]*255)
|
| 1817 |
+
list1.loc[len(list1)] =[annot.info['content'],annot.info['id'],annot.info['subject'],[x,y,z]]
|
| 1818 |
+
return annotatedimgs, merged_pdf , list1, repeated_labels , not_found, pretty_xml, column_xml, merged_pdf
|
| 1819 |
|
| 1820 |
+
# return annotatedimg, doc2 , list1, repeated_labels , not_found
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|