• deepstream-测试发送kafka


    一 kafka 环境搭建

    kafka官网的安装说明:https://kafka.apache.org/quickstart,具体步骤如下:
    1. 安装jdk
    $ apt-get update  && apt-get install openjdk-8-jdk -y
    2. 安装kafka
    https://www.apache.org/dyn/closer.cgi?path=/kafka/3.3.1/kafka_2.13-3.3.1.tgz
    $ tar -xzf kafka_2.13-3.3.1.tgz
    $ cd kafka_2.13-3.3.1

    3 开启两个服务器
    # Start the ZooKeeper service
    $ ./bin/zookeeper-server-start.sh config/zookeeper.properties
    # start a new teminal, Start the Kafka broker service
    $ ./bin/kafka-server-start.sh config/server.properties


    4. 测试kafka
    4.1 创建主题,这条命令只用执行一次,执行完会自己退出。
    $ ./bin/kafka-topics.sh --create --topic deepstream --bootstrap-server localhost:9092

    4.2 开启消费者
    $ ./bin/kafka-console-consumer.sh --topic deepstream --from-beginning --bootstrap-server localhost:9092
    #按ctrl+c退出

    deepstream工具测试

     deepstream的安装和介绍,详见其官网是​​​​​​Quickstart Guide — DeepStream 6.1.1 Release documentation

    到/opt/nvidia/deepstream/deepstream/sources/libs/kafka_protocol_adaptor下,修改test_kafka_proto_sync.cpp, 如下将topic1改成deepsream。

    1.    //Subscribe to topics
    2.    const char *topics[] = {"deepstream", "topic2"};
    3.        if (msgapi_send_ptr(conn_handle, (char *)"deepstream", (const uint8_t*) SEND_MSG, \

    然后安装编译器apt-get install protobuf-compiler, 执行编译,make -f Makefile.test, 然后执行./test_kafka_proto_sync,发现开启消费者的窗口能收到数据。

    默认连的是这个地址#define KAFKA_CONNECT_STR "localhost;9092"。

    打印如下:

    ./test_kafka_proto_sync
    Refer to nvds log file for log output
    Adapter protocol=KAFKA , version=2.0
    connection signature queried=
    send [0] completed
    send [1] completed
    send [2] completed
    send [3] completed
    send [4] completed
    Disconnecting in 3 secs

    Python deepstream-test4测试

    python3 deepstream_test_4.py -i /opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.h264 -p /opt/nvidia/deepstream/deepstream/lib/libnvds_kafka_proto.so   --conn-str="localhost;9092" -t deepstream -s 0 --no-display

    C++ deepstream-test4测试

    以deepstream-test4为例,更改配置文件,填入正确的conn-str和topic。

    1. msgbroker:
    2.   proto-lib: /opt/nvidia/deepstream/deepstream/lib/libnvds_kafka_proto.so
    3.   conn-str: localhost;9092
    4.   topic: deepstream

     这里不要写成:con-str:;<9092>,要去掉括号。然后执行./deepstream-test4-app  dstest4_config.yml,发现开启消费者的窗口能收到数据,如下所示:

     日志:

    PAYLOAD_DEEPSTREAM级别

    ./bin/kafka-console-consumer.sh --topic deepstream --from-beginning --bootstrap-server localhost:9092
    {
      "messageid" : "26ed04be-1f78-44b3-9a9b-73e69a2c4baf",
      "mdsversion" : "1.0",
      "@timestamp" : "2022-11-17T15:00:21.139Z",
      "place" : {
        "id" : "1",
        "name" : "XYZ",
        "type" : "garage",
        "location" : {
          "lat" : 30.32,
          "lon" : -40.549999999999997,
          "alt" : 100.0
        },
        "aisle" : {
          "id" : "walsh",
          "name" : "lane1",
         

  • 相关阅读:
    推荐系统-排序层-模型:Wide&Deep
    相关性质和条件变量-ReentrantLock详解(2)-AQS-并发编程(Java)
    学了MVC,第一个项目该怎么做?(一)
    hive3
    把字符串转换成整数[考虑溢出]
    【JVM详解&JVM优化】JVM垃圾回收机制
    Docker Compose
    Qt应用开发(基础篇)——视图基类 QAbstractItemView
    使用Torchmetrics快速进行验证指标的计算
    MacOS - Cpolar 在 Mac 上如何使用?
  • 原文地址:https://blog.csdn.net/evsqiezi/article/details/127809277