0

使用树莓派和 python 流服务器的代码(在此处描述:http: //picamera.readthedocs.io/en/latest/recipes2.html#web-streaming),我构建了一个嵌套框来观察鸟类。由于我不想每天检查服务器,直到鸟儿搬进来,我想使用运动检测(我计划使用此处描述的代码的修改:https ://www.pyimagesearch.com/2015/06 /01/home-surveillance-and-motion-detection-with-the-raspberry-pi-python-and-opencv/) 一旦鸟儿安顿下来就会收到通知。但是,我不明白在什么时候以及如何将此代码包含到流服务器中,以便它像流服务器一样在后台运行。如果我在 server.serve_forever() 之前包含运动检测代码的循环,流媒体服务器将不会运行,如果我在之后添加它,运动检测循环将永远不会启动:

    try:
    address = (host_name, host_port)
    server = StreamingServer(address, StreamingHandler)
    # motion detection loop here --> server.serve_forever() will never be reached
    server.serve_forever()
    # motion detection loop here --> motion detection loop will never start

我怎样才能同时运行两者?我想这可能适用于线程,......不知何故?

谢谢!

4

0 回答 0