コード例 #1
0
            self.send_header('X-Array-Width', msg.array.shape[1])
            self.send_header('X-Array-Height', msg.array.shape[0])
            self.send_header('X-Array-Channels', 1)
            self.send_header('X-Array-Type', msg.array.dtype)

            self.end_headers()

            self.wfile.write(msg.array[:, :, 0].tobytes())

if __name__ == '__main__':
    """ Parse commandline arguments """
    parser = argparse.ArgumentParser(description='Capture bayer frames and serve them over HTTP')
    parser.add_argument('--address', type=str, help='Binding address for the HTTP server', default='0.0.0.0')
    parser.add_argument('--port', type=int, help='Port the HTTP server will listen on', default=3000)

    parser.add_argument('imagefile', type=str, help='Image file the camserver will server')

    args = parser.parse_args()

    """ Configure logging """
    logging.basicConfig(level=0, format='%(asctime)-15s [%(levelname)s] %(message)s')
    logging.info("Starting CamServer")

    """ Run the server """
    server_address = (args.address, args.port)
    httpd = HTTPServer(server_address, CamServer_RequestHandler)
    httpd.capture_handler = CamServer_CaptureHandler(args.imagefile)
    logging.info("Serving on http://{}:{}".format(server_address[0], server_address[1]))

    httpd.serve_forever()
コード例 #2
0
ファイル: camserver.py プロジェクト: holmos-frs/camera-server
            self.wfile.write(msg[:, :, 0].tobytes())


if __name__ == '__main__':
    """ Parse commandline arguments """
    parser = argparse.ArgumentParser(
        description='Capture bayer frames and serve them over HTTP')
    parser.add_argument('--address',
                        type=str,
                        help='Binding address for the HTTP server',
                        default='0.0.0.0')
    parser.add_argument('--port',
                        type=int,
                        help='Port the HTTP server will listen on',
                        default=3000)

    args = parser.parse_args()
    """ Configure logging """
    logging.basicConfig(level=0,
                        format='%(asctime)-15s [%(levelname)s] %(message)s')
    logging.info("Starting CamServer")
    """ Run the server """
    server_address = (args.address, args.port)
    httpd = HTTPServer(server_address, CamServer_RequestHandler)
    httpd.capture_handler = CamServer_CaptureHandler()
    logging.info("Serving on http://{}:{}".format(server_address[0],
                                                  server_address[1]))

    httpd.serve_forever()