ठीक है, मैंने अंततः इसे किया, इसलिए मैं यहां अपना समाधान पोस्ट करूंगा ताकि हमारे पास इसके बारे में कुछ स्पष्ट हो। http://sol.gfxile.net/escapi/index.html
इस डिवाइस से तख्ते पर कब्जा करने के लिए एक बेहद आसान तरीका प्रदान करते हैं:
मैं एक पुस्तकालय 'ESCAPI' कहा जाता है का इस्तेमाल किया। इस कच्चे डेटा के साथ, मैं सिर्फ एक QImage बनाता हूं जो बाद में एक QLabel में दिखाया गया है।
मैंने इसे संभालने के लिए एक साधारण वस्तु बनाई है।
#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;
}
और हेडर फाइल:
#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
यह बहुत आसान है, लेकिन सिर्फ उदाहरण के प्रयोजनों के लिए। उपयोग किया जाना चाहिए कुछ की तरह:
Camera cam(320, 240);
cam.initialize();
cam.capture();
QImage img(cam.getImage());
ui->label->setPixmap(QPixmap::fromImage(img));
बेशक
, आप एक QTimer का उपयोग करें और QLabel में फ्रेम को अद्यतन करने और तुम वहाँ वीडियो होगा कर सकते हैं ...
आशा है कि यह मदद! और आपकी मदद के लिए निकोलस धन्यवाद!
यहां सूचीबद्ध कुछ विकल्प हैं: http://stackoverflow.com/questions/1259192/webcam-access-in-c लेकिन 'डायरेक्टशो' एपीआई शायद सबसे अच्छा काम करेगा। –
सीआर * पी ... मैं खोज और खोज करता हूं इसलिए मैं एक प्रश्न डुप्लिकेट नहीं करता हूं, और वहां था ... धन्यवाद निकोलस – webbi
ठीक है, मैंने आपके द्वारा बताए गए प्रश्न पर डायरेक्टशो के बारे में पढ़ा है, यह आसान या लगभग संगत प्रतीत होता है मेरी ज़रूरतों के साथ, बात यह है कि मुझे क्यूटी से डायरेक्टशो के साथ बातचीत करने के बारे में कोई पूरा उदाहरण नहीं मिला है। मैं अब कुछ शोध कर रहा हूं, लेकिन अगर कोई मदद करना चाहता है, तो मैं इसकी सराहना करता हूं। – webbi