我在互联网上搜索了将近 2 天的解决方案,但我发现的解决方案似乎不适用于我的计算机。
我正在使用什么:
- Matrox Vio DUO
- OpenCV 2.4.5
- MIL-lite
- Ubuntu 10.04
我已经尝试过您可以在此处找到的 cvcap_mil.cpp 文件。
此代码也不适用于我的项目:
IplImage* rgb_frame;
rgb_frame = cvCreateImage(cvSize(w,h), IPL_DEPTH_8U, 3 );
MilImage = MbufAllocColor(MilSystem, 3, w, h,8+M_UNSIGNED,M_IMAGE + M_GRAB,M_NULL);
MbufGetColor(MilImage, M_BGR24+M_PACKED, M_ALL_BAND, (void*)(rgb_frame->imageData));
rgb_frame->origin = IPL_ORIGIN_BL;
cvFlip(rgb_frame,rgb_frame,0);
你知道怎么做吗?
PS:我的 Matrox Vio 卡工作正常。
编辑:我找到了一种获取黑白图像的方法。以下是感兴趣的人的解决方案:
MIL_ID MilApplication, /* Application identifier */
MilSystem, /* System identifier */
MilDigitizer, /* Digitizer identifier */
MilImageRGB, /* RGB Buffer */
MilImage1Child, /* R child */
MilImage2Child, /* G child */
MilImage3Child; /* B child */
//init
MappAlloc(M_DEFAULT,&MilApplication);
MsysAlloc(M_SYSTEM_VIO,M_DEFAULT,M_DEFAULT,&MilSystem);
MdigAlloc(MilSystem,M_DEFAULT,MIL_TEXT("M_DEFAULT"),M_DEFAULT,&MilDigitizer);
/*get width & height of cam*/
long width = MdigInquire(MilDigitizer,M_SIZE_X,M_NULL);
long height = MdigInquire(MilDigitizer,M_SIZE_Y,M_NULL);
MbufAllocColor(MilSystem,3,width,height,8+M_UNSIGNED,M_IMAGE+M_GRAB+M_PROC+M_DISP,&MilImageRGB); /*Erster Buffer*/
/*first Child (r channel)*/
MbufChildColor2d(MilImageRGB,M_RED, 0, 0, width , height ,&MilImage1Child);
MbufChildColor2d(MilImageRGB,M_GREEN, 0, 0, width , height ,&MilImage2Child); /*second Child (g channel)*/
MbufChildColor2d(MilImageRGB,M_BLUE, 0, 0, width , height ,&MilImage3Child); /*third Child (b channel)*/
IplImage *pIplImgProcessed = cvCreateImage ( cvSize ( width,height ), 8,1 );
/* get one image */
MdigGrab(MilDigitizer, MilImageRGB);
/*copy first child to buffer*/
MbufGet ( MilImage1Child, pIplImgProcessed->imageData );
// Visualise in a Qt label
Mat src(pIplImgProcessed);
QImage qImage = Mat2QImage(src);
QPixmap pixmap = QPixmap::fromImage(qImage);
ui->label_2->clear();
ui->label_2->setPixmap(pixmap.scaled(ui->label_2->size()));
//release
MdigFree(MilDigitizer);
MbufFree(MilImage1Child);
MbufFree(MilImage2Child);
MbufFree(MilImage3Child);
MbufFree(MilImageRGB);
MsysFree(MilSystem);
MappFree(MilApplication);
谢谢您的帮助。蒂博。