【问题标题】:How to capture image from usbcamera button in C# or C++如何从 C# 或 C++ 中的 usbcamera 按钮捕获图像
【发布时间】:2013-10-28 07:02:11
【问题描述】:

谁能告诉我?我使用directshow和wia但没有找到方法

【问题讨论】:

  • 没有研究工作,它必须是可见的。
  • 我使用 directshow ISampleGrabberCB ,但它无法收听 USB 摄像头按钮消息

标签: directshow wia


【解决方案1】:

为什么不使用 OpenCV

main.cpp

int main(int argc, char** argv) { 
    CvCapture* capture = cvCaptureFromCAM(0);

    int index = 0;
    while(cvGrabFrame(capture)) { 
        /*Get webcam image!*/
        IplImage *camImg = cvRetrieveFrame(capture); 

        /*Save the image to the disk!*/
        string fileName = "tmp/" + int2str(index) + ".jpg";
        cvSaveImage(fileName.c_str(), screenShotImg);

        index++;

        int key = cvWaitKey(10); 
        if(key == 27) {
            break;  
        }
    }

    cvReleaseCapture(&capture); 
    return 0; 
}

TypeConvert.cpp

#include "TypeConvert.h"

#include <iostream>
#include <sstream>

string int2str(int &num) {
    string emptyStr;
    stringstream ss(emptyStr);
    ss << num;

    return ss.str();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-18
    • 2017-10-18
    • 1970-01-01
    相关资源
    最近更新 更多