Well, I finally did it, so I will post my decision here so that we have something clear.
I used a library called "ESCAPI": http://sol.gfxile.net/escapi/index.html
This provides an extremely easy way to capture frames from the device. Using this source data, I simply create a QImage, which is later displayed in QLabel.
I created a simple object to handle this.
#include <QDebug> #include "camera.h" Camera::Camera(int width, int height, QObject *parent) : QObject(parent), width_(width), height_(height) { capture_.mWidth = width; capture_.mHeight = height; capture_.mTargetBuf = new int[width * height]; int devices = setupESCAPI(); if (devices == 0) { qDebug() << "[Camera] ESCAPI initialization failure or no devices found"; } } Camera::~Camera() { deinitCapture(0); } int Camera::initialize() { if (initCapture(0, &capture_) == 0) { qDebug() << "[Camera] Capture failed - device may already be in use"; return -2; } return 0; } void Camera::deinitialize() { deinitCapture(0); } int Camera::capture() { doCapture(0); while(isCaptureDone(0) == 0); image_ = QImage(width_, height_, QImage::Format_ARGB32); for(int y(0); y < height_; ++y) { for(int x(0); x < width_; ++x) { int index(y * width_ + x); image_.setPixel(x, y, capture_.mTargetBuf[index]); } } return 1; }
And the header file:
#ifndef CAMERA_H #define CAMERA_H #include <QObject> #include <QImage> #include "escapi.h" class Camera : public QObject { Q_OBJECT public: explicit Camera(int width, int height, QObject *parent = 0); ~Camera(); int initialize(); void deinitialize(); int capture(); const QImage& getImage() const { return image_; } const int* getImageRaw() const { return capture_.mTargetBuf; } private: int width_; int height_; struct SimpleCapParams capture_; QImage image_; }; #endif // CAMERA_H
It is so simple, but just for the purpose. Use should be something like this:
Camera cam(320, 240); cam.initialize(); cam.capture(); QImage img(cam.getImage()); ui->label->setPixmap(QPixmap::fromImage(img));
Of course, you can use QTimer and update the frame in QLabel, and you will have a video ...
Hope this helps! and thanks to Nicholas for your help!