Thursday, 15 July 2010

video streaming - Enumerating UVC Properties items of a property set of a camera -



video streaming - Enumerating UVC Properties items of a property set of a camera -

i enumerating uvc properties photographic camera using ikstopologyinfo , ikscontrol interface. using both mft , direct show code.during enumeration various guid illustration clsid_iamcameracontrol, clsid_iamvideoprocamp , many more.

now iamvideoprocamp back upwards 10 properties , iamcameracontrol supports 7 properties

not photographic camera supports property items.i wanted know exact properties(enum index/value) supported camera.can query using ikstopologyinfo , ikscontrol ?is ther other way this.

here code enumerate properties i.e. code gives me interface clsid_iamcameracontrol,clsid_iamvideoprocamp

hresult hret = s_ok; ccomptr<ikstopologyinfo> kstopology = null; byte* plist = null; { if(!m_pmediasource) break; if(m_supppropsetguids.size()) break; hret = m_pmediasource->queryinterface(iid_ppv_args(&kstopology)); if(failed(hret)) break; kstopology->get_numnodes(&m_dwnumnodes); (ulong ulnode=0; ulnode < m_dwnumnodes; ulnode++ ) { ccomptr<ikscontrol> kscontrol = 0; guid nodetype = guid_null; dword dwbytesreturned = 0; ksproperty ksprop = {0}; ksprop.set = guid_null; ksprop.id = 0; // ignored ksprop.flags = ksproperty_type_setsupport; ksp_node ksnode = {0}; ksnode.property.set = guid_null; ksnode.nodeid = ulnode; ksnode.property.flags = ksproperty_type_setsupport; kstopology->get_nodetype(ulnode, &nodetype); hret = kstopology->createnodeinstance(ulnode, iid_ppv_args(&kscontrol)); if(failed(hret)) continue; hret = kscontrol->ksproperty(&ksprop, sizeof(ksproperty), null, null, &dwbytesreturned); if( hret == hresult_from_win32(error_more_data) && dwbytesreturned ) { plist = (byte*)calloc(dwbytesreturned, sizeof(byte) ); if ( plist == null ) continue; hret = kscontrol->ksproperty(&ksprop, sizeof(ksproperty), plist, dwbytesreturned, &dwbytesreturned); if(failed(hret)) break; } else continue; guid* pguidlist = (guid*)plist; int icount = dwbytesreturned/sizeof(guid); for(int = 0; < icount; i++ ) { if( !lookupps( &pguidlist[i] ) ) m_supppropsetguids.push_back( pguidlist[i] ); } if(plist) free(plist); plist = null; } }while(false); if(plist) free(plist); plist = null; homecoming hret;

use directshow interfaces of iamvideoprocamp , iamcameracontrol this.

here's c# class encapsulates cameracontrol , removes of painful parts. videoprocamp analogous:

public class cameracontrolsetting : idisposable { private readonly cameracontrolproperty property; private iamcameracontrol controlinterface; private int min; private int max; private int steppingdelta; private int defaultvalue; public cameracontrolflags capabilityflags; public int min { { homecoming min; } } public int max { { homecoming max; } } public int steppingdelta { { homecoming steppingdelta; } set { steppingdelta = value; } // shouldn't exposed, whitebalancesteppingdelta 1! } public int defaultvalue { { homecoming defaultvalue; } } public cameracontrolsetting(cameracontrolproperty property, iamcameracontrol controlinterface) { this.property = property; this.controlinterface = controlinterface; } public void getrange() { if (controlinterface == null) return; controlinterface.getrange(property, out min, out max, out steppingdelta, out defaultvalue, out capabilityflags); getcurrentvalueandflags(); } private void getcurrentvalueandflags() { if (controlinterface == null) return; controlinterface.get(property, out currentvalue, out currentflags); } private void setcurrentvalueandflags() { if (controlinterface == null) return; controlinterface.set(property, currentvalue, currentflags); } private cameracontrolflags currentflags; public cameracontrolflags currentflags { { homecoming currentflags; } set { getcurrentvalueandflags(); currentflags = value; setcurrentvalueandflags(); } } private int currentvalue; public int currentvalue { { homecoming currentvalue; } set { currentflags = cameracontrolflags.manual; currentvalue = value; setcurrentvalueandflags(); } } public void dispose() { controlinterface = null; } }

then, utilize above class follows:

public iamcameracontrol cameracontrol { { homecoming m_pcapturefilter iamcameracontrol; } } public cameracontrolsetting zoom { get; private set; } public cameracontrolsetting focus { get; private set; } public bool hasautofocus { { homecoming (focus != null) && ((focus.capabilityflags & cameracontrolflags.auto) == cameracontrolflags.auto); } } private void getcamerafeatures() { zoom = new cameracontrolsetting(cameracontrolproperty.zoom, cameracontrol); focus = new cameracontrolsetting(cameracontrolproperty.focus, cameracontrol); // cameracontrol properties zoom.getrange(); focus.getrange(); if (hasautofocus) { focus.currentflags = cameracontrolflags.auto; } ... }

video-streaming directshow ms-media-foundation wdm

No comments:

Post a Comment