DirectShow设置摄像头的分辨率和图像格式代码如下所示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| AM_MEDIA_TYPE *p = NULL; IAMStreamConfig *pSC = NULL; pCGB2->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVCap, IID_IAMStreamConfig, (void **)&pSC); pSC->GetFormat(&p); VIDEOINFOHEADER *pHd = (VIDEOINFOHEADER *)p->pbFormat;
pHd->AvgTimePerFrame = 10000000 / fps;
pHd->bmiHeader.biCompression = MAKEFOURCC('I', '4', '2', '0'); pHd->bmiHeader.biWidth = width; pHd->bmiHeader.biHeight = height;
pHd->bmiHeader.biBitCount = 12;
pHd->bmiHeader.biSizeImage = width * height * 3 / 2;
pHd->dwBitRate = pHd->bmiHeader.biSizeImage * 8 * fps;
p->subtype = WMMEDIASUBTYPE_I420; p->lSampleSize = pHd->bmiHeader.biSizeImage; pSC->SetFormat(p);
FreeAM_MEDIA_TYPE(p); pSC->Release();
|