21 สิงหาคม 2553

ทดสอบการสร้างโปรเจคที่ใช้งาน wiiuse, OpenGL, OpenCV ร่วมกัน

ทดสอบการสร้างโปรเจคที่ใช้งาน wiiuse, OpenGL, OpenCV ร่วมกัน

ดาวน์โหลด

โค้ดที่ใช้ทดสอบ wiiuse

       /* Test wiimote
         */
        wiimote** wiimotes;
        int found, connected;

        /*
         *    Initialize an array of wiimote objects.
         *
         *    The parameter is the number of wiimotes I want to create.
         */
        wiimotes =  wiiuse_init(MAX_WIIMOTES);
        found = wiiuse_find(wiimotes, MAX_WIIMOTES, 5);
        if (!found) {
            printf ("No wiimotes found.");
            return 0;
        }
        wiiuse_rumble(wiimotes[0], 0);
        /*
         *    Disconnect the wiimotes
         */
        wiiuse_cleanup(wiimotes, MAX_WIIMOTES);

โค้ดที่ใช้ทดสอบ OpenCV

       /* test OpenCV
         */
        IplImage *img = cvLoadImage(".\\image.jpg");
        cv::namedWindow("Image:",1);
       
        IplImage *dst = cvCreateImage(cvGetSize(img),IPL_DEPTH_16S,3);
        IplImage *dst2 = cvCreateImage(cvGetSize(img),IPL_DEPTH_16S,3);
        cvLaplace(img, dst, 3);
        //cvLaplace(dst, dst2, 3);
        cv::imshow("Image:", dst);
        cvWaitKey();
        cvDestroyWindow("Image:");
        cvReleaseImage(&img);

 


โค้ดที่ใช้ทดสอบ OpenGL

       /* test OpenGL
         */
        char *targv[] = {""};
        glutInit (&argc, targv);
        glutInitDisplayMode (GLUT_DOUBLE | GLUT_DEPTH); //set the display to Double buffer, with depth
        glutGameModeString( "1024x768:32@30" ); //the settings for fullscreen mode
        glutEnterGameMode(); //set glut to fullscreen using the settings in the line above
        init (); //call the init function
        glutDisplayFunc (display); //use the display function to draw everything
        glutIdleFunc (display); //update any variables in display, display can be changed to anyhing, as long as you move the variables to be updated, in this case, angle++;
        glutReshapeFunc (reshape); //reshape the window accordingly

        glutKeyboardFunc (keyboard); //check the keyboard
        glutMainLoop (); //call the main loop}

ไม่มีความคิดเห็น: