/** @file app_vetVideo4LinuxPlayer.cpp * * @brief Testing code for class vetVideo4Linux and vetWindowQT. * * Load video stream from first device (/dev/video0) and * show preview in a window with the same size, stream * is passed through vetFrameRGB24 objects. * Frame rate should be the higher possible, after 100 frames, * loop will exit printing average fps; this number depends * on source rate and window's redrawing both (sum). * Then last captured frame is saved. * * Tested on a Linux 2.4.29 kernel with an USB Logitech Express * Webcam, frame rate is around 15 fps, that is hardware limit. * In example test_LinuxMPEGPlayer was 34 fps (decoding+displaying). * * @warning requires VETLib with V4L support and GUI support * requires a valid capture device, Video4Linux library, QT library. * * @see vetVideo4Linux * @see vetWindowQT * @see vetDoctor * @see app_LinuxMPEGPlayer.cpp * @see app_LinuxMOVPlayer.cpp * * @version 1.0.2 * @date 12/09/2005 * @author Alessandro Polo * * **************************************************************************** * VETLib Framework 1.02 * Copyright (C) Alessandro Polo 2005 * http://www.ewgate.net/vetlib * ****************************************************************************/ //--------------------------------------------------------------------------- #pragma hdrstop //--------------------------------------------------------------------------- #include "../source/vetFrameRGB24.h" #include "../source/inputs/vetVideo4Linux.h" #include "../source/outputs/vetWindowQT.h" #include "../source/outputs/vetDoctor.h" #include "../source/codecs/vetCodec_BMP.h" #include #pragma argsused int main(int argc, char* argv[]) { printf("Testing vetVideo4Linux and vetWindowQT Development...\n"); printf("\nCreating Instances and Connecting to /dev/video0...\n"); vetVideo4Linux cap("/dev/video0"); vetDoctor doc; float fps; int i; long time; printf("\nDevice Stream INFO:\n"); printf(" Device Stream Width: %d\n", cap.getWidth() ); printf(" Device Stream Height: %d\n", cap.getHeight() ); printf(" Device Stream Color Depth: %d\n", cap.getColorDepth() ); printf(" Device Stream Palette: %d\n", cap.getPalette() ); vetFrameRGB24 imgRGB24 ( cap.getWidth(), cap.getHeight() ); // cap.setBrightness(0); // cap.setContrast(0); // cap.setHue(0); printf("\nCreating QApplication...\n"); QApplication app(argc, argv); printf("\nCreating QWindow...\n"); vetWindowQT *myapp = new vetWindowQT(cap.getWidth(), cap.getHeight() ); printf("\nShowing vetWindowQT...\n"); myapp->show(); app.setMainWidget(myapp); printf("\nStarting frame redirection loop... (with vetFrameRGB24)\n"); i = 0; time = 0; doc.reset(true); while (i++ < 100) { cap >> imgRGB24; *myapp << imgRGB24; } time = doc.getElapsedTime(); fps = (float)100000/(float)doc.getElapsedTime(); printf("Elapsed milliseconds : %ld\n", time ); printf("Average Frame Rate : %f fps\n", fps ); printf("\nSaving last capture frame...\n"); vetCodec_BMP::save(imgRGB24, "v4l_captured_last.bmp", vetCodec_BMP::FORMAT_BMP_24); app.exec(); printf("Test Completed. Type something to continue...\n"); getchar(); return 0; } //---------------------------------------------------------------------------