Marthee commited on
Commit
590ae13
·
1 Parent(s): 2555472

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -24,7 +24,7 @@ import colorsys
24
  from PIL import Image , ImageDraw, ImageFont , ImageColor
25
  import numpy as np
26
  import gradio as gr
27
- from pdf_annotate import PdfAnnotator, Location, Appearance ,Metadata
28
  import os
29
  from db import dropbox_upload_file
30
  from pathlib import Path
@@ -636,13 +636,13 @@ def FillDictionary(SimilarAreaDictionary,img,number,num1,num2,flag,finalColorArr
636
 
637
  # pip install pymupdf
638
 
639
- from pdf_annotate import PdfAnnotator, Location, Appearance
640
- ImgShape=img.shape
641
 
642
- # mirroredpdf=mirrorImg()
643
- apdf = PdfAnnotator('/content/drive/MyDrive/Colab Notebooks/Pile caps plans/13886-CRH-B2-FN-DR-S-21001.pdf')
644
 
645
- ratio2=apdf.get_size(0)[0] / ImgShape[1]
646
  # ratio1 = apdf.get_size(0)[1] / ImgShape[0]
647
  # print(ratio1,ratio2)
648
 
@@ -766,11 +766,11 @@ def drawAllContours(img,number,finalColorArray,num1,num2,flag):
766
  # print(index)
767
  cv2.drawContours(imgArea1, [contour], 0, (int(rgbcolor[2]), int(rgbcolor[1]), int(rgbcolor[0])), -1)
768
 
769
- apdf.add_annotation(
770
- 'polygon',
771
- Location(points=shape ,page=0),
772
- Appearance(stroke_color=(1, 0, 1), stroke_width=5,fill=(0.2,0.3,0.8),fill_transparency=0.5),
773
- )
774
  cv2.putText(imgtransparent1,'Area= '+str(areaa) + ' m', (x+50,y-10) ,cv2.FONT_HERSHEY_SIMPLEX, 0.6, (50, 50, 255), 2)
775
  areasinImage.append(areaa)
776
 
@@ -872,7 +872,7 @@ def drawAllContours(img,number,finalColorArray,num1,num2,flag):
872
  SimilarAreaDictionary.drop(['Rounded', 'Width','Height','R','G','B'], axis=1, inplace=True)
873
 
874
 
875
- apdf.write('b.pdf')
876
  # annotationsDraw
877
  return imgPerimeter1,image_new1,SimilarAreaDictionary
878
  # drawAllContours(img,0,[],1.11,25579,'area') #,[190,47,250] ,[47,251,255] ,[80,240,15],[253,163,40]
 
24
  from PIL import Image , ImageDraw, ImageFont , ImageColor
25
  import numpy as np
26
  import gradio as gr
27
+ # from pdf_annotate import PdfAnnotator, Location, Appearance ,Metadata
28
  import os
29
  from db import dropbox_upload_file
30
  from pathlib import Path
 
636
 
637
  # pip install pymupdf
638
 
639
+ # from pdf_annotate import PdfAnnotator, Location, Appearance
640
+ # ImgShape=img.shape
641
 
642
+ # # mirroredpdf=mirrorImg()
643
+ # apdf = PdfAnnotator('/content/drive/MyDrive/Colab Notebooks/Pile caps plans/13886-CRH-B2-FN-DR-S-21001.pdf')
644
 
645
+ # ratio2=apdf.get_size(0)[0] / ImgShape[1]
646
  # ratio1 = apdf.get_size(0)[1] / ImgShape[0]
647
  # print(ratio1,ratio2)
648
 
 
766
  # print(index)
767
  cv2.drawContours(imgArea1, [contour], 0, (int(rgbcolor[2]), int(rgbcolor[1]), int(rgbcolor[0])), -1)
768
 
769
+ # apdf.add_annotation(
770
+ # 'polygon',
771
+ # Location(points=shape ,page=0),
772
+ # Appearance(stroke_color=(1, 0, 1), stroke_width=5,fill=(0.2,0.3,0.8),fill_transparency=0.5),
773
+ # )
774
  cv2.putText(imgtransparent1,'Area= '+str(areaa) + ' m', (x+50,y-10) ,cv2.FONT_HERSHEY_SIMPLEX, 0.6, (50, 50, 255), 2)
775
  areasinImage.append(areaa)
776
 
 
872
  SimilarAreaDictionary.drop(['Rounded', 'Width','Height','R','G','B'], axis=1, inplace=True)
873
 
874
 
875
+ # apdf.write('b.pdf')
876
  # annotationsDraw
877
  return imgPerimeter1,image_new1,SimilarAreaDictionary
878
  # drawAllContours(img,0,[],1.11,25579,'area') #,[190,47,250] ,[47,251,255] ,[80,240,15],[253,163,40]