# setup_debugging() poller = Poller() thread = Thread(target = poller.run) thread.start() device_uuid = '60874e62-e7fb-4bb6-bfbd-f0625230e791' # uuid.uuid4() local_ip_address = get_network_interface_ip_address() ups = check_ups() http_server = UPNPHTTPServer(8088, friendly_name=ups['ups.model'], manufacturer=ups['ups.mfr'], model_description=ups['ups.model'] + ' ' + ups.get('ups.serial',''), model_name=ups['ups.model'], model_number=ups['ups.productid'], serial_number="UPS1234", uuid=device_uuid, presentation_url="http://{}:8088/".format(local_ip_address)) http_server.start() ssdp = SSDPServer() ssdp.register('local', 'uuid:{}::upnp:rootdevice'.format(device_uuid), 'urn:schemas-upnp-org:device:UPS:1', 'http://{}:8088/ups.xml'.format(local_ip_address)) ssdp.run()
if (2 not in interface) or (len(interface[2]) == 0): logger.warning('Could not find IP of interface %s. Sleeping.' % (interface, )) sleep(60) continue return interface[2][0]['addr'] device_uuid = uuid.uuid4() local_ip_address = get_network_interface_ip_address(NETWORK_INTERFACE) http_server = UPNPHTTPServer( 8088, friendly_name="MPV Renderer", manufacturer="solarkraft", manufacturer_url='http://github.com/solarkraft/mpv-upnp/', model_description='Renders through MPV. ', model_name="MPV", model_number="1", model_url="http://github.com/solarkraft/mpv-upnp/", serial_number="1", uuid=device_uuid, presentation_url="http://{}:5000/".format(local_ip_address)) http_server.start() ssdp = SSDPServer() ssdp.register('local', 'uuid:{}::upnp:rootdevice'.format(device_uuid), 'upnp:rootdevice', 'http://{}:8088/device.xml'.format(local_ip_address)) ssdp.run()
logger.warning('Could not find IP of interface %s. Sleeping.' % (interface, )) sleep(60) continue return interface[2][0]['addr'] device_uuid = uuid.uuid4() local_ip_address = get_network_interface_ip_address(NETWORK_INTERFACE) http_server = UPNPHTTPServer( 8088, friendly_name="Hyunwoo", manufacturer="Boucherie numérique SAS", manufacturer_url='http://www.boucherie.example.com/', model_description='Jambon Appliance 3000', model_name="Jambon", model_number="3000", model_url="http://www.boucherie.example.com/en/prducts/jambon-3000/", serial_number="JBN425133", uuid=device_uuid, presentation_url="http://{}:5000/".format(local_ip_address)) http_server.start() ssdp = SSDPServer() ssdp.register( 'local', 'uuid:{}::urn:lge-com:service:webos-whiteboard:1'.format(device_uuid), 'urn:lge-com:service:webos-whiteboard:1', 'http://{}:8088/jambon-3000.xml'.format(local_ip_address)) ssdp.run()
interface = ni.ifaddresses(interface) if (2 not in interface) or (len(interface[2]) == 0): logger.warning('Could not find IP of interface %s. Sleeping.' % (interface, )) sleep(60) continue return interface[2][0]['addr'] if __name__ == '__main__': device_uuid = uuid.uuid4() local_ip_address = get_network_interface_ip_address(NETWORK_INTERFACE) http_server = UPNPHTTPServer( 8088, friendly_name="PartyTimeServer", manufacturer="AMI-PartyTime", manufacturer_url='https://ami-2018.github.io/Party-Time/index.html', model_description='PartyTime Server', model_name="PartyTimeServer", ) http_server.start() ssdp = SSDPServer() ssdp.register ssdp.register('local', 'uuid:{}::upnp:rootdevice'.format(device_uuid), 'upnp:rootdevice', 'http://{}:8088/partyTime.xml'.format(local_ip_address)) ssdp.run()
def main(): ap = argparse.ArgumentParser() ap.add_argument( '-c', '--conf', type=str, default="conf.json", help= 'Path to the JSON configuration file, default is conf.json in the program folder' ) arg = vars(ap.parse_args()) try: conf = json.load(open(arg['conf'])) except FileNotFoundError as error: print(error) return server_port = conf['upnp_port'] device_uuid = uuid.uuid4() sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.connect(('239.255.255.250', 1900)) local_ip = sock.getsockname()[0] sock.close() http_server = UPNPHTTPServer( server_port, uuid=device_uuid, presentation_url='http://{}/'.format(local_ip), server_PSK=conf['server_PSK']) http_server.start() ssdp = SSDPServer(device_uuid, local_ip, server_port) ssdp.start() stream = VideoStream(conf['source'], conf['resolution'], conf['fps']).start() time.sleep(conf['camera_warmup_time']) background = None motion_counter = 0 kernel = np.ones((3, 3), np.uint8) prev_status = "No motion" while True: frame = stream.read() timestamp = datetime.datetime.now() status = "No motion" motion = False frame = imutils.resize(frame, width=500) gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) gray = cv2.GaussianBlur(gray, (21, 21), 0) if background is None: background = np.float32(gray) continue cv2.accumulateWeighted(gray, background, 0.5) frame_delta = cv2.absdiff(gray, cv2.convertScaleAbs(background)) thresh = cv2.threshold(frame_delta, conf['delta_thresh'], 255, cv2.THRESH_BINARY)[1] thresh = cv2.dilate(thresh, kernel, iterations=2) contours = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) contours = contours[0] if imutils.is_cv2() else contours[1] for c in contours: if cv2.contourArea(c) < conf['min_area']: continue (x, y, w, h) = cv2.boundingRect(c) cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2) motion = True ts = timestamp.strftime('%A %d %B %Y %I:%M:%S%p') cv2.putText(frame, '{} detected'.format(status), (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2) cv2.putText(frame, ts, (10, frame.shape[0] - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.35, (0, 0, 255), 1) if motion: motion_counter += 1 if motion_counter >= conf['min_motion_frames']: status = "Motion" else: motion_counter = 0 if status != prev_status: http_server.server.update_status(status) prev_status = status
if network_interface is None: return "" interface = ni.ifaddresses(network_interface) if (2 not in interface) or (len(interface[2]) == 0): return "" return interface[2][0]['addr'] device_uuid = uuid.uuid4() local_ip_address = get_network_interface_ip_address() http_server = UPNPHTTPServer( 8088, friendly_name="NXE 400", manufacturer="Nexa3D", manufacturer_url='https://nexa3d.com/', model_description='NXE 400 3D Printer', model_name="NXE", model_number="400", model_url="https://nexa3d.com/3d-printers/", serial_number="1234", uuid=device_uuid, presentation_url="http://{}:5000/".format(local_ip_address)) http_server.start() ssdp = SSDPServer() ssdp.register('local', 'uuid:{}::upnp:rootdevice'.format(device_uuid), 'upnp:rootdevice', 'http://{}:8088/nxe-400.xml'.format(local_ip_address)) ssdp.run()