PDA

View Full Version : How to use the webcam available on my laptop in my application?



_dmn
1st August 2013, 07:13
I'm trying to use my webcam (in Qt) using OpenCv library. I get an error for this code:

#include "mainwindow.h"
#include <QApplication>
#include <QLabel>
#include <opencv2/opencv.hpp>
#include <opencv/cv.h>
#include <QtWidgets>
#include <QImage>

int main(int argc, char *argv[])
{
cv::VideoCapture camera;
camera.open(1);
}

saying

/home/darshan/AindraDesktopApp/main.cpp:27: error: undefined reference to `cv::VideoCapture::VideoCapture()'
/home/darshan/AindraDesktopApp/main.cpp:28: error: undefined reference to `cv::VideoCapture::open(int)'
/home/darshan/AindraDesktopApp/main.cpp:30: error: undefined reference to `cv::VideoCapture::~VideoCapture()'
/home/darshan/AindraDesktopApp/main.cpp:30: error: undefined reference to `cv::VideoCapture::~VideoCapture()'
collect2: error: collect2: error: ld returned 1 exit status

What should I do? Or rather, how do I make use use of my laptop's webcam?

ChrisW67
1st August 2013, 07:22
Link the correct OpenCV libraries into your application and these linker errors will go away. This has very little to do with Qt.