示例#1
0
def areaMap(m):
  # Calculate the area in MAP image of the entry mask
  aux = m[:,:,1].copy()
  c = cv2.findContours(aux,cv2.RETR_EXTERNAL,2)[1]
  # Load list as array and remove 1-dim entries
  ca = np.squeeze(c)
  pMap = []
  for i in range(len(ca)):
    xm, ym = np.int32(vca2map(ca[i,0],ca[i,1]))
    pMap.append((xm,ym))
  areapx2 = cv2.contourArea(np.asarray(pMap))
  aream2 = areapx2 / 0.8**2
  return aream2
示例#2
0
def add_point(event,x,y,flags,param):
  global pVCA, pMap
  # Left double-click to add a point to list 
  if event == cv2.EVENT_LBUTTONDBLCLK:
    pVCA.append((x,y))
    # Map coordinate from the vca image to the map
    xm, ym = np.int32(vca2map(x,y))
    pMap.append((xm,ym))
    # Draw lines or not
    if len(pVCA) > 1:
      cv2.line(frame,pVCA[-2],pVCA[-1],(0,255,0),1)
      cv2.line(frMap,pMap[-2],pMap[-1],(0,255,0),1)
    # Draw circles
    cv2.circle(frame,(x,y),1,(0,0,255),-1)
    # Calculate real area
    if len(pVCA)>3:
      areapx2 = cv2.contourArea(np.asarray(pMap))
      aream2 = areapx2 / 0.8**2
      print aream2