Skip to main content

A flexible and efficient cross process distributed edge computing engine.

Project description

edgehub

一款灵活高效的,跨进程分布式边缘计算引擎。

安装方式

pip3 install edgehub

使用示例

示例1

该示例由一个Master节点和两个Node节点组成。

Master负责消息传递,不负责运算。

两个Node,一个Node节点负责实时读入摄像头视频流,另一个Node节点负责展示前一个Node读到的视频流。

本示例需要安装python-opencv: pip3 install opencv-python

master.py

from edgehub import Master

if __name__ == '__main__':
    SERVER_IP = '127.0.0.1'
    SERVER_PROT = 9010
    m = Master("master", address=(SERVER_IP, SERVER_PROT), authkey=b'z', log_level="DEBUG")
    
    server = m.get_server()
    server.serve_forever()

node_cam_read.py

from edgehub import Node
import cv2


class CameraNode(Node):
    stream = Node
    camera_url = 1

    def before_run(self):
        self.stream = cv2.VideoCapture(self.camera_url)

    def on_queue_process(self, queue_name):
        (grabbed, frame) = self.stream.read()
        self.put(frame, queue_name)


if __name__ == '__main__':
    SERVER_IP = '127.0.0.1'
    SERVER_PROT = 9010
    n = CameraNode("cap_put", address=(SERVER_IP, SERVER_PROT), authkey=b'z')
    n.register_queue("cam")
    n.run()

node_cam_show.py

from edgehub import Node
import cv2


class CamGetNode(Node):
    def on_queue_process(self, queue_name):
        item = self.get(queue_name)
        cv2.imshow("queue_name", item)
        key = cv2.waitKey(1) & 0xFF
        if key == ord("q"):
            raise StopIteration()

        # 为了确保队列不积压 导致延迟递增  每次执行完后清空当前队列,这样每次处理时就会取到最新图片
        self.clear(queue_name)


if __name__ == '__main__':
    SERVER_IP = '127.0.0.1'
    SERVER_PROT = 9010
    n = CamGetNode(name="cam_get", address=(SERVER_IP, SERVER_PROT), authkey=b'z')
    n.register_queue("cam")
    n.run()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edgehub-0.0.4.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

edgehub-0.0.4-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file edgehub-0.0.4.tar.gz.

File metadata

  • Download URL: edgehub-0.0.4.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.23.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.4

File hashes

Hashes for edgehub-0.0.4.tar.gz
Algorithm Hash digest
SHA256 7b8392d310677237d2680d19093ff409e6819ca2e5dc76c06b89a5aa0c264dc1
MD5 f2f798abb5cd68a304ea4fb304ddfaa8
BLAKE2b-256 a8c93c2c8de8700a8001033e22cdf9e88f2af7568720e014f189987ebc2ff529

See more details on using hashes here.

File details

Details for the file edgehub-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: edgehub-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.23.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.4

File hashes

Hashes for edgehub-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 982203f654852c1d3b63d419e2f93cd9aaaf50d147c82fe2c6c8c9d3fd01ecbc
MD5 2568dbdf9e28ce4ca3f60ca19282c2aa
BLAKE2b-256 00fb214a87ed37ba024b6cd6f9f3d67de5235f2014109cc3d673e6ef52b93626

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page