这篇教程C++ ARDrone类代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ARDrone类的典型用法代码示例。如果您正苦于以下问题:C++ ARDrone类的具体用法?C++ ARDrone怎么用?C++ ARDrone使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。 在下文中一共展示了ARDrone类的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainint main(int argc, char *argv[]) { ARDrone ardrone; if(!ardrone.open()) { std::cerr << "Error: Failed to initialization of ARDrone." << std::endl; return 1; } return 0;}
开发者ID:hiroyky,项目名称:vrdrone,代码行数:11,
示例2: main// --------------------------------------------------------------------------// main(Number of arguments, Argument values)// Description : This is the entry point of the program.// Return value : SUCCESS:0 ERROR:-1// --------------------------------------------------------------------------int main(int argc, char *argv[]){ // AR.Drone class ARDrone ardrone; // Initialize if (!ardrone.open()) { std::cout << "Failed to initialize." << std::endl; return -1; } // Image of AR.Drone's camera cv::Mat image = ardrone.getImage(); // Video name std::time_t t = std::time(NULL); std::tm *local = std::localtime(&t); std::ostringstream stream; stream << 1900 + local->tm_year << "-" << 1 + local->tm_mon << "-" << local->tm_mday << "-" << local->tm_hour << "-" << local->tm_min << "-" << local->tm_sec << ".avi"; // Create a video writer cv::VideoWriter writer(stream.str(), cv::VideoWriter::fourcc('D', 'I', 'B', ' '), 30, cv::Size(image.cols, image.rows)); // Main loop while (1) { // Key input int key = cv::waitKey(33); if (key == 0x1b) break; // Get an image image = ardrone.getImage(); // Write a frame writer << image; // Display the image imshow("camera", image); } // Output the video writer.release(); // See you ardrone.close(); return 0;}
开发者ID:B12040331,项目名称:CVDrone,代码行数:52,
示例3: main// --------------------------------------------------------------------------// main(Number of arguments, Value of arguments)// Description : This is the main function.// Return value : SUCCESS:0 ERROR:-1// --------------------------------------------------------------------------int main(int argc, char **argv){ // AR.Drone class ARDrone ardrone; // Initialize if (!ardrone.open()) { printf("Failed to initialize./n"); return -1; } // Recording flag int rec = 0; printf("Press 'R' to start/stop recording."); // Main loop while (!GetAsyncKeyState(VK_ESCAPE)) { // Update if (!ardrone.update()) break; // Get an image IplImage *image = ardrone.getImage(); // Video recording start / stop if (KEY_PUSH('R')) { if (rec) { ardrone.stopVideoRecord(); rec = 0; } else { ardrone.startVideoRecord(); rec = 1; } } // Show recording state if (rec) { static CvFont font = cvFont(1.0); cvPutText(image, "REC", cvPoint(10, 20), &font, CV_RGB(255,0,0)); } // Display the image cvShowImage("camera", image); cvWaitKey(1); } // See you ardrone.close(); return 0;}
开发者ID:RobQuistNL,项目名称:cvdrone,代码行数:56,
示例4: mainint main(){ cout<<"Hol<"<<endl; //Mat img=imread("/home/mottamx/Pictures/batman.jpg"); //namedWindow("batman"); //imshow("batman", img); //waitKey(1); cout<<"Hol<<"<<endl; ARDrone ardrone; if (!ardrone.open()){ cout<<"error de comunicación"<<endl; return -1; } cout<<"Bat: "<<ardrone.getBatteryPercentage()<<endl; sleep(2); cout<<"Bat: "<<ardrone.getBatteryPercentage()<<endl; sleep(2); cout<<"Bat: "<<ardrone.getBatteryPercentage()<<endl; sleep(2); time_t start, end; time (&start); cout.flush(); double elapsed=0; namedWindow("dron"); namedWindow("dron2"); while(elapsed<5){ //sleep(2); IplImage *im=ardrone.getImage(); Mat img = Mat(im); Mat img2; resize(img, img2, Size(), 2,2, INTER_AREA); resize(img, img, Size(), 2,2, INTER_LANCZOS4); imshow("dron", img); waitKey(1); imshow("dron2", img2); waitKey(1); time(&end); elapsed=difftime(end,start); } cout<<"Tiempo: "<<setprecision(3)<<elapsed<<"segundos"<<endl; cout<<"<dios"<<endl; ardrone.close(); ardrone.emergency();return 0;}
开发者ID:mottamx,项目名称:LTI_Robotics,代码行数:46,
示例5: main// --------------------------------------------------------------------------// main(Number of arguments, Argument values)// Description : This is the entry point of the program.// Return value : SUCCESS:0 ERROR:-1// --------------------------------------------------------------------------int main(int argc, char **argv){ // AR.Drone class ARDrone ardrone; // Initialize if (!ardrone.open()) { printf("Failed to initialize./n"); return -1; } // Image of AR.Drone's camera IplImage *image = ardrone.getImage(); // Read intrincis camera parameters CvFileStorage *fs = cvOpenFileStorage("camera.xml", 0, CV_STORAGE_READ); CvMat *intrinsic = (CvMat*)cvRead(fs, cvGetFileNodeByName(fs, NULL, "intrinsic")); CvMat *distortion = (CvMat*)cvRead(fs, cvGetFileNodeByName(fs, NULL, "distortion")); // Initialize undistortion maps CvMat *mapx = cvCreateMat(image->height, image->width, CV_32FC1); CvMat *mapy = cvCreateMat(image->height, image->width, CV_32FC1); cvInitUndistortMap(intrinsic, distortion, mapx, mapy); // Main loop while (1) { // Key input int key = cvWaitKey(1); if (key == 0x1b) break; // Update if (!ardrone.update()) break; // Get an image image = ardrone.getImage(); // Remap the image cvRemap(image, image, mapx, mapy); // Display the image cvShowImage("camera", image); } // Release the matrices cvReleaseMat(&mapx); cvReleaseMat(&mapy); cvReleaseFileStorage(&fs); // See you ardrone.close(); return 0;}
开发者ID:B12040331,项目名称:CVDrone,代码行数:58,
示例6: main// --------------------------------------------------------------------------// main(Number of arguments, Argument values)// Description : This is the entry point of the program.// Return value : SUCCESS:0 ERROR:-1// --------------------------------------------------------------------------int main(int argc, char **argv){ // AR.Drone class ARDrone ardrone; // Initialize if (!ardrone.open()) { printf("Failed to initialize./n"); return -1; } // Recording flag bool rec = false; printf("Press 'R' to start/stop recording."); // Main loop while (1) { // Key input int key = cvWaitKey(1); if (key == 0x1b) break; // Update if (!ardrone.update()) break; // Get an image IplImage *image = ardrone.getImage(); // Video recording start / stop if (key == 'r') { rec = !rec; ardrone.setVideoRecord(rec); } // Show recording state if (rec) { static CvFont font = cvFont(1.0); cvPutText(image, "REC", cvPoint(10, 20), &font, CV_RGB(255,0,0)); } // Display the image cvShowImage("camera", image); } // See you ardrone.close(); return 0;}
开发者ID:messichess77,项目名称:cvdrone,代码行数:53,
示例7: main// --------------------------------------------------------------------------// main(Number of arguments, Argument values)// Description : This is the entry point of the program.// Return value : SUCCESS:0 ERROR:-1// --------------------------------------------------------------------------int main(int argc, char **argv){ // AR.Drone class ARDrone ardrone; // Initialize if (!ardrone.open()) { printf("Failed to initialize./n"); return -1; } // Battery int battery = ardrone.getBatteryPercentage(); printf("ardrone.battery = %d [%%]/n", battery); // Instructions printf("***************************************/n"); printf("* CV Drone sample program */n"); printf("* - Haw To Play - */n"); printf("***************************************/n"); printf("* */n"); printf("* - Controls - */n"); printf("* 'Space' -- Takeoff/Landing */n"); printf("* 'Up' -- Move forward */n"); printf("* 'Down' -- Move backward */n"); printf("* 'Left' -- Turn left */n"); printf("* 'Right' -- Turn right */n"); printf("* 'Shift+Up' -- Move upward */n"); printf("* 'Shift+Down' -- Move downward */n"); printf("* 'Shift+Left' -- Move left */n"); printf("* 'Shift+Right' -- Move right */n"); printf("* */n"); printf("* - Others - */n"); printf("* 'C' -- Change camera */n"); printf("* 'Esc' -- Exit */n"); printf("* */n"); printf("***************************************/n/n"); // Main loop while (!GetAsyncKeyState(VK_ESCAPE)) { // Update if (!ardrone.update()) break; // Get an image IplImage *image = ardrone.getImage(); // Take off / Landing if (KEY_PUSH(VK_SPACE)) { if (ardrone.onGround()) ardrone.takeoff(); else ardrone.landing(); } // Move double vx = 0.0, vy = 0.0, vz = 0.0, vr = 0.0; if (KEY_DOWN(VK_SHIFT)) { if (KEY_DOWN(VK_UP)) vz = 1.0; if (KEY_DOWN(VK_DOWN)) vz = -1.0; if (KEY_DOWN(VK_LEFT)) vy = 1.0; if (KEY_DOWN(VK_RIGHT)) vy = -1.0; } else { if (KEY_DOWN(VK_UP)) vx = 1.0; if (KEY_DOWN(VK_DOWN)) vx = -1.0; if (KEY_DOWN(VK_LEFT)) vr = 1.0; if (KEY_DOWN(VK_RIGHT)) vr = -1.0; } ardrone.move3D(vx, vy, vz, vr); // Change camera static int mode = 0; if (KEY_PUSH('C')) ardrone.setCamera(++mode%4); // Display the image cvShowImage("camera", image); cvWaitKey(1); } // See you ardrone.close(); return 0;}
开发者ID:borceg,项目名称:cvdrone,代码行数:87,
示例8: runArdroneint runArdrone(void){ // AR.Drone class ARDrone ardrone; // Initialize if (!ardrone.open()) { printf("Failed to initialize./n"); return -1; } // Battery battery = ardrone.getBatteryPercentage(); int tmpOrder = -99; int nbLabelPos = 8; int occLabelPos[nbLabelPos]; list<int> listOrder(5,-1);float vx = 0.0, vy = 0.0, vz = 0.0, vr = 0.0; while (1) { usleep(33000); imgFromKarmen = ardrone.getImage(); battery = ardrone.getBatteryPercentage(); tmpOrder = -99; for (int i = 0; i < nbLabelPos; i++) occLabelPos[i] = 0; // Key input // int key = cvWaitKey(0); // if (key == 0x1b) break; //TODO // Get an image // Move vx = 0.0; vy = 0.0; vz = 0.0; vr = 0.0; if(order == 100){ orderName = "Land"; ardrone.landing(); // Land newOrder = false; } else{ if(newOrder){ newOrder = false; listOrder.pop_front(); listOrder.push_back(order); } for (list<int>::iterator it=listOrder.begin(); it != listOrder.end(); ++it){ if(*it >= 0 && *it < nbLabelPos) occLabelPos[*it]++; } for (int i = 0; i < nbLabelPos; i++){ if(occLabelPos[i] >= 3){ tmpOrder = i; break; } } switch (tmpOrder) { case 0 : orderName = "Up"; vz = 1.0; break; case 1 : orderName = "Down"; vz = -1.0; break; case 2 : orderName = "Left"; vy = 1.0; break; case 3 : orderName = "Right"; vy = -1.0; break; case 4 : orderName = "Land"; ardrone.landing(); // Land break; case 5 : if (ardrone.onGround()){ orderName = "Take Off"; ardrone.takeoff(); // Take-off } break; case 6 : orderName = "Forward"; vx = 1.0;//.........这里部分代码省略.........
开发者ID:SirYacc,项目名称:ter,代码行数:101,
示例9: main// --------------------------------------------------------------------------// main(Number of arguments, Argument values)// Description : This is the entry point of the program.// Return value : SUCCESS:0 ERROR:-1// --------------------------------------------------------------------------int main(int argc, char *argv[]){ // AR.Drone class ARDrone ardrone; // Initialize if (!ardrone.open()) { std::cout << "Failed to initialize." << std::endl; return -1; } // Main loop while (1) { // Key input int key = cv::waitKey(33); if (key == 0x1b) break; // Get an image cv::Mat image= ardrone.getImage(); // Orientation double roll = ardrone.getRoll(); double pitch = ardrone.getPitch(); double yaw = ardrone.getYaw(); std::cout << "ardrone.roll = " << roll * RAD_TO_DEG << " [deg]" << std::endl; std::cout << "ardrone.pitch = " << pitch * RAD_TO_DEG << " [deg]" << std::endl; std::cout << "ardrone.yaw = " << yaw * RAD_TO_DEG << " [deg]" << std::endl; // Altitude double altitude = ardrone.getAltitude(); std::cout << "ardrone.altitude = " << altitude << " [m]" << std::endl; // Velocity double vx, vy, vz; double velocity = ardrone.getVelocity(&vx, &vy, &vz); std::cout << "ardrone.vx = " << vx << " [m/s]" << std::endl; std::cout << "ardrone.vy = " << vy << " [m/s]" << std::endl; std::cout << "ardrone.vz = " << vz << " [m/s]" << std::endl; // Battery int battery = ardrone.getBatteryPercentage(); std::cout << "ardrone.battery = " << battery << " [%%]" << std::endl; // Take off / Landing if (key == ' ') { if (ardrone.onGround()) ardrone.takeoff(); else ardrone.landing(); } // Move double x = 0.0, y = 0.0, z = 0.0, r = 0.0; if (key == 0x260000) x = 1.0; if (key == 0x280000) x = -1.0; if (key == 0x250000) r = 1.0; if (key == 0x270000) r = -1.0; ardrone.move3D(x, y, z, r); // Change camera static int mode = 0; if (key == 'c') ardrone.setCamera(++mode%4); // Display the image cv::imshow("camera", image); } // See you ardrone.close(); return 0;}
开发者ID:tekkies,项目名称:cvdrone,代码行数:75,
示例10: mainint main(int argc, char **argv){ //int i; //static IplImage *src_img = 0, *src_gray = 0; CascadeClassifier face_cascade; //OK 2014.02.14 精度は荒いが速度はよい ※速度重 C++ ARGS_TYPE类代码示例 C++ APoint类代码示例
|