How to control my Drone with OpenCV?

  • @robolink_arnold About the delay , this is my code. Today I try the code, it happened. Maybe 1/10 , the delay above 2000ms.
    from time import sleep
    from petrone.drone import *
    from petrone.protocol import *
    from petrone.system import *
    import cv2

    def eventUpdateInformation(data):
    print("eventUpdateInformation() / {0} / {1} / {2} / Ver:{3} / 20{4:02}.{5}.{6}".format(data.modeUpdate,
    data.imageType, data.version,
    data.year, data.month,

    cap = cv2.VideoCapture('rtsp://')
    #cap = cv2.VideoCapture(0)
    fourcc = cv2.VideoWriter_fourcc(*'XVID')
    out = cv2.VideoWriter('outputVideo.avi',fourcc, 20.0, (640,480))

    drone = Drone(True, True, True, True, True)



    while (cap.isOpened()):

    ret, frame =
    cv2.imshow('frame', frame)
    key = cv2.waitKey(1) & 0xFF
    if key == ord("W"):
        drone.sendControl(0, 0, 0, 70)
        print("T 60")
    if key == ord("S"):
        drone.sendControl(0, 0, 0, -70)
        print("T -60")
    if key == ord("A"):
        drone.sendControl(0, 0, 50, 0)
        print("Y 100")
    if key == ord("D"):
        drone.sendControl(0, 0, -50, 0)
        print("Y -100")
    if key == ord("i"):
        drone.sendControl(0, 50, 0, 0)
        print("P 100")
    if key == ord("k"):
        drone.sendControl(0, -50, 0, 0)
        print("P -100")
    if key == ord("j"):
        drone.sendControl(-50, 0, 0, 0)
        print("R 100")
    if key == ord("l"):
        drone.sendControl(50, 0, 0, 0)
        print("R -100")
    if key == ord("z"):
    if key == ord("q"):
    if key == ord("x"):

    print("Disconnecting device.")



  • I install drivers you say. About the delay, maybe it happened when I use pycharm and anaconda in the same time. I want to know how to do about this. I mean control the Drone with OpenCV. Is it Opencv image recognition?
    About this code,I can't save the video I catch with CoDrone, but computer camera can.0_1532325151639_code.png

  • administrators

    @smilebean So 4000ms and 3000ms delay is not normal, what code are you running? Do you have the BLE module driver installed on your computer? the SiLabs Driver? Also can you post the code you are trying to run here? Thank you!

  • The FPV transfer to PC have delay 3000~4000ms. Is it normal?
    I can use the Key_Control example thank you!
    Can you show me how to use OpenCV to control CoDrone?

  • @robolink_arnold or @robolink_whoseop, can you take a look at this? Looks like we haven't gotten back to @smilebean yet.

  • When I use pycharm, I have the same problem(Key_Control).0_1530588853043_problem.png
    And the FPV transfer to PC have delay 3000~4000ms. Is it normal?

  • This post is deleted!

  • administrators

    @smilebean I can explain everything over the video call. I will be on the website let me know if the site works for you. It is best if you use a google chrome browser.

  • When I create a project , how not to use the virtual env of python?
    We date on monday 11pm in Taiwan.

  • administrators

    Monday would be best I am free at 8am-10am Pacific Time which will be around 11pm in Taiwan @smilebean Just have pycharm setup and python 3.6. Try not to use the virtual env of python. Also have the windows computer and the IDE ready. Let me know if this is possible.

  • What do I need to prepare before video call? I trying to use pycharm now .If I have any question , I will ask, thank you!

  • I live in Taiwan (GMT+8). Can we video call next week? Monday ,Tuesday or Friday(7/2,7/3 or 7/6) . And I can cooperate with you at any time , just give me a time, thank you!

  • administrators

    @smilebean Please let me know when you are available for a video call I will be able to guide you through a lot of the content.

  • administrators

    Hello @smilebean I highly recommend setting up exactly as we did, use PyCharm as we will be able to help you out with your issues. Please follow the guide for PyCharm. Also that error appears when the CoDrone BLE module is not connected.

  • About fpv_videosave ,when I press "Q", my program(video frame) will crash. And I can't open the video I save.
    About keyControl,I can't connect my drone . 0_1529633491930_problem.png

    And can you give some example about CES video, or give me some hint to do that?
    Thank you for help.

  • @robolink_wes Thank you! I will try that by myself. If I need help, I will ask questions.
    It is exam week,so I am busy. Thank you for help!

  • @robolink_arnold I think @smilebean is referring to the CES video he linked in the original post. We'd be able to walk you through how we did those OpenCV demos in a video call, if you're interested. It's a project we're planning to work on eventually, but it's currently on hold, so documentation is still minimal.

    Would you like to do a call?

  • administrators

    Hello @smilebean which videos are you talking about?

  • Thanks. Can I learn about openCV from same videos?

  • administrators

    Hello @smilebean here are some of the sample programs we made. If you want and can we should set up a video call to guide you on using CoDrone with OpenCV.

Log in to reply

Looks like your connection to Robolink community was lost, please wait while we try to reconnect.