我想编写一个应用程序(在c++中),以便从用于采集系统的照相机中捕获图像。相机连接到一个盒子(采集系统),我发现使用的芯片是FTDI。芯片位于摄像头和PC机之间的盒子里。照相机连接到这个盒子上。USB电缆连接到PC机和机箱。其他一些工具连接到盒上,这些工具并不重要。
此外,还有一个简单的商业应用程序是由MFC和我想要做的完全相同的。在应用程序的文件夹中有D2XX驱动文件(ftd2x.h等)和照相机的一个信息文件(*.inf)。
此外,相机不是在录像,而是在短间隔(<0.1s)拍摄,间隔由采集系统而不是商业应用决定(采集系统检测相机需要拍照的时间)。
以下是我的问题:
由于提供了USB设备的信息文件,我是否可以使用Open库来捕捉相机,或者我是否只需要使用D2XX库?
如果我必须使用D2XX库来读取数据,如何将原始数据转换为图像格式( Qt)?
我不能简单地一遍又一遍地在设备上编写应用程序和测试来寻找解决方案,因为设备位于离我的位置很远的地方,而且对于每一个测试,我都要走这个距离。所以,我想确保我的应用程序能正常工作。
中国的一家公司为我们制造了这个装置,他们再也不支持了。
发布于 2015-09-13 17:34:55
相机使用自定义通信协议,它不实现成像设备类。OpenCV不会看到它,任何其他多媒体库也不会。无论如何,你都需要实现那个协议。然后,如果愿意,可以将其公开给OpenCV。
发布于 2016-06-21 13:11:38
若要转换为图像,请尝试如下:
Mat hwnd2mat(HWND hwnd){
HDC hwindowDC, hwindowCompatibleDC;
int height, width, srcheight, srcwidth;
HBITMAP hbwindow; // <-- The image represented by hBitmap
cv::Mat src; // <-- The image represented by mat
BITMAPINFOHEADER bi;
// Initialize DCs
hwindowDC = GetDC(hwnd); // Get DC of the target capture..
hwindowCompatibleDC = CreateCompatibleDC(hwindowDC); // Create compatible DC
SetStretchBltMode(hwindowCompatibleDC, COLORONCOLOR);
RECT windowsize; // get the height and width of the screen
GetClientRect(hwnd, &windowsize);
srcheight = windowsize.bottom;
srcwidth = windowsize.right;
height = windowsize.bottom *2/ 2; //change this to whatever size you want to resize to
width = windowsize.right *2/ 2;
src.create(height, width, CV_8UC4);
// create a bitmap
hbwindow = CreateCompatibleBitmap(hwindowDC, width, height);
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = width;
bi.biHeight = -height; //this is the line that makes it draw upside down or not
bi.biPlanes = 1;
bi.biBitCount = 32;
bi.biCompression = BI_RGB;
bi.biSizeImage = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
// use the previously created device context with the bitmap
SelectObject(hwindowCompatibleDC, hbwindow);
// copy from the window device context to the bitmap device context
StretchBlt(hwindowCompatibleDC, 0, 0, width, height, hwindowDC, 0, 0, srcwidth, srcheight, SRCCOPY); //change SRCCOPY to NOTSRCCOPY for wacky colors !
GetDIBits(hwindowCompatibleDC, hbwindow, 0, height, src.data, (BITMAPINFO *)&bi, DIB_RGB_COLORS); //copy from hwindowCompatibleDC to hbwindow
// avoid memory leak
DeleteObject(hbwindow); DeleteDC(hwindowCompatibleDC); ReleaseDC(hwnd, hwindowDC);
return src;
}https://stackoverflow.com/questions/32536297
复制相似问题