c++ - Random frame of Video AR Drone is empty and then can't get a new image with OpenCV -
i'm doing simple program print ar.drone video during flight on computer.
it works during few seconds , then, randomly, program abort because frame empty. decided test it, now, when frame empty, following frames empty too.
here simple code :
int main(void) { cv::videocapture cap; cv::mat image; if (!cap.open("tcp://192.168.1.1:5555")) { printf("ar.drone error connect\n"); return -1; } takeoff(); while (42) { cap >> image; if (!image.empty()) { cv::imshow("ar.drone", image); std::cout << "ok" << std::endl; } else std::cout << "error" << std::endl; cv::waitkey(1); } return 0; }
my output :
>ok >ok >[...] >ok >err >err >err
but should :
>ok >ok >[...] >ok >err // okay got error ? ... >ok // ... give new frame :) >ok
why fail forever?
if don't protect error “opencv error: bad flag” , abort. connection on ar.drone tcp, can't slow down waitkey...
any idea?
i got same issue when wanted stable video stream ar.drone 2.0 took time, realized frame missing because drone consider connection lost after 2 seconds without @ command. if open stream , nothing more fine (the stream good), after send @ command after 2 second drone disconnect. need send example hovering command drone if no other command sent keep connection alive.
Comments
Post a Comment