大疆社区

标题: 机甲大师SDK编程怎样同时启动多个识别功能? [打印本页]

作者: godX    时间: 11-4 14:24
标题: 机甲大师SDK编程怎样同时启动多个识别功能?
[{"type":1,"imgsrc":"","key":"first-text","url":"","desc":""},{"type":2,"multi_size":{"small":"https://bbs.djicdn.com/data/attachment/forum/202411/04/9825sXYB54KssksdbzvH.jpg@!550","large":"https://bbs.djicdn.com/data/attachment/forum/202411/04/9825sXYB54KssksdbzvH.jpg@!1920","extra_large":"https://bbs.djicdn.com/data/attachment/forum/202411/04/9825sXYB54KssksdbzvH.jpg@!2560","wide_450_360":"https://bbs.djicdn.com/data/attachment/forum/202411/04/9825sXYB54KssksdbzvH.jpg@!450x360","medium":"https://bbs.djicdn.com/data/attachment/forum/202411/04/9825sXYB54KssksdbzvH.jpg@!1200","square_360_360":"https://bbs.djicdn.com/data/attachment/forum/202411/04/9825sXYB54KssksdbzvH.jpg@!360x360","standard_640_360":"https://bbs.djicdn.com/data/attachment/forum/202411/04/9825sXYB54KssksdbzvH.jpg@!640x360"},"percent":1,"key":"p47q73xq","url":"https://bbs.djicdn.com/data/attachment/forum/202411/04/9825sXYB54KssksdbzvH.jpg"},{"type":1,"key":"ncga6o9e","desc":"代码如下:"},{"type":1,"key":"od70x0p7","desc":"from robomaster import robot\nline = []\n# 重编callback回调函数\ndef on_detect_line(line_info):\n    number = len(line_info)\n    line.clear()\n    line_type = line_info[0]\n    # print('line_type', line_type)\n    for i in range(1, number):\n        x, y, ceta, c = line_info\n        line.append([x, y, ceta, c])\n\npersons = []\ndef on_detect_person(person_info):\n    number = len(person_info)\n    persons.clear()\n    for i in range(0, number):\n        x, y, w, h = person_info\n        persons.append([x, y, w, h])\n        # print(\"person: x:{0}, y:{1}, w:{2}, h:{3}\".format(x, y, w, h))\n\n\nif __name__ == '__main__':\n    # 初始化\n    ep_robot = robot.Robot()\n    # 直连模式\n    ep_robot.initialize(conn_type=\"ap\")\n    # 机器人版本\n    ep_version = ep_robot.get_version()\n    print(\"Robot Version: {0}\".format(ep_version))\n    # 云台跟随底盘\n    ep_robot.set_robot_mode(mode=robot.CHASSIS_LEAD)\n    # 云台向下旋转10度\n    ep_gimbal = ep_robot.gimbal\n    ep_gimbal.moveto(pitch=0, yaw=0).wait_for_completed()\n    ep_gimbal.move(pitch=-10, yaw=0).wait_for_completed()\n    # 初始化麦轮\n    ep_chassis = ep_robot.chassis\n    # 启动视觉识别\n    ep_vision = ep_robot.vision\n    # 启动摄像头\n    ep_camera = ep_robot.camera\n    ep_camera.start_video_stream(display=False)\n    # 启动线识别\n    ep_vision.sub_detect_info(name=\"line\", color=\"blue\", callback=on_detect_line)\n    # 启动人识别\n    ep_vision.sub_detect_info(name=\"person\", callback=on_detect_person)\n    # threading1 = threading.Thread(target=ep_vision.sub_detect_info, args=('line', 'blue', on_detect_line))\n    # threading1.start()\n    # time.sleep(2)\n    # print(line)\n    # threading2 = threading.Thread(target=ep_vision.sub_detect_info, args=('person', '', on_detect_person))\n    # threading2.start()\n    # time.sleep(2)\n\n    # 这里不管启动不启动多线程,后边都只能输出一个数据。而且启动行人识别后,机器还总有提示声音(怎么去除)。哪位大佬可以帮帮我,怎样在SDK中同时启用多个识别功能啊??非常感谢!!  在模块编程里面转换出来的python代码也不能直接用,有没有API代码转换SDK代码的教程?\n    while True:\n        print(persons)\n        print(line)"},{"type":1,"key":"55gq8ike","desc":""},{"type":1,"key":"5qdb383k","desc":""},{"type":1,"key":"t860jisi","desc":""}]




欢迎光临 大疆社区 (https://bbs.dji.com/) Powered by Discuz! X3.2