Marthee commited on
Commit
d73765e
·
1 Parent(s): 8c48588

Update pilecaps_adr.py

Browse files
Files changed (1) hide show
  1. pilecaps_adr.py +12 -33
pilecaps_adr.py CHANGED
@@ -681,23 +681,12 @@ def drawAllContours(img,number,finalColorArray,ratioarea,ratioperim,flag , path,
681
  green2=allpreSteps(img)
682
  doc = fitz.open('dropbox_plans/1.0/'+path)
683
  page = doc[0]
684
- # page.set_rotation(270)
685
  pix=page.get_pixmap()
686
- print('SHAPPEE',img.shape)
687
- # if img.shape[0] > img.shape[1]:
688
- ratio = pix.width / img.shape[1]
689
- # ratio0 = img.shape[1] * pix.width
690
- # ratio= pix.height /img.shape[0]
691
-
692
  areasinImage=[]
693
- totaldf=pd.DataFrame()
694
  imgArea1= img.copy()
695
  imgPerimeter1=img.copy()
696
  imgtransparent1=img.copy()
697
-
698
- Blackmask = np.zeros(img.shape[:2], dtype="uint8")
699
-
700
- invertedmask=img
701
  allpoints=[]
702
 
703
  if number ==220:
@@ -750,18 +739,12 @@ def drawAllContours(img,number,finalColorArray,ratioarea,ratioperim,flag , path,
750
  area1 = cv2.contourArea(approx)
751
  approx = cv2.approxPolyDP(contourss[contour][0], 0.01 * perimeter, True) #0.0009
752
  perimeter1 = cv2.arcLength(approx, True)
753
-
754
  for point in approx:
755
- x1, y1 = point[0]
756
-
757
- shape.append([int(x1*ratio),int(y1*ratio)])
758
- # shape= np.fliplr(shape)
759
-
760
- # cv2.circle(imgArea1, (x1, y1), 4, (0, 255, 0), -1)
761
- allpoints.append(shape)
762
- # print(x,y,width,height)
763
- # print(allpoints)
764
- # print(shape)
765
  if (angleR != 90.0 and angleR != -90.0 and angleR != 0.0 and angleR != -0.0 ): #inclined b ay degree
766
  width=widthR
767
  height=heightR
@@ -860,16 +843,12 @@ def drawAllContours(img,number,finalColorArray,ratioarea,ratioperim,flag , path,
860
  area1 = cv2.contourArea(approxa)
861
  approx = cv2.approxPolyDP(contourss[contour][0], 0.01 * perimeter, True) #0.0009
862
  perimeter1 = cv2.arcLength(approx, True)
863
- M = cv2.moments(contourssA[contour][0])
864
- if M['m00'] != 0:
865
- cx = int(M['m10']/M['m00'])
866
- cy = int(M['m01']/M['m00'])
867
-
868
- for point in approxa:
869
- x1, y1 = point[0]
870
-
871
- shape.append([int(x1*ratio),int(y1*ratio)])
872
- # shape=rotate_polygon(shape, 90)
873
  if (angleR != 90.0 and angleR != -90.0 and angleR != 0.0 and angleR != -0.0 ): #inclined b ay degree
874
  width=widthR
875
  height=heightR
 
681
  green2=allpreSteps(img)
682
  doc = fitz.open('dropbox_plans/1.0/'+path)
683
  page = doc[0]
 
684
  pix=page.get_pixmap()
685
+ ratio = pix.width / img.shape[1]
 
 
 
 
 
686
  areasinImage=[]
 
687
  imgArea1= img.copy()
688
  imgPerimeter1=img.copy()
689
  imgtransparent1=img.copy()
 
 
 
 
690
  allpoints=[]
691
 
692
  if number ==220:
 
739
  area1 = cv2.contourArea(approx)
740
  approx = cv2.approxPolyDP(contourss[contour][0], 0.01 * perimeter, True) #0.0009
741
  perimeter1 = cv2.arcLength(approx, True)
 
742
  for point in approx:
743
+ x1, y1 = point[0]
744
+ p1 = fitz.Point(x1*ratio,y1*ratio)
745
+ p1=p1*page.derotation_matrix
746
+ shape.append([p1[0],p1[1]])
747
+
 
 
 
 
 
748
  if (angleR != 90.0 and angleR != -90.0 and angleR != 0.0 and angleR != -0.0 ): #inclined b ay degree
749
  width=widthR
750
  height=heightR
 
843
  area1 = cv2.contourArea(approxa)
844
  approx = cv2.approxPolyDP(contourss[contour][0], 0.01 * perimeter, True) #0.0009
845
  perimeter1 = cv2.arcLength(approx, True)
846
+ for point in approx:
847
+ x1, y1 = point[0]
848
+ p1 = fitz.Point(x1*ratio,y1*ratio)
849
+ p1=p1*page.derotation_matrix
850
+ shape.append([p1[0],p1[1]])
851
+
 
 
 
 
852
  if (angleR != 90.0 and angleR != -90.0 and angleR != 0.0 and angleR != -0.0 ): #inclined b ay degree
853
  width=widthR
854
  height=heightR