int main(int argc,char **argv) { QApplication app(argc,argv); MyCameraWindow *mainWin = new MyCameraWindow(0); mainWin->show(); app.setMainWidget(mainWin); return app.exec(); }
int main(int argc, char **argv) { CvCapture * camera = cvCreateCameraCapture(0); assert(camera); IplImage * image=cvQueryFrame(camera); assert(image); printf("Image depth=%i \n", image->depth);//8 printf("Image nChannels=%i \n", image->nChannels);//3 QApplication app(argc, argv); MyCameraWindow *mainWin = new MyCameraWindow(camera); mainWin->setWindowTitle("AKA Loco Team"); mainWin->show(); int retval = app.exec(); cvReleaseCapture(&camera); return retval; }
int main(int argc,char **argv) { if (argc<2) { qWarning("%s [server ip]",argv[0]); exit(1); } QApplication app(argc,argv); MyCameraWindow *mainWin = new MyCameraWindow(0); app.setMainWidget(mainWin); mainWin->show(); // 連到server端 mainWin->Connect2Host(QString(argv[1]),MY_PORT_NUM); // 開始要求傳送圖片 mainWin->start(); return app.exec(); }
int main(int argc, char **argv) { CvCapture * camera = cvCreateCameraCapture(0); //The function cvCreateCameraCapture allocates and initialized the CvCapture structure for reading a video stream from the camera. assert(camera); //Expression to be evaluated. If this expression evaluates to 0, this causes an assertion failure that terminates the program. IplImage * image=cvQueryFrame(camera); //The function cvQueryFrame grabs a frame from camera or video file, decompresses and returns it. assert(image); printf("Image depth=%i\n", image->depth); printf("Image nChannels=%i\n", image->nChannels); printf("Image size = %i x %i", image->width, image->height); QApplication app(argc, argv); MyCameraWindow *mainWin = new MyCameraWindow(camera); mainWin->setWindowTitle("OpenCV --> QtImage"); mainWin->show(); int retval = app.exec(); cvReleaseCapture(&camera); return retval; }
/** * This is the main function. * This function is called when the program is launched. */ int main(int argc, char **argv) { // Qt application QApplication app(argc, argv); // Ask the user how many cameras he wants to use QStringList list; // list of the diferent choices the user can make list << "Only one camera (classic)" << "Two cameras (3D stereoscopy)"; bool ok = false; QString nbCam = QInputDialog::getItem(NULL, "Mode", "How many cameras do you want to use ?", list, 0, false, &ok); if(ok && !nbCam.isEmpty()) { // If ok was pressed and a choice was made if(nbCam == "Only one camera (classic)") { // The user choosed only one camera // Create the webcam capture device and connect it to the webcam VideoThread* videoThread = new VideoThread(ALONE); if(!videoThread->ConnectToWebcam(0)) { QMessageBox::critical(NULL, "Problem with the camera", "The program couldn't find the camera, and will close now."); exit(0); } // Start the thread // Now the capturing runs by itself, in another thread videoThread->StartCapturingThread(); if(videoThread == NULL) { QMessageBox::critical(NULL, "Problem with the camera", "The program couldn't find the camera, and will close now."); exit(0); } else { // Create the video handler vector<VideoThread*> cameras; cameras.push_back(videoThread); VideoHandler* handler = new VideoHandler(cameras); // Start the camera window MyCameraWindow *mainWin = new MyCameraWindow(handler); mainWin->setWindowTitle("Camera"); ClientWindow* window = new ClientWindow; new Client(window); mainWin->getMainLayout()->addWidget(window); mainWin->show(); } } else if(nbCam == "Two cameras (3D stereoscopy)") { // Create the webcam capture device and connect it to the webcam // Right VideoThread* rightVideoThread = new VideoThread(RIGHT); if(!rightVideoThread->ConnectToWebcam(0)) { QMessageBox::critical(NULL, "Problem with the cameras", "The program couldn't find the cameras, and will close now."); exit(0); } // Left VideoThread* leftVideoThread = new VideoThread(LEFT); if(!leftVideoThread->ConnectToWebcam(0)) { QMessageBox::critical(NULL, "Problem with the cameras", "The program couldn't find the cameras, and will close now."); exit(0); } // Start the threads // Now the capturing runs by itself, in two different threads rightVideoThread->StartCapturingThread(); leftVideoThread->StartCapturingThread(); if(rightVideoThread == NULL || leftVideoThread == NULL) { QMessageBox::critical(NULL, "Problem with the cameras", "The program couldn't find the cameras, and will close now."); exit(0); } else { // Create the video handler vector<VideoThread*> cameras; cameras.push_back(rightVideoThread); cameras.push_back(leftVideoThread); VideoHandler* handler = new VideoHandler(cameras); // Start the camera window MyCameraWindow *mainWin = new MyCameraWindow(handler); mainWin->setWindowTitle("Camera"); // Create the ClientWindow ClientWindow* window = new ClientWindow; // Create and launch the Client new Client(window); // Add the ClientWindow to the camera window mainWin->getMainLayout()->addWidget(window); mainWin->show(); // Ask the user if he wants to calibrate the cameras int calibrate = QMessageBox::question(NULL, "Calibration", "Do you want to calibrate the cameras ?", QMessageBox::Yes | QMessageBox::No); if (calibrate == QMessageBox::Yes) { // Start the calibration window CalibrationWindow *caliWin = new CalibrationWindow(handler); caliWin->setWindowTitle("Calibration"); caliWin->show(); } } } } else { exit(0); } int retval = app.exec(); return retval; }