def UAVScan(RGDiff=75, FramesCount=5): """ Function to detect fire using UAV thermal camera based on thresholding image's intesity :params RGDiff: FramesCount: :return Detected: True if fire detected latQuad, longQuad : Coordinates of fire detection """ cam_quad = cv2.VideoCapture("rtmp://127.0.0.1:1935/live/quad") cntDetected = 0 while 1: retQuad, frmQuad = cam_quad.read() if not retQuad: continue qq = (np.sum((frmQuad[:, :, 2].astype(int) - frmQuad[:, :, 1].astype(int)) > RGDiff)) if qq: cntDetected += 1 if cntDetected > FramesCount: quadCoords = alarmRequests.getQuadCoords() latQuad = float(quadCoords[0]) longQuad = float(quadCoords[1]) #absAltQuad = float(quadCoords[2]) cv2.imwrite('/home/theasis/software/static_cam/fireFrame.jpg', frmQuad) print("Validated...") return True, latQuad, longQuad cam_quad.release() # if break while loop return False, -1, -1
def UAVScan(): cam_quad = cv.VideoCapture("rtmp://127.0.0.1:1935/live/quad") cntDetected = 0 while 1: retQuad, frmQuad = cam_quad.read() qq = (np.sum((frmQuad[:, :, 2].astype(int) - frmQuad[:, :, 1].astype(int)) > 75)) if qq: cntDetected += 1 if cntDetected > 0: quadCoords = alarmRequests.getQuadCoords() latQuad = float(quadCoords[0]) longQuad = float(quadCoords[1]) #absAltQuad = float(quadCoords[2]) cv.imwrite('/home/theasis/software/static_cam/fireFrame.jpg', frmQuad) print("Validated...") return True, latQuad, longQuad cam_quad.release() # if break while loop return False, -1, -1
def checkIfDroneIsHome(): droneHomeCoords = [ 38.123456, 21.567890] #isDroneHome = True droneCurrentCoords = alarmRequests.getQuadCoords() droneCurrentCoords[0] = float(droneCurrentCoords[0]) droneCurrentCoords[1] = float(droneCurrentCoords[1]) droneCurrentCoords[2] = float(droneCurrentCoords[2]) if np.abs(droneHomeCoords[0] - droneCurrentCoords[0])<0.00001 and np.abs(droneHomeCoords[1] - droneCurrentCoords[1])<0.00001: isDroneHome = True else: isDroneHome = False return isDroneHome