Do you know what palettes are supported by your webcam ? Laurent
张源 a écrit : > > > 2009/7/2 Laurent Tarrisse <[email protected] <mailto:[email protected]>> > > Can you make a small test : > > nmake webcam-test-visu-c > > ... > > launch webcam-test-visu-c.exe > > Is it the same result ? > > Laurent > > 张源 a écrit : > > > > > > 2009/7/1 Laurent Tarrisse <[email protected] > <mailto:[email protected]> <mailto:[email protected] > <mailto:[email protected]>>> > > > > Laurent Tarrisse a écrit : > > > 张源 a écrit : > > > > > >> I have built qutecom-2-2-3faed9597730(debug),with vs 2005 on > > windows > > >> xp Chinese simplified but there are some problems with > Qutecom when > > >> making a webcam preview or a video call . > > >> > > >> The problems are as follows: when entering Video settings ,then > > click > > >> Webcam Preview button ,after a while ,the Label on the right > > side just > > >> shows a gray rectangle. The Video call is also just shows a gray > > >> rectangle,and after a while it crashed . > > >> Webcam Preview.png (/image/png/) 5K > > >> > > > <?ui=2&ik=ab85a7e087&view=att&th=1223455e9356b51f&attid=0.1&disp=attd> > > >> The piximage has been sucessfully catched by WebcamDriver. > > >> I found the problem may lie in this code section: > > >> pixertool.cpp > > >> > > >> *...* > > >> pixerrorcode* pix_convert*(int flags, piximage * img_dst, > > piximage * > > >> img_src) { > > >> *...* > > >> if (*img_convert*(&avp_target, pix_fmt_target, > > >> &avp_tmp_target, pix_fmt_source, > > >> img_dst->width, img_dst->height) *== -1*) { > > >> av_free(buf_tmp_target); > > >> return PIX_NOK; > > >> } > > >> * ...* > > >> } > > >> > > > Can you give me img_src->palette and img_src->dst ? > > > > > Oups, > > > > it is img_src->palette and img_dst->palette. > > > > Laurent > > >> *...* > > >> when calling * pix_convert*() ,the function *img_convert()* > allways > > >> return -1 which means the image conversion fails. > > >> > > >> Has anyone face the same problem ,please help me > > >> > > >> > > > ------------------------------------------------------------------------ > > >> > > >> > > > ------------------------------------------------------------------------ > > >> > > >> _______________________________________________ > > >> QuteCom-dev mailing list > > >> [email protected] > <mailto:[email protected]> > > <mailto:[email protected] > <mailto:[email protected]>> > > >> http://lists.qutecom.org/mailman/listinfo/qutecom-dev > > >> > > >> > > > > > > _______________________________________________ > > > QuteCom-dev mailing list > > > [email protected] > <mailto:[email protected]> > <mailto:[email protected] > <mailto:[email protected]>> > > > http://lists.qutecom.org/mailman/listinfo/qutecom-dev > > > > > > > _______________________________________________ > > QuteCom-dev mailing list > > [email protected] > <mailto:[email protected]> > <mailto:[email protected] > <mailto:[email protected]>> > > http://lists.qutecom.org/mailman/listinfo/qutecom-dev > > > > > > Thank you ! > > the functions are called as follows:1――>2――>3 > > *1 *void QtVideoSettings::frameCapturedEventHandler (IWebcamDriver * > > sender, piximage * image) {//重要函数 > > > > * ...* > > QSize qs(_ui->webcamPreviewLabel->width(), > > _ui->webcamPreviewLabel->height()); > > QImage tmpRgbImage(qs, QImage::Format_RGB32); > > *QtVideoQt::convertPixImageToQImage(image, qs, &tmpRgbImage);* > > QPixmap tmp = QPixmap::fromImage(tmpRgbImage); > > * ...* > > > > } > > *2 * void QtVideoQt::convertPixImageToQImage(piximage* pixImage, > const > > QSize& size, QImage* image) { > > * ...* > > piximage resizedPixImage; > > resizedPixImage.palette = PIX_OSI_RGB32; > > resizedPixImage.width = image->width(); > > resizedPixImage.height = image->height(); > > resizedPixImage.data = image->bits(); > > > > * pix_convert(PIX_NO_FLAG, &resizedPixImage, pixImage); > > * //测试// > > } > > > > * so the img_dst->palette == PIX_OSI_RGB32 img_src->palette == > > PIX_OSI_YUV420P* > > *3* pixerrorcode pix_convert(int flags, piximage * img_dst, > piximage * > > img_src) { > > > > * ...* > > enum PixelFormat pix_fmt_source > > =(PixelFormat)pix_ffmpeg_from_pix_osi(img_src->palette); > > enum PixelFormat pix_fmt_target = > > (PixelFormat)pix_ffmpeg_from_pix_osi(img_dst->palette); > > > > > > *...* > > > > > > #ifndef HAVE_SWSCALE > > //TODO optimize this part but will need the preparation of contexts > > ImgReSampleContext * resample_context = > > img_resample_init(img_dst->width, img_dst->height, > > img_src->width, img_src->height); > > > > if (!resample_context) { > > return PIX_NOK; > > } > > > > AVPicture avp_tmp_target; > > > > //we need to prepare a tmp buffer > > uint8_t * buf_tmp_target = (uint8_t > > *)av_malloc(avpicture_get_size(pix_fmt_source, img_dst->width, > > img_dst->height) * sizeof(uint8_t)); > > avpicture_fill(&avp_tmp_target, buf_tmp_target, pix_fmt_source, > > img_dst->width, img_dst->height); > > // > > > > //do the resampling > > img_resample(resample_context, &avp_tmp_target, &avp_source); > > img_resample_close(resample_context); > > // > > > > //do the conversion > > if (*img_convert*(&avp_target, pix_fmt_target, > > &avp_tmp_target, pix_fmt_source, > > img_dst->width, img_dst->height) == -1) { > > av_free(buf_tmp_target); > > return PIX_NOK;//转换没有成功 > > } > > * ...* > > } > > *img_dst->palette : PIX_OSI_RGB32* > > * img_src->palette : PIX_OSI_YUV420P* > > pix_fmt_target : *PIX_FMT_BGR32* > > pix_fmt_source : *PIX_FMT_YUV420P* > > img_convert()is a function in ffmpeg library,so the problems > might be > > in parameters passed into it .It involves encoding and decoding > which > > I totally don't know how to deal with . > > Thanks again ! > > > > > > _______________________________________________ > QuteCom-dev mailing list > [email protected] <mailto:[email protected]> > http://lists.qutecom.org/mailman/listinfo/qutecom-dev > > > > Thank you Laurent > I have made a small test with webcam-test-visu-c.exe. the results are > as follows: > * <error>15:32:03 [Common] DirectXWebcamDriver::setCaps:failed caps > request:(19,15,320,240) > > Using width:320 ,height:240 FPS:15 > **Starting capture... > I am called!! > frame _captured > ..... > > * > * * > setCaps error.png (/image/png/) 7K > <?ui=2&ik=ab85a7e087&view=att&th=1223a64d4bdb3ee5&attid=0.2&disp=attd> > webcam widget.png (/image/png/) 5K > <?ui=2&ik=ab85a7e087&view=att&th=1223a64d4bdb3ee5&attid=0.1&disp=attd> > The picture still coulid not show on the webcam widget > The execution results show below: > > DirectXWebcamDriver .cpp > * ...* > ** > WebcamErrorCode DirectXWebcamDriver::setDevice(const std::string & > deviceName) { > > //TODO: test if a webcam is already open > //TODO: refactor the COM initialization phase to avoid > //multiple initalisations and better handle unitialization > //cf trac ticket #1008 > // We really need to refactor that point > // I leave this line here just because the phapi thread > // must call this function (one time). We must move this elsewhere ... > CoInitialize(NULL); > //// > _pGraph.CoCreateInstance(CLSID_FilterGraph); > if (!_pGraph) { > LOG_ERROR("failed to create Graph builder"); > return WEBCAM_NOK; > } > _pBuild.CoCreateInstance(CLSID_CaptureGraphBuilder2); > if (!_pBuild) { > LOG_ERROR("failed to create Capture Graph builder"); > return WEBCAM_NOK; > } > _pBuild->SetFiltergraph(_pGraph); > //Create the Sample Grabber > HRESULT hr = CoCreateInstance(CLSID_SampleGrabber, NULL, > CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&(_pGrabberF)); > if (hr != S_OK) { > LOG_ERROR("failed to create COM instance"); > return WEBCAM_NOK; > } > //Add the filter to the graph > hr = (_pGraph)->AddFilter(_pGrabberF, L"Sample Grabber"); > if (hr != S_OK) { > LOG_ERROR("failed to add filter"); > return WEBCAM_NOK; > } > //Query the Sample Grabber for the ISampleGrabber interface. > _pGrabberF->QueryInterface(IID_ISampleGrabber, (void**)&_pGrabber); > hr = _pGrabber->SetBufferSamples(FALSE); > hr = _pGrabber->SetOneShot(FALSE); > //Set the Sample Grabber callback > //0: SampleCB (the buffer is the original buffer, not a copy) > //1: BufferCB (the buffer is a copy of the original buffer) > if (_pGrabber->SetCallback(this, 0) != S_OK) { > LOG_ERROR("failed to assign callback"); > return WEBCAM_NOK; > } > CComBSTR bstrName(deviceName.c_str()); > hr = FindMyCaptureDevice(&_pCap, bstrName); > if ((hr != S_OK) || !_pCap) { > return WEBCAM_NOK; > } > //initialize IAMStreamConfig > _iam = GetIAMStreamConfig(_pCap); > if (!_iam) { > return WEBCAM_NOK; > } > //add the capture filter to the graph > hr = (_pGraph)->AddFilter(_pCap, L""); > if (hr != S_OK) { > LOG_ERROR("failed to add filter"); > return WEBCAM_NOK; > } > //Add a null renderer filter > hr = CoCreateInstance(CLSID_NullRenderer, NULL, > CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&_pNull); > hr = (_pGraph)->AddFilter(_pNull, L"NullRender"); > _pBuild->RenderStream(&PIN_CATEGORY_CAPTURE, NULL, _pCap, NULL, > _pGrabberF); > //try to assign some palette until the webcam supports it > if (*setCaps*(PIX_OSI_YUV420P, _cachedFPS, 176, 144) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_YUV420P, _cachedFPS, 160, 120) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_I420, _cachedFPS, 176, 144) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_I420, _cachedFPS, 160, 120) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_RGB32, _cachedFPS, 176, 144) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_RGB32, _cachedFPS, 160, 120) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_RGB24, _cachedFPS, 176, 144) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_RGB24, _cachedFPS, 160, 120) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_YUV422, _cachedFPS, 176, 144) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_YUV422, _cachedFPS, 160, 120) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_RGB565, _cachedFPS, 176, 144) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_RGB565, _cachedFPS, 160, 120) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_RGB555, _cachedFPS, 176, 144) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_RGB555, _cachedFPS, 160, 120) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_YUY2, _cachedFPS, 176, 144) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_YUY2, _cachedFPS, 160, 120) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_UYVY, _cachedFPS, 176, 144) != WEBCAM_OK) { > if (*setCaps*(PIX_OSI_UYVY, _cachedFPS, 160, 120) != WEBCAM_OK) { > }}}}}}}}}}}}}}}}}} > ** > *all of the 18 "if(setCaps(...)!=WEBCAM_OK)" above are executed > .That's to say all the 18 " setCaps() " return WEBCAM_NOK;* > ** > ** > *readCaps();* > if (getPalette() == PIX_OSI_UNSUPPORTED) { > return WEBCAM_NOK; > } > _isOpen = true; > return WEBCAM_OK; > > } > WebcamErrorCode DirectXWebcamDriver::setCaps(pixosi palette, unsigned > fps, unsigned resolutionWidth, unsigned resolutionHeight) { > _cachedFPS = fps; > > if (!isOpen()) { > return WEBCAM_NOK; > } > > if (!_pCap) { > LOG_FATAL("webcam not initialized"); > } > if (!_iam) { > LOG_FATAL("webcam not initialized"); > } > > int iCount, iSize; > HRESULT hr = _iam->GetNumberOfCapabilities(&iCount, &iSize); > > VIDEO_STREAM_CONFIG_CAPS scc; > if (sizeof(scc) != iSize) { > LOG_ERROR("wrong config structure"); > return WEBCAM_NOK; > } > > for (int i = 0; i < iCount; i++) { > AM_MEDIA_TYPE * pmt = NULL; > hr = _iam->GetStreamCaps(i, &pmt, reinterpret_cast<BYTE *>(&scc)); > if (hr == S_OK) { > pixosi wc_palette = pix_directx_to_pix_osi(pmt->subtype); > if (wc_palette != palette) { > hr = E_FAIL; > continue; > } > VIDEOINFOHEADER * pvi = (VIDEOINFOHEADER *) pmt->pbFormat; > pvi->bmiHeader.biWidth = resolutionWidth; > pvi->bmiHeader.biHeight = resolutionHeight; > pvi->AvgTimePerFrame = (LONGLONG) (10000000. / (double)fps); > hr = _iam->SetFormat(pmt); > if (hr != S_OK) { > hr = E_FAIL; > continue; > } else { > LOG_DEBUG("assigned caps : (" > + String::fromNumber(palette) > + "," + String::fromNumber(fps) > + "," + String::fromNumber(resolutionWidth) > + "," + String::fromNumber(resolutionHeight) > + ")"); > break; > } > } > } > > readCaps(); > > if (hr == S_OK) { > return WEBCAM_OK; > } > > *LOG_ERROR("failed caps request: (" > + String::fromNumber(palette) > + "," + String::fromNumber(fps) > + "," + String::fromNumber(resolutionWidth) > + "," + String::fromNumber(resolutionHeight) > + ")");* > > *error occured , I am trying to figure out which function > (DirectXWebcamDriver::setResolution() or > DirectXWebcamDriver::setPalette() or others)calling setCaps() results > in this error * > > > return WEBCAM_NOK; > } > void DirectXWebcamDriver::*readCaps*() { > > VIDEOINFOHEADER * pvi; > pixosi palette; > AM_MEDIA_TYPE * pmt = NULL; > HRESULT hr = _iam->GetFormat(&pmt); > if (pmt->formattype == FORMAT_VideoInfo) { > pvi = (VIDEOINFOHEADER *) pmt->pbFormat; > palette = pix_directx_to_pix_osi(pmt->subtype); > } > _cachedPalette = palette; > _cachedWidth = pvi->bmiHeader.biWidth; > _cachedHeight = pvi->bmiHeader.biHeight; > > > } > > > ------------------------------------------------------------------------ > > > ------------------------------------------------------------------------ > _______________________________________________ QuteCom-dev mailing list [email protected] http://lists.qutecom.org/mailman/listinfo/qutecom-dev
