• 5791阅读
  • 1回复

[请教] 如何用qt4做视频采集? [复制链接]

上一主题 下一主题
离线aaronhc
 
只看楼主 倒序阅读 楼主  发表于: 2008-10-10
— 本帖被 XChinux 执行加亮操作(2008-10-12) —
我是在Windows下用QT4开发的

我买了一个海康的HC视频采集卡,因为海康提供的是VC做的SDK,我想用QT实现一个显示摄像头图像的程序,但是由于是新手,有点不知所从。。。
请教大牛们指点迷津,给点提示。

支持QT,不用VC
离线aaronhc
只看该作者 1楼 发表于: 2008-10-10
我顶一下哈,在网上找到一段代码,但是不知道怎么使用,只是一个构造函数而已啊。。。。

#include <QLibrary>
#include <QMessageBox>
#include <windows.h>

const static int WM_CAP_START=WM_USER;
const static int WM_CAP_STOP = WM_CAP_START + 68;
const static int WM_CAP_DRIVER_CONNECT=WM_CAP_START+10;
const static int WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
const static int WM_CAP_SAVEDIB = WM_CAP_START + 25;
const static int WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
const static int WM_CAP_SEQUENCE = WM_CAP_START + 62;
const static int WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20;
const static int WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+ 63;
const static int WM_CAP_SET_OVERLAY =WM_CAP_START+ 51 ;
const static int WM_CAP_SET_PREVIEW =WM_CAP_START+ 50  ;
const static int WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +6;
const static int WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +2;
const static int WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +3;
const static int WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +5;
const static int WM_CAP_SET_SCALE=WM_CAP_START+ 53;
const static int WM_CAP_SET_PREVIEWRATE=WM_CAP_START+ 52;

CamViewer::CamViewer(QWidget *parent)
    : QWidget(parent)
{
    resize(400,300);
    QLibrary mylib("avicap32");
    if(mylib.load()){
//        QMessageBox::information(this,tr("info"),tr("load dll OK!"));
        typedef HWND(* capCreateFunc)(char *lpszWindowName,long int swStyle,
                int x,int y,int nWidth,int nHeight,HWND parentWin,int nID);
        capCreateFunc capCreate=(capCreateFunc)mylib.resolve("capCreateCaptureWindowA");
        if(capCreate){
            HWND h=capCreate("my own capture window",WS_CHILD|WS_VISIBLE,0,0,width(),height(),winId(),0);
            if(h){
                SendMessage(h,WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
                SendMessage(h,WM_CAP_SET_CALLBACK_ERROR,0,0);
                SendMessage(h,WM_CAP_SET_CALLBACK_STATUSA,0,0);
                SendMessage(h,WM_CAP_DRIVER_CONNECT,0,0);
                SendMessage(h,WM_CAP_SET_SCALE,1,0);
                SendMessage(h,WM_CAP_SET_PREVIEWRATE,66,0);
                SendMessage(h,WM_CAP_SET_OVERLAY,1,0);
                SendMessage(h,WM_CAP_SET_PREVIEW,1,0);
            }
             
        }
    }
}
快速回复
限100 字节
 
上一个 下一个