Spaces:
Sleeping
Sleeping
Update Counting_Columns_2_1.py
Browse files- Counting_Columns_2_1.py +22 -2
Counting_Columns_2_1.py
CHANGED
|
@@ -217,8 +217,28 @@ def mainfun(plan):
|
|
| 217 |
columns_types_v = getColumnsTypesKeyValue(nearby, txtpts_ky_vlu)
|
| 218 |
legend = generate_legend(columns_types_v)
|
| 219 |
pdf_document = add_annotations_to_pdf(image, pdf_name, slctd_clm, columns_types_v)
|
| 220 |
-
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
'''def mainfun(plan):
|
| 224 |
texts_from_pdf = get_text_from_pdf(plan)
|
|
|
|
| 217 |
columns_types_v = getColumnsTypesKeyValue(nearby, txtpts_ky_vlu)
|
| 218 |
legend = generate_legend(columns_types_v)
|
| 219 |
pdf_document = add_annotations_to_pdf(image, pdf_name, slctd_clm, columns_types_v)
|
| 220 |
+
page=pdf_document[0]
|
| 221 |
+
pix = page.get_pixmap() # render page to an image
|
| 222 |
+
pl=Image.frombytes('RGB', [pix.width,pix.height],pix.samples)
|
| 223 |
+
img=np.array(pl)
|
| 224 |
+
annotatedimg = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|
| 225 |
+
|
| 226 |
+
legend = legend.fillna(' ')
|
| 227 |
+
gc,spreadsheet_service,spreadsheetId, spreadsheet_url , namepathArr=google_sheet_Legend.legendGoogleSheets(df_doors , pdf_name,pdfpath)
|
| 228 |
+
list1=pd.DataFrame(columns=['content', 'id', 'subject','color'])
|
| 229 |
+
for page in doc2:
|
| 230 |
+
for annot in page.annots():
|
| 231 |
+
annot_color = annot.colors
|
| 232 |
+
if annot_color is not None:
|
| 233 |
+
stroke_color = annot_color.get('stroke') # Border color
|
| 234 |
+
print('strokeee',stroke_color)
|
| 235 |
+
if stroke_color:
|
| 236 |
+
v='stroke'
|
| 237 |
+
list1.loc[len(list1)] =[annot.info['content'],annot.info['id'],annot.info['subject'],[255,0,0]]
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
print('list1',list1)
|
| 241 |
+
return annotatedimg, pdf_document , spreadsheet_url, list1, legend
|
| 242 |
|
| 243 |
'''def mainfun(plan):
|
| 244 |
texts_from_pdf = get_text_from_pdf(plan)
|